1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
#!/usr/bin/env python
"""
Linux ARP plugin test
Morten Siebuhr
sbhr@sbhr.dk
12/12 2008
"""
from munin import Plugin
from os.path import exists
p = Plugin("ARP Cache", "MAC addresses", "Network")
# Information
p.info = "Shows how many interfaces are listed in the system's ARP cache"
p.args = "--base 1000 -l 0"
# Autoconfigure
p.autoconf = lambda: exists("/proc/net/arp")
# Populate with data
for line in open("/proc/net/arp").readlines():
if "IP address" in line:
continue
(ip, hw, flags, address, mogl, dev) = line.split()
if not dev in p:
p[dev].value = 0
p[dev].label = dev
p[dev].draw = "AREA"
p[dev].value += 1
# Run it!
p.run()
|