Projet

Général

Profil

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

root / plugins / network / ifem_ @ 4de0ceb0

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

1
#!/bin/sh
2
#
3
# Wildcard-plugin to monitor FreeBSD em(4) and igb(4) network interfaces
4
# using sysctl dev.em.0.mac_stats 64-bit counters
5
# To monitor an # interface, link if_<interface> to this file. E.g.
6
#
7
#    ln -s /usr/share/munin/node/plugins-auto/if_ /etc/munin/node.d/if_em0
8
#
9
# ...will monitor em0.
10
#
11
# Magic markers (optional - used by munin-config and some installation
12
# scripts):
13
#
14
#%# family=auto
15
#%# capabilities=autoconf suggest
16

    
17

    
18
INTERFACE=`basename $0 | sed 's/^ifem_//g'`
19

    
20
if [ "$1" = "autoconf" ]; then
21
	if [ -x /sbin/sysctl ]; then
22
		echo yes
23
		exit 0
24
	else
25
		echo "no (/sbin/sysctl not found)"
26
		exit 0
27
	fi
28
fi
29

    
30
if [ "$1" = "suggest" ]; then
31
	if [ -x /sbin/sysctl ]; then
32
		/sbin/sysctl -q dev.em dev.igb | /usr/bin/awk -F '.' '/mac_stats\.total_pkts_recvd/{print $2$3;}'
33
		exit 0
34
	else
35
		exit 1
36
	fi
37
fi
38

    
39
if [ "$1" = "config" ]; then
40

    
41
	echo "graph_order rbytes obytes" 
42
	echo "graph_title $INTERFACE traffic"
43
	echo 'graph_args --base 1000'
44
	echo 'graph_vlabel bits per ${graph_period} in (-) / out (+)'
45
	echo 'graph_category network'
46
	echo "graph_info This graph shows the traffic of the $INTERFACE network interface. Please note that the traffic is shown in bits per second, not bytes."
47
	echo 'rbytes.label received'
48
        echo 'rbytes.type COUNTER'
49
        echo 'rbytes.graph no'
50
        echo 'rbytes.cdef rbytes,8,*'
51
        echo 'obytes.label bps'
52
	echo 'obytes.type COUNTER'
53
	echo 'obytes.negative rbytes'
54
	echo 'obytes.cdef obytes,8,*'
55
	echo "obytes.info Traffic sent (+) and received (-) on the $INTERFACE network interface."
56
	exit 0
57
fi
58

    
59
oid=`echo $INTERFACE | sed -E 's/^(em|igb)([0-9]+)$/dev\.\1\.\2\.mac_stats/g'`
60
rbytes='U'
61
obytes='U'
62

    
63
while read ev val; do
64
   case "$ev" in
65
	"$oid.good_octets_recvd:")
66
	   rbytes="$val"
67
	   ;;
68
        "$oid.good_octets_txd:")
69
	   obytes="$val"
70
	   ;;
71
        "$oid.good_octest_txd:")
72
	   obytes="$val"
73
	   ;;
74
   esac
75
done << EOF
76
$(/sbin/sysctl -q $oid 2>/dev/null)
77
EOF
78

    
79
printf "rbytes.value ${rbytes}\nobytes.value ${obytes}\n"
80

    
81