Projet

Général

Profil

Révision e17278db

IDe17278db431c5a336a60eec036d6ae8ddc49ec33
Parent fcd1327d
Enfant 9ff495b3

Ajouté par Johannes il y a presque 14 ans

Initial version

Voir les différences:

plugins/other/chrony
1
#!/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
# Magic markers (optional - used by munin-config and installation
18
# scripts):
19
#
20
#%# family=auto
21
#%# capabilities=autoconf
22

  
23
#Modify this to fit other chronyc path
24
CHRONYC=/usr/bin/chronyc
25

  
26
#Frequency has extremely higher values than other. Therefore they are fitted by scaling. Adjust the factor here
27
FACTOR=1000
28
#fieldfactors="1000 1 1000 100 1000 1000"
29
fieldfactors="1000 1 100 100 1000 1000"
30
#Fields to catch and graph, second line is friendly name
31
fields="systime frequency residualfreq skew rootdelay rootdispersion"
32
fieldnames="System Time (seconds,x=Frequency (seconds,x=Residual Freq (ppm,x=Skew (ppm,x=Root delay(seconds,x=Root dispersion (seconds,x"
33

  
34

  
35
if [ "$1" = "autoconf" ]; then
36
	if [ -f "$CHRONYC" ]; then 
37
		echo yes
38
		exit 0
39
	else
40
		echo "no (no $CHRONYC)"
41
		exit 1
42
	fi
43
fi
44

  
45
if [ "$1" = "config" ]; then
46

  
47
        echo 'graph_title Chrony Tracking Stats'
48
        echo 'graph_args --base 1000 -l 0'
49
        #echo 'graph_vlabel seconds / ${graph_period}'
50
        echo 'units (seconds,ppm)'
51
	#echo 'graph_total total'
52
	echo 'graph_category NTP'    
53
		i=0
54
		for a in $fields ; do
55
			i=$(expr $i + 1);
56
			#echo "i=$i"
57
			word=`echo $fieldnames | cut -f $i -d '='`;
58
			factor=`echo $fieldfactors | cut -f $i -d ' '`;
59
			echo "$a.label $word$factor)";
60
			echo "$a.type GAUGE";
61
		done
62
        exit 0
63
fi
64

  
65

  
66
#Remove superflous whitespace (hinders cut), remove non-needed output lines, remove more space,cut out final result value, scale values to factor if needed, output values in munin-required format
67
j=0
68
chronyc tracking  |  \
69
	sed "s/  */ /g" | \
70
	sed "1,3d" | \
71
#	grep -v "Frequency" | \
72
	sed "s/ : /:/g" | \
73
	cut -f 2 -d ':' | \
74
	cut -f 1 -d ' ' | \
75
	while read LINE; do
76
		j=$(expr $j + 1);
77
		measure=`echo $fields | cut -f $j -d ' '`;
78
		factor=`echo $fieldfactors | cut -f $j -d ' '`;
79
		echo -en "$measure.value ";
80
#		if [ "$measure" = "frequency" ]; then 
81
			#measure is frequency do not enlarge numbers
82
#			echo $LINE | xargs printf "%1.2f";
83
#		else
84
			#measure is not frequency, enlarge numbers to make them showable together with frequency
85
			echo $LINE*$factor | bc | xargs printf "%1.2f";
86
#		fi
87
		#echo $LINE*100 | bc | xargs printf "%1.2f";
88
		echo;
89
	done
90

  

Formats disponibles : Unified diff