Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / time / chrony @ 81db94e2

Historique | Voir | Annoter | Télécharger (2,09 ko)

1 e17278db Johannes
#!/bin/bash
2
#
3
# Script to parse Chrony Tracking Output
4
#
5
# Parameters understood:
6
#
7
#       config   (required)
8
#       autoconf (optional - used by munin-config)
9
#
10
# $log$
11
# Revision 0.1 2008/08/23 13:06:00 joti
12
# First version only chronyc tracking, autodetection included.
13
#
14
# Revision 0.2 2008/10/11 16:09:00 joti
15
# Added scaling of other values to match with frequency, added more description to fields
16
#
17 1a0b0167 Tobias Richter
# Revision 0.3 2014/02/16 zjttoefs
18
# reduce forking by using awk
19
# do not limit output precision
20
# add stratum monitoring
21
# detect slow/fast time or freqency and adjust sign of value accordingly
22
# remove commented out code
23
#
24
# Magic markers (optional - used by munin-config and installation scripts):
25 e17278db Johannes
#
26
#%# family=auto
27
#%# capabilities=autoconf
28
29
#Modify this to fit other chronyc path
30
CHRONYC=/usr/bin/chronyc
31
32 1a0b0167 Tobias Richter
#Frequency has extremely higher values than other. Therefore they are fitted by scaling. Adjust the factors here
33
fieldfactors="1 1000 1 100 100 1000 1000"
34
#fieldfactors="1 1000000 0.1 100 10 10 10"
35
fields="stratum systime frequency residualfreq skew rootdelay rootdispersion"
36
fieldnames="Stratum (=System Time (seconds,x=Frequency (ppm,x=Residual Freq (ppm,x=Skew (ppm,x=Root delay(seconds,x=Root dispersion (seconds,x"
37 e17278db Johannes
38
if [ "$1" = "autoconf" ]; then
39
	if [ -f "$CHRONYC" ]; then 
40
		echo yes
41
		exit 0
42
	else
43
		echo "no (no $CHRONYC)"
44
		exit 1
45
	fi
46
fi
47
48
if [ "$1" = "config" ]; then
49
        echo 'graph_title Chrony Tracking Stats'
50
        echo 'graph_args --base 1000 -l 0'
51
        echo 'units (seconds,ppm)'
52 81db94e2 Gabriele Pohl
	echo 'graph_category time'    
53 e17278db Johannes
		i=0
54
		for a in $fields ; do
55
			i=$(expr $i + 1);
56
			word=`echo $fieldnames | cut -f $i -d '='`;
57
			factor=`echo $fieldfactors | cut -f $i -d ' '`;
58
			echo "$a.label $word$factor)";
59
			echo "$a.type GAUGE";
60
		done
61
        exit 0
62
fi
63
64 1a0b0167 Tobias Richter
# remove non-needed output lines, remove labels, rescale and label values while detecting slow/fast keywords
65
chronyc tracking | sed -e 1d -e 3d -e "s/.*://" | \
66
	awk -v FAC="$fieldfactors" -v NAM="$fields" \
67
	'BEGIN { split(FAC,factors," "); split(NAM,names," "); } 
68
	{ /slow/ ? SIGN=-1 : SIGN=1 ; print names[NR]".value ",SIGN*$1*factors[NR]}'