mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-25 02:18:08 +00:00
new plugin time/ntp_packets that graphs NTP packet rates
This commit is contained in:
parent
6f0db08c25
commit
5f0fd4e5c3
1 changed files with 74 additions and 0 deletions
74
plugins/time/ntp_packets
Executable file
74
plugins/time/ntp_packets
Executable file
|
@ -0,0 +1,74 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- python -*-
|
||||
|
||||
# This plugin graphs the rate of sent, received, ignored, and dropped
|
||||
# NTP packets for an ntpd process. Similarly to the if_ plugins,
|
||||
# received packets are graphed as negative values, and sent packets
|
||||
# are graphed as positive values. Ignored and dropped packets are
|
||||
# graphed as positive values.
|
||||
#
|
||||
# The values are retrieved using ntpq or ntpdc, depending on the
|
||||
# version of the NTP distribution.
|
||||
#
|
||||
# Symlink this plugin into the node's plugins directory (like
|
||||
# /etc/munin/plugins).
|
||||
#
|
||||
# Copyright © 2013 Kenyon Ralph <kenyon@kenyonralph.com>
|
||||
#
|
||||
# This program is free software. It comes without any warranty, to the
|
||||
# extent permitted by applicable law. You can redistribute it and/or
|
||||
# modify it under the terms of the Do What The Fuck You Want To Public
|
||||
# License, Version 2, as published by Sam Hocevar. See
|
||||
# http://www.wtfpl.net/ for more details.
|
||||
#
|
||||
# The latest version of this plugin can be found in the munin contrib
|
||||
# repository at https://github.com/munin-monitoring/contrib. Issues
|
||||
# with this plugin may be reported there. Patches accepted through the
|
||||
# normal github process of forking the repository and submitting a
|
||||
# pull request with your commits.
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
if len(sys.argv) == 2 and sys.argv[1] == 'config':
|
||||
print('graph_title NTP traffic')
|
||||
print('graph_vlabel Packets/${graph_period} received(-)/sent(+)')
|
||||
print('graph_info This graph shows the packet rates of this ntpd. Ignored and dropped packets are graphed as positive values.')
|
||||
print('graph_category time')
|
||||
print('received.label Received')
|
||||
print('received.type DERIVE')
|
||||
print('received.graph no')
|
||||
print('sent.label Rx/Tx')
|
||||
print('sent.type DERIVE')
|
||||
print('sent.negative received')
|
||||
print('dropped.label Dropped')
|
||||
print('dropped.type DERIVE')
|
||||
print('ignored.label Ignored')
|
||||
print('ignored.type DERIVE')
|
||||
sys.exit(0)
|
||||
|
||||
os.environ['PATH'] = '/usr/local/sbin:/usr/local/bin:' + os.environ['PATH']
|
||||
|
||||
# Assuming that the ntpd version is the same as the ntpq or ntpdc
|
||||
# version. This is how a proper install should be.
|
||||
|
||||
version = subprocess.check_output(['ntpq', '-c', 'version'], universal_newlines=True).split()[1][0:5].replace('.', '')
|
||||
|
||||
if int(version) >= 427:
|
||||
cmd = 'ntpq'
|
||||
else:
|
||||
cmd = 'ntpdc'
|
||||
|
||||
iostats = dict()
|
||||
|
||||
iostats_output = subprocess.check_output([cmd, '-c', 'iostats'], universal_newlines=True).splitlines()
|
||||
|
||||
for line in iostats_output: iostats[line.split(':')[0]] = int(line.split(':')[1])
|
||||
|
||||
print('received.value ' + str(iostats['received packets']))
|
||||
print('sent.value ' + str(iostats['packets sent']))
|
||||
print('dropped.value ' + str(iostats['dropped packets']))
|
||||
print('ignored.value ' + str(iostats['ignored packets']))
|
||||
|
||||
sys.exit(0)
|
Loading…
Add table
Add a link
Reference in a new issue