-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnode_exporter_chrony.sh
53 lines (39 loc) · 2.25 KB
/
node_exporter_chrony.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env bash
# Author: Tamir Suliman
# Script inspired by the chrony.py
# text_exporter node_exporter for ntp clients data
# 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"}'