1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-25 10:28:36 +00:00

Plugins xen_*: fix shellcheck issues

This commit is contained in:
Lars Kruse 2018-08-01 23:51:11 +02:00
parent 0987cf33a2
commit 4b4a6a01e1
4 changed files with 55 additions and 64 deletions

View file

@ -7,8 +7,8 @@
#%# capabilities=autoconf suggest
DOMAIN=$( basename $0 | sed 's/^xen_traffic_//g' )
NAME=$( echo $DOMAIN | sed -e's/-/_/g' )
DOMAIN=$( basename "$0" | sed 's/^xen_traffic_//g' )
NAME=$( echo "$DOMAIN" | sed -e's/-/_/g' )
if [ "$1" = "autoconf" ]; then
if which xm > /dev/null ; then
@ -27,12 +27,13 @@ if [ "$1" = "autoconf" ]; then
fi
if [ "$1" = "suggest" ]; then
xm list | awk '{print $1}' | egrep -v "^(Name|Domain-0)"
xm list | awk '{print $1}' | grep -v -E "^(Name|Domain-0)"
exit 0
fi
if [ "$1" = "config" ]; then
echo "graph_title Xen Traffic for $NAME"
# shellcheck disable=SC2016
echo 'graph_vlabel bits in (-) / out (+) per ${graph_period}'
echo 'graph_args --base 1024 -l 0'
echo 'graph_category Virtualization'
@ -47,13 +48,12 @@ if [ "$1" = "config" ]; then
exit 0
fi
dev=$( xm network-list $DOMAIN | egrep "^[0-9]+" | sed 's@^.*vif/\([0-9]*\)/\([0-9]*\).*$@vif\1.\2@')
dev=$( xm network-list "$DOMAIN" | grep '^[0-9]\+' | sed 's@^.*vif/\([0-9]*\)/\([0-9]*\).*$@vif\1.\2@')
awk -v interface="$dev" \
'BEGIN { gsub(/\./, "\\.", interface) } \
'BEGIN { gsub(/\./, "\\.", interface) }
$1 ~ "^" interface ":" {
split($0, a, /: */); $0 = a[2]; \
print "in.value " $1 "\nout.value " $9 \
split($0, a, /: */); $0 = a[2];
print "in.value " $1 "\nout.value " $9;
}' \
/proc/net/dev