File: arp

package info (click to toggle)
munin 2.0.76-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,064 kB
  • sloc: perl: 11,684; java: 1,924; sh: 1,632; makefile: 636; javascript: 365; python: 267
file content (38 lines) | stat: -rwxr-xr-x 698 bytes parent folder | download | duplicates (13)
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()