mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-24 18:07:20 +00:00
83 lines
2.1 KiB
Bash
Executable file
83 lines
2.1 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
: <<=cut
|
|
|
|
=head1 NAME
|
|
|
|
parse Chrony Tracking output for timeserver status information
|
|
|
|
=head1 APPLICABLE SYSTEMS
|
|
|
|
Any system with a local chronyd service.
|
|
|
|
=head1 CONFIGURATION
|
|
|
|
No configuration.
|
|
|
|
=head1 MAGIC MARKERS
|
|
|
|
#%# family=auto
|
|
#%# capabilities=autoconf
|
|
|
|
=head1 VERSION
|
|
|
|
Revision 0.1 2008/08/23 13:06:00 joti
|
|
|
|
First version only chronyc tracking, autodetection included.
|
|
|
|
Revision 0.2 2008/10/11 16:09:00 joti
|
|
|
|
Added scaling of other values to match with frequency, added more description to fields
|
|
|
|
Revision 0.3 2014/02/16 zjttoefs
|
|
|
|
reduce forking by using awk
|
|
do not limit output precision
|
|
add stratum monitoring
|
|
detect slow/fast time or freqency and adjust sign of value accordingly
|
|
remove commented out code
|
|
|
|
=head1 AUTHOR
|
|
|
|
joti
|
|
zjttoefs
|
|
|
|
=cut
|
|
|
|
CHRONYC="$(which chronyc | head -1)"
|
|
|
|
# Frequency has extremely higher values than other. Therefore they are fitted by scaling. Adjust the factors here
|
|
fieldfactors="1 1000 1 100 100 1000 1000"
|
|
fields="stratum systime frequency residualfreq skew rootdelay rootdispersion"
|
|
fieldnames="Stratum (=System Time (seconds,x=Frequency (ppm,x=Residual Freq (ppm,x=Skew (ppm,x=Root delay(seconds,x=Root dispersion (seconds,x"
|
|
|
|
if [ "$1" = "autoconf" ]; then
|
|
if [ -n "$CHRONYC" ] && [ -x "$CHRONYC" ]; then
|
|
echo yes
|
|
else
|
|
echo "no (missing 'chronyc' executable)"
|
|
fi
|
|
exit 0
|
|
fi
|
|
|
|
if [ "$1" = "config" ]; then
|
|
echo 'graph_title Chrony Tracking Stats'
|
|
echo 'graph_args --base 1000 -l 0'
|
|
echo 'units (seconds,ppm)'
|
|
echo 'graph_category time'
|
|
i=0
|
|
for a in $fields ; do
|
|
i=$((i + 1))
|
|
word="$(echo "$fieldnames" | cut -f "$i" -d '=')"
|
|
factor="$(echo "$fieldfactors" | cut -f "$i" -d ' ')"
|
|
echo "$a.label $word$factor)";
|
|
echo "$a.type GAUGE"
|
|
done
|
|
exit 0
|
|
fi
|
|
|
|
# remove non-needed output lines, remove labels, rescale and label values while detecting slow/fast keywords
|
|
"$CHRONYC" tracking | sed -e 1d -e 3d -e "s/.*://" | \
|
|
awk -v FAC="$fieldfactors" -v NAM="$fields" \
|
|
'BEGIN { split(FAC,factors," "); split(NAM,names," ");
|
|
{ /slow/ ? SIGN=-1 : SIGN=1 ; print names[NR]".value ",SIGN*$1*factors[NR]}'
|