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

Update ntp_packets

With Debian 10 the command "ntpq -c iostats -c sysstats" produces one empty line.
The additional if condition tackles this.

Traceback (most recent call last):
  File "/etc/munin/plugins/ntp_packets", line 91, in <module>
    stats[line.split(':')[0]] = int(line.split(':')[1])
IndexError: list index out of range
This commit is contained in:
d0m84 2019-07-26 22:22:49 +02:00 committed by Lars Kruse
parent ee68a404b5
commit d0139a588d

View file

@ -87,7 +87,8 @@ stats_output = subprocess.check_output([cmd, '-c', 'iostats', '-c', 'sysstats'],
universal_newlines=True).splitlines() universal_newlines=True).splitlines()
for line in stats_output: for line in stats_output:
stats[line.split(':')[0]] = int(line.split(':')[1]) if len(line.split(':')) == 2:
stats[line.split(':')[0]] = int(line.split(':')[1])
print('received.value ' + str(stats['received packets'])) print('received.value ' + str(stats['received packets']))
print('sent.value ' + str(stats['packets sent'])) print('sent.value ' + str(stats['packets sent']))