10 if_err_
- Wildcard plugin to monitor errors
, packet drops
, and
11 collisions of network interfaces
15 This is a wildcard plugin. To monitor an interface
, link
16 if_err_
<interface
> to this
file. E.g.
18 ln -s /usr
/share
/munin
/plugins
/if_err_ \
19 /etc
/munin
/plugins
/if_err_eth0
23 This plugin does not use environment variables.
27 Any device found
in /proc
/net
/dev can be monitored. Examples include
28 ipsec
*, eth
*, irda
* and lo.
30 Please note that aliases cannot be monitored with this plugin.
43 #%# capabilities=autoconf suggest
47 .
"$MUNIN_LIBDIR/plugins/plugin.sh"
49 INTERFACE
=${0##*/if_err_}
51 if [ "$1" = "autoconf" ]; then
52 if [ -r /proc
/net
/dev
]; then
56 echo "no (/proc/net/dev not found)"
61 if [ "$1" = "suggest" ]; then
62 if [ -r /proc
/net
/dev
]; then
63 sed -rne '/^[[:space:]]*(lo|gre[[:digit:]]|sit[[:digit:]]+|[a-z0-9]+\.[0-9]+):/d;s,^[[:space:]]*([^:]+):.*,\1,p' /proc
/net
/dev
68 if [ "$1" = "config" ]; then
69 address
="$(ip -j address show dev $INTERFACE | jq -r '.[0].addr_info[].local' | tr '\n' ' ')"
70 echo "graph_order rcvd trans"
71 echo "graph_title $INTERFACE (${address% }) errors"
72 echo 'graph_args --base 1000'
73 # shellcheck disable=SC2016
74 echo 'graph_vlabel packets in (-) / out (+) per ${graph_period}'
75 echo 'graph_category network'
76 echo "graph_info This graph shows the amount of errors, packet drops, and collisions on the $INTERFACE network interface."
77 echo 'rcvd.label errors'
78 echo 'rcvd.type COUNTER'
81 echo 'trans.label errors'
82 echo 'trans.type COUNTER'
83 echo 'trans.negative rcvd'
84 echo 'trans.warning 1'
85 echo 'rxdrop.label drops'
86 echo 'rxdrop.type COUNTER'
87 echo 'rxdrop.graph no'
88 echo 'txdrop.label drops'
89 echo 'txdrop.type COUNTER'
90 echo 'txdrop.negative rxdrop'
91 echo 'collisions.label collisions'
92 echo 'collisions.type COUNTER'
100 # Escape dots in the interface name (eg. vlans) before using it as a regex
101 if [ -r "/sys/class/net/$INTERFACE/statistics/rx_bytes" ]; then
102 echo "rcvd.value $(cat "/sys/class/net/$INTERFACE/statistics/rx_errors")"
103 echo "trans.value $(cat "/sys/class/net/$INTERFACE/statistics/tx_errors")"
104 echo "rxdrop.value $(cat "/sys/class/net/$INTERFACE/statistics/rx_dropped")"
105 echo "txdrop.value $(cat "/sys/class/net/$INTERFACE/statistics/tx_dropped")"
106 echo "collisions.value $(cat "/sys/class/net/$INTERFACE/statistics/collisions")"
108 awk -v interface
="$INTERFACE" \
109 'BEGIN { gsub(/\./, "\\.", interface) }
110 $1 ~ "^" interface ":" {
111 split($0, a, /: */); $0 = a[2];
112 print "rcvd.value " $3 "\ntrans.value " $11;
113 print "rxdrop.value " $4 "\ntxdrop.value " $12;
114 print "collisions.value " $14;