2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00
contrib-munin/plugins/xen/xen_traffic_

57 lines
1.4 KiB
Plaintext
Raw Normal View History

2008-02-02 16:16:31 +01:00
#!/bin/sh
# Author: mario manno <projects@manno.name>
# Description: measure traffic for one xen host
# Get xen host name from symlink
#
#%# family=auto
#%# capabilities=autoconf suggest
2018-08-01 23:51:11 +02:00
DOMAIN=$( basename "$0" | sed 's/^xen_traffic_//g' )
NAME=$( echo "$DOMAIN" | sed -e's/-/_/g' )
2008-02-02 16:16:31 +01:00
if [ "$1" = "autoconf" ]; then
if which xm > /dev/null ; then
if [ -r /proc/net/dev ]; then
echo yes
else
echo "no (/proc/net/dev not found)"
fi
2008-02-02 16:16:31 +01:00
else
echo "no (xm not found)"
fi
exit 0
fi
if [ "$1" = "suggest" ]; then
2018-08-01 23:51:11 +02:00
xm list | awk '{print $1}' | grep -v -E "^(Name|Domain-0)"
2008-02-02 16:16:31 +01:00
exit 0
fi
if [ "$1" = "config" ]; then
echo "graph_title Xen Traffic for $NAME"
2018-08-01 23:51:11 +02:00
# shellcheck disable=SC2016
2008-02-02 16:16:31 +01:00
echo 'graph_vlabel bits in (-) / out (+) per ${graph_period}'
echo 'graph_args --base 1024 -l 0'
echo 'graph_category virtualization'
2008-02-02 16:16:31 +01:00
echo 'out.label sent'
echo 'out.type DERIVE'
echo 'out.min 0'
echo 'out.cdef out,8,*'
echo 'in.label received'
echo 'in.type DERIVE'
echo 'in.min 0'
echo 'in.cdef in,8,*'
exit 0
fi
2018-08-01 23:51:11 +02:00
dev=$( xm network-list "$DOMAIN" | grep '^[0-9]\+' | sed 's@^.*vif/\([0-9]*\)/\([0-9]*\).*$@vif\1.\2@')
2008-02-02 16:16:31 +01:00
awk -v interface="$dev" \
2018-08-01 23:51:11 +02:00
'BEGIN { gsub(/\./, "\\.", interface) }
2008-02-02 16:16:31 +01:00
$1 ~ "^" interface ":" {
2018-08-01 23:51:11 +02:00
split($0, a, /: */); $0 = a[2];
print "in.value " $1 "\nout.value " $9;
2008-02-02 16:16:31 +01:00
}' \
/proc/net/dev