Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / arp / arp_ @ e5ce7492

Historique | Voir | Annoter | Télécharger (1,31 ko)

1 fec8686c Sven Hartge
#!/bin/sh
2
#
3
# Plugin to monitor ARP entries per interface
4
#
5
# Parameters understood:
6
#
7
#       config   (required)
8
#       autoconf (optional)
9
#
10
#  Made by Sven Hartge (sven AT svenhartge DOT de)
11
#
12
#
13
14
15
#%# family=contrib
16
#%# capabilities=autoconf suggest
17
18
INTERFACE=`basename $0 | sed 's/^arp_//g' | tr '_' '.'`
19
20
if [ "$1" = "autoconf" ]; then
21
    # Search for arp
22
    which arp >/dev/null 2>/dev/null || (echo "no (can't find arp binary)" && exit 1)
23
24
    # ...or success
25
    echo yes
26
    exit 0
27
fi
28
29
if [ "$1" = "suggest" ]; then
30
  if [ -r /proc/net/dev ]; then
31
    egrep '^ *(eth|wlan|ath|ra)[0-9]+(\.[0-9]+)?:' /proc/net/dev | cut -f1 -d: | sed 's/ //g' | tr '.' '_'
32
    exit 0
33
  else
34
    exit 1
35
  fi
36
fi
37
38
39
40
if [ "$1" = "config" ]; then
41
        echo "graph_title ARP entries for $INTERFACE"
42
        echo 'graph_args --base 1000 -l 0'
43
        echo 'graph_vlabel Entries'
44
        echo 'graph_category network'
45
	echo 'graph_scale no'
46
        echo "graph_info This graph shows the number of ARP entries registered by the system for interface $INTERFACE."
47
	echo 'entries.label ARP entries'
48
	echo 'entries.draw LINE2'
49
	echo 'entries.type GAUGE'
50
	echo 'entries.info Number of ARP entries'
51
	exit 0
52
fi
53
54 4a56eb18 Sven Hartge
arp -an -i $INTERFACE | awk 'BEGIN { regex="<incomplete>";} { if (!match($4,regex)) { a[$4] }} END{for(i in a){n++};print "entries.value " n}'