1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-22 02:51:03 +00:00

chrony_status: perlpod and small fixes

This commit is contained in:
Kim B. Heino 2021-04-06 10:46:03 +03:00 committed by Lars Kruse
parent ebac55597d
commit 085d7a9ba8

View file

@ -1,13 +1,40 @@
#!/usr/bin/python3 -tt #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Munin plugin to monitor chrony NTP daemon status. """Munin plugin to monitor chrony NTP daemon status.
Copyright 2014, Kim B. Heino, b@bbbs.net, Foobar Oy =head1 NAME
License GPLv2+
chrony_status - monitor chrony NTP daemon status
=head1 APPLICABLE SYSTEMS
Systems with chrony installed.
=head1 CONFIGURATION
No configuration is required for this plugin.
=head1 INTERPRETATION
Monitor Chrony's stratum value (with warning), time offset, network delay
and clock frequency. It would be very easy to monitor all Chrony's values, but
IMHO they aren't needed. The most important information in stratum, giving
"synced" / "not synced" value.
=head1 AUTHOR
Kim B. Heino <b@bbbs.net>
=head1 LICENSE
GPLv2
=head1 MAGIC MARKERS
#%# capabilities=autoconf
#%# family=auto #%# family=auto
#%# capabilities=autoconf
=cut
""" """
import os import os
@ -29,7 +56,7 @@ def get_values():
Return: list of (label, value, description) Return: list of (label, value, description)
""" """
try: try:
output = subprocess.run(['/usr/bin/chronyc', 'tracking'], output = subprocess.run(['chronyc', 'tracking'],
stdout=subprocess.PIPE, check=False, stdout=subprocess.PIPE, check=False,
encoding='utf-8', errors='ignore') encoding='utf-8', errors='ignore')
except FileNotFoundError: except FileNotFoundError:
@ -55,6 +82,9 @@ def config():
print('graph_args --base 1000 --lower-limit 0') print('graph_args --base 1000 --lower-limit 0')
print('stratum.label Stratum') print('stratum.label Stratum')
print('stratum.warning 1:9') print('stratum.warning 1:9')
# Use long unknown_limit to allow server reboot without Munin warning.
# Clock doesn't drift fast so there's no hurry with warning.
print('stratum.unknown_limit 15')
print('multigraph chrony_systime') print('multigraph chrony_systime')
print('graph_title Chrony system time offset') print('graph_title Chrony system time offset')
@ -94,7 +124,7 @@ def fetch():
if __name__ == '__main__': if __name__ == '__main__':
if len(sys.argv) > 1 and sys.argv[1] == 'autoconf': if len(sys.argv) > 1 and sys.argv[1] == 'autoconf':
print('yes' if get_values() else 'no') print('yes' if get_values() else 'no (chrony is not running)')
elif len(sys.argv) > 1 and sys.argv[1] == 'config': elif len(sys.argv) > 1 and sys.argv[1] == 'config':
config() config()
else: else: