munin-contrib/plugins/ntp/ntp_drift

86 lines
1.4 KiB
Bash
Executable File

#! /bin/sh
# -*- sh -*-
: <<=cut
=head1 NAME
ntp_drift - Munin plugin to monitor the NTP drift value.
=head1 APPLICABLE SYSTEMS
Any ntpd host.
=head1 CONFIGURATION
The following configuration parameters are used by this plugin:
[ntp_drift]
env.driftfile - Path to driftfile.
=head2 DEFAULT CONFIGURATION
[ntp_drift]
env.driftfile "/var/lib/ntp/ntp.drift"
=head1 USAGE
Link this plugin to /etc/munin/plugins/ and restart the munin-node.
=head1 AUTHOR
HORINOUCHI Masato <thermes+github@confei.to> 2019-07-16
=head1 LICENSE
Same as munin.
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf
=cut
driftfile=${driftfile:-'/var/lib/ntp/ntp.drift'}
do_autoconf () {
if [ -r "$driftfile" ]; then
echo "yes"
else
echo "no (could not read driftfile '$driftfile'.)"
fi
}
do_config () {
cat <<'EOM'
graph_title NTP drift
graph_args --base 1000
graph_vlabel Parts Per Million
graph_category time
drift.label Frequency Offset
graph_info The frequency of the local clock oscillator. A single floating point number, which records the frequency offset measured in parts-per-million (PPM).
EOM
}
do_ () {
if [ -r "$driftfile" ]; then
echo "drift.value $(cat "$driftfile")"
else
echo "drift.value U"
fi
}
case $1 in
autoconf|config|'')
do_"$1"
;;
*)
echo "Don't know how to do that" >&2
exit 1
;;
esac