mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
Plugin snmp__airport: port to python3
This commit is contained in:
parent
09b88141b3
commit
3a2f2ec7ec
1 changed files with 29 additions and 29 deletions
|
@ -1,9 +1,9 @@
|
|||
#!/usr/bin/python
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Munin plugin to monitor various items of data from an Apple Airport Express/Extreme or a Time Capsule.
|
||||
Monitor various items of data from an Apple Airport Express/Extreme or a Time Capsule.
|
||||
|
||||
|
||||
=head1 INSTALLATION
|
||||
|
@ -71,9 +71,9 @@ import os
|
|||
try:
|
||||
import netsnmp
|
||||
except ImportError:
|
||||
print """ERROR: Unable to import netsnmp.
|
||||
print("""ERROR: Unable to import netsnmp.
|
||||
Please install the Python bindings for libsnmp.
|
||||
On Debian/Ubuntu machines this package is named 'libsnmp-python'"""
|
||||
On Debian/Ubuntu machines this package is named 'libsnmp-python'""", file=sys.stderr)
|
||||
sys.exit(-3)
|
||||
|
||||
DEBUG = None
|
||||
|
@ -89,12 +89,12 @@ WANIFINDEX = None
|
|||
def dbg(text):
|
||||
"""Print some debugging text if DEBUG=1 is in our environment"""
|
||||
if DEBUG is not None:
|
||||
print "DEBUG: %s" % text
|
||||
print("DEBUG: %s" % text)
|
||||
|
||||
|
||||
def usage():
|
||||
"""Print some usage information about ourselves"""
|
||||
print __doc__
|
||||
print(__doc__)
|
||||
|
||||
|
||||
def parseName(name):
|
||||
|
@ -216,8 +216,8 @@ def getExternalInterface():
|
|||
try:
|
||||
WANIFINDEX = interfaces.index('mgi1') + 1
|
||||
except ValueError:
|
||||
print "ERROR: Unable to find WAN interface mgi1"
|
||||
print interfaces
|
||||
print("ERROR: Unable to find WAN interface mgi1")
|
||||
print(interfaces)
|
||||
sys.exit(-3)
|
||||
|
||||
dbg("getExternalInterface: found mgi1 at index: %d" % WANIFINDEX)
|
||||
|
@ -293,15 +293,15 @@ def main(clients=None):
|
|||
clients = getData()
|
||||
|
||||
if CMD == 'clients':
|
||||
print "clients.value %s" % getNumClients()
|
||||
print("clients.value %s" % getNumClients())
|
||||
elif CMD == 'dhcpclients':
|
||||
print "dhcpclients.value %s" % getNumDHCPClients()
|
||||
print("dhcpclients.value %s" % getNumDHCPClients())
|
||||
elif CMD == 'wanTraffic':
|
||||
print "recv.value %s" % getExternalInOctets()
|
||||
print "send.value %s" % getExternalOutOctets()
|
||||
print("recv.value %s" % getExternalInOctets())
|
||||
print("send.value %s" % getExternalOutOctets())
|
||||
else:
|
||||
for client in clients:
|
||||
print "MAC_%s.value %s" % (client, clients[client][CMD])
|
||||
print("MAC_%s.value %s" % (client, clients[client][CMD]))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -322,44 +322,44 @@ if __name__ == '__main__':
|
|||
|
||||
if len(sys.argv) > 1:
|
||||
if sys.argv[1] == 'config':
|
||||
print """
|
||||
print("""
|
||||
graph_category network
|
||||
host_name %s""" % DESTHOST
|
||||
host_name %s""" % DESTHOST)
|
||||
|
||||
if CMD == 'signal':
|
||||
print """graph_args -l 0 --lower-limit -100 --upper-limit 0
|
||||
print("""graph_args -l 0 --lower-limit -100 --upper-limit 0
|
||||
graph_title Wireless client signal
|
||||
graph_scale no
|
||||
graph_vlabel dBm Signal"""
|
||||
graph_vlabel dBm Signal""")
|
||||
elif CMD == 'noise':
|
||||
print """graph_args -l 0 --lower-limit -100 --upper-limit 0
|
||||
print("""graph_args -l 0 --lower-limit -100 --upper-limit 0
|
||||
graph_title Wireless client noise
|
||||
graph_scale no
|
||||
graph_vlabel dBm Noise"""
|
||||
graph_vlabel dBm Noise""")
|
||||
elif CMD == 'rate':
|
||||
print """graph_args -l 0 --lower-limit 0 --upper-limit 500
|
||||
print("""graph_args -l 0 --lower-limit 0 --upper-limit 500
|
||||
graph_title Wireless client WiFi rate
|
||||
graph_scale no
|
||||
graph_vlabel WiFi Rate"""
|
||||
graph_vlabel WiFi Rate""")
|
||||
elif CMD == 'clients':
|
||||
print """graph_title Number of connected clients
|
||||
print("""graph_title Number of connected clients
|
||||
graph_args --base 1000 -l 0
|
||||
graph_vlabel number of wireless clients
|
||||
graph_info This graph shows the number of wireless clients connected
|
||||
clients.label clients
|
||||
clients.draw LINE2
|
||||
clients.info The number of clients."""
|
||||
clients.info The number of clients.""")
|
||||
elif CMD == 'dhcpclients':
|
||||
print """graph_title Number of active DHCP leases
|
||||
print("""graph_title Number of active DHCP leases
|
||||
graph_args --base 1000 -l 0
|
||||
graph_vlabel number of DHCP clients
|
||||
graph_info This graph shows the number of active DHCP leases
|
||||
dhcpclients.label leases
|
||||
dhcpclients.draw LINE2
|
||||
dhcpclients.info The number of leases."""
|
||||
dhcpclients.info The number of leases.""")
|
||||
elif CMD == 'wanTraffic':
|
||||
speed = getWanSpeed()
|
||||
print """graph_title WAN interface traffic
|
||||
print("""graph_title WAN interface traffic
|
||||
graph_order recv send
|
||||
graph_args --base 1000
|
||||
graph_vlabel bits in (-) / out (+) per ${graph_period}
|
||||
|
@ -377,9 +377,9 @@ send.type DERIVE
|
|||
send.negative recv
|
||||
send.cdef send,8,*
|
||||
send.max %s
|
||||
send.min 0""" % (speed, speed)
|
||||
send.min 0""" % (speed, speed))
|
||||
else:
|
||||
print "Unknown command: %s" % CMD
|
||||
print("Unknown command: %s" % CMD, file=sys.stderr)
|
||||
sys.exit(-2)
|
||||
|
||||
if CMD in ['clients', 'dhcpclients', 'wanTraffic']:
|
||||
|
@ -388,7 +388,7 @@ send.min 0""" % (speed, speed)
|
|||
else:
|
||||
clients = getData()
|
||||
for client in clients:
|
||||
print "MAC_%s.label %s" % (client, client)
|
||||
print("MAC_%s.label %s" % (client, client))
|
||||
|
||||
sys.exit(0)
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue