File: ntp_kernel_pll_off.in

package info (click to toggle)
munin 2.0.76-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,064 kB
  • sloc: perl: 11,684; java: 1,924; sh: 1,632; makefile: 636; javascript: 365; python: 267
file content (60 lines) | stat: -rw-r--r-- 1,405 bytes parent folder | download | duplicates (4)
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
53
54
55
56
57
58
59
60
#!@@GOODSH@@
# -*- sh -*-

: <<EOF

=head1 NAME

ntp_kernel_pll_off - Plugin to monitor the kernel's PLL offset for the
NTP status

=head1 CONFIGURATION

No configuration

=head1 AUTHORS

Unknown author

=head1 LICENSE

GPLv2

=head1 MAGIC MARKERS

 #%# family=auto
 #%# capabilities=autoconf

=cut

EOF

export PATH=/usr/local/sbin:$PATH

if [ "$1" = "autoconf" ]; then
    { ntpq -c kerninfo; ntpdc -c kerninfo; } 2>/dev/null |
    awk 'BEGIN { ev=1; }
         /^pll offset:/ { ev=0; }
         END { if (ev == 0) { print "yes";} else { print "no (command ntpq or ntpdc not found)"; } exit 0; }'
    exit 0
fi

if [ "$1" = "config" ]; then
    echo 'graph_title NTP kernel PLL offset (secs)'
    echo 'graph_vlabel PLL offset (secs)'
    echo 'graph_category time'
    echo 'graph_info The kernel offset for the phase-locked loop used by NTP'
    echo 'ntp_pll_off.label pll-offset'
    echo 'ntp_pll_off.info Phase-locked loop offset in seconds'
    exit 0
fi

printf 'ntp_pll_off.value '

ntpq_name=$(ntpq -c version | sed 's/[^[:alpha:]].*//')
ntpq_version=$(ntpq -c version | grep --extended-regexp --only-matching '[[:digit:]]\.[[:digit:]]\.[[:digit:]]')
if [ "$ntpq_name" = "ntpq" ] && [ "$(echo "$ntpq_version" | tr -d '.')" -lt 427 ]; then
    ntpdc -c kerninfo | awk '/^pll offset:/ { printf("%.9f\n", $3) }'
else
    ntpq -c kerninfo | awk '/^pll offset:/ { printf("%.9f\n", $3 / 1000) }'
fi