From 24431ce3fde3f0d5005abbbfa0a6dff8f9249531 Mon Sep 17 00:00:00 2001 From: Tamir Suliman Date: Sat, 21 Oct 2023 19:36:55 +0200 Subject: [PATCH 1/3] adding chrony.sh to parse chrony NTP clients --- chrony.sh | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 chrony.sh diff --git a/chrony.sh b/chrony.sh new file mode 100644 index 0000000..c076091 --- /dev/null +++ b/chrony.sh @@ -0,0 +1,56 @@ +#!/usr/bin/env bash + +# Author: Tamir Suliman +# Script inspired by the chrony.py +# Usage: add this to crontab: + + +# Extract chronyc tracking data and write it to a Prometheus text file collector + +# Run chronyc to get tracking data and store it in a variable +tracking_data=$(chronyc tracking) + +# HELP node_chronyc_refid Reference ID of the NTP server. +# TYPE node_chronyc_refid gauge +echo "$tracking_data" | awk -F '[(]' '/Reference ID/{print "node_chronyc_refid{server=\""$1"\"} 1"}' + +# HELP node_chronyc_stratum Stratum of the NTP server. +# TYPE node_chronyc_stratum gauge +echo "$tracking_data" | awk '/Stratum/ {print "node_chronyc_stratum "$3}' + +# HELP node_chronyc_offset Last offset from NTP time (seconds). +# TYPE node_chronyc_offset gauge +echo "$tracking_data" | awk '/Last offset/ {print "node_chronyc_last_offset "$4}' + +# HELP node_chronyc_rms_offset Last offset from NTP time (seconds). +# TYPE node_chronyc_rms_offset gauge +echo "$tracking_data" | awk '/RMS offset/ {print "node_chronyc_rms_offset "$4}' + +# HELP node_chronyc_frequency Frequency of the NTP server(ppm). +# TYPE node_chronyc_frequency gauge +echo "$tracking_data" | awk '/Frequency/ {print "node_chronyc_frequency "$3}' + +# HELP node_chronyc_residual_freq Residual Frequency of the NTP server(ppm). +# TYPE node_chronyc_residual_freq gauge +echo "$tracking_data" | awk '/Residual freq/ {print "node_chronyc_resideual_freq "$4}' + +# HELP node_chronyc_skew Skew of the NTP server(ppm). +# TYPE node_chronyc_skew gauge +echo "$tracking_data" | awk '/Skew/ {print "node_chronyc_skew "$3}' + +# HELP node_chronyc_root_delay Root delay of the NTP server (seconds). +# TYPE node_chronyc_root_delay gauge +echo "$tracking_data" | awk '/Root delay/ {print "node_chronyc_root_delay "$4}' + +# HELP node_chronyc_root_dispersion Root dispersion of the NTP server (seconds). +# TYPE node_chronyc_root_dispersion gauge +echo "$tracking_data" | awk '/Root dispersion/ {print "node_chronyc_root_dispersion "$4}' + +# HELP node_chronyc_update_interval Update interval of the NTP server (seconds). +# TYPE node_chronyc_update_interval gauge +echo "$tracking_data" | awk '/Update interval/ {print "node_chronyc_update_interval "$4}' + +# HELP node_chronyc_leap_status Leap status of the NTP server. +# TYPE node_chronyc_leap_status gauge +echo "$tracking_data" | awk '/Leap status/ {print "node_chronyc_leap_status{status=\""$4"\"} 1"}' + From eb84b7e54890685173b1dcef711d9b64830f0e6c Mon Sep 17 00:00:00 2001 From: Tamir Suliman Date: Sat, 21 Oct 2023 20:30:12 +0200 Subject: [PATCH 2/3] adding chrony.sh to parse Chrony NTP clients --- chrony.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/chrony.sh b/chrony.sh index c076091..fa7df51 100644 --- a/chrony.sh +++ b/chrony.sh @@ -2,7 +2,6 @@ # Author: Tamir Suliman # Script inspired by the chrony.py -# Usage: add this to crontab: # Extract chronyc tracking data and write it to a Prometheus text file collector From 81a27a4cab3db92e795443a21fe387e73c3ff1bd Mon Sep 17 00:00:00 2001 From: Tamir Suliman Date: Sun, 22 Oct 2023 12:09:59 +0200 Subject: [PATCH 3/3] Adding chrony.sh to parse Chrony NTP clients Fixed sign off message missing Signed-off-by: Tamir Suliman --- chrony.sh | 2 ++ 1 file changed, 2 insertions(+) mode change 100644 => 100755 chrony.sh diff --git a/chrony.sh b/chrony.sh old mode 100644 new mode 100755 index fa7df51..7ef7d36 --- a/chrony.sh +++ b/chrony.sh @@ -2,6 +2,8 @@ # Author: Tamir Suliman # Script inspired by the chrony.py +# +# # Extract chronyc tracking data and write it to a Prometheus text file collector