Projet

Général

Profil

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

root / plugins / arp / arp_ @ fec8686c

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

1
#!/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
echo -n "entries.value "
55
arp -an -i $INTERFACE | grep -v "incomplete" | awk '{ print $4; }' | sort -u | wc -l 
56