Projet

Général

Profil

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

root / plugins / arp / arp_ @ e10e386b

Historique | Voir | Annoter | Télécharger (1,65 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
#  change to iproute by Martin89 (martin AT martin89 DOT de)
12
#
13
#
14

    
15

    
16
#%# family=contrib
17
#%# capabilities=autoconf suggest
18

    
19
case "$1" in
20
	autoconf)
21
		# Search for ip
22
		which ip >/dev/null 2>&1
23
		if [ $? -ne 0 ]; then
24
			echo "no (can't find ip binary)"
25
			exit 1
26
		fi
27
		# ...or success
28
		echo 'yes'
29
		exit 0
30
	;;
31
	suggest)
32
		if [ ! -r /proc/net/dev ]; then
33
			exit 1
34
		fi
35
		awk '$1~ /^(eth|wlan|ath|ra)[0-9]+(\.[0-9]+)?/ { gsub(":", ""); gsub("\.", "_"); print $1 }' /proc/net/dev
36
		exit 0
37
	;;
38
	config)
39
		INTERFACE="$(basename $0 | sed 's/^arp_//g' | tr '_' '.')"
40
		if [ -z "$INTERFACE" ]; then
41
			exit 1
42
		fi
43
		echo "graph_title ARP/NDP entries for $INTERFACE"
44
		cat <<'EOM'
45
graph_args --base 1000 -l 0
46
graph_vlabel Entries
47
graph_category network
48
graph_scale no
49
graph_info This graph shows the number of ARP and NDP entries for a interface.
50
entries4.label ARP entries
51
entries4.info Number of ARP entries
52
entries6global.label NDP global entries
53
entries6global.info Number of NDP entries for global IPv6 address
54
entries6local.label NDP local entries
55
entries6local.info Number of NDP entries for link-local IPv6 address (fe80::/64)
56
EOM
57
		exit 0
58
	;;
59
esac
60

    
61
INTERFACE="$(basename $0 | sed 's/^arp_//g' | tr '_' '.')"
62
if [ -z "$INTERFACE" ]; then
63
	exit 1
64
fi
65
ip neigh show dev "$INTERFACE" | awk 'BEGIN { a=0; b=0; c=0 }
66
/(REACHABLE|DELAY|STALE)/ { if ($1~ /^fe80:/){c++} else{if ($1~ /^[0-9]+\./) {a++} else{b++} } }
67
END { print "entries4.value", a "\nentries6global.value", b, "\nentries6local.value", c }'