mirror of
https://github.com/munin-monitoring/contrib.git
synced 2018-11-08 00:59:34 +01:00
Plugins xen_*: fix shellcheck issues
This commit is contained in:
parent
0987cf33a2
commit
4b4a6a01e1
@ -28,9 +28,9 @@ fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
|
||||
if [ ! -e $statefile ]; then
|
||||
touch $statefile
|
||||
fi
|
||||
if [ ! -e "$statefile" ]; then
|
||||
touch "$statefile"
|
||||
fi
|
||||
|
||||
echo 'graph_title Xen Domain Utilisation'
|
||||
echo 'graph_args --base 1000 -l 0 --upper-limit 100 --rigid'
|
||||
@ -39,26 +39,24 @@ if [ "$1" = "config" ]; then
|
||||
echo 'graph_category Virtualization'
|
||||
echo 'graph_info This graph shows how many percent of the CPU time was used by each domain'
|
||||
|
||||
xm list | grep -v "^Name .* Time(s)$" | \
|
||||
while read name domid mem cpu state time console; do
|
||||
name=`echo $name | sed -e"s/[-.]/_/g"`
|
||||
TEST=`less $statefile | grep "^${name}$" | wc -l`
|
||||
if [ $TEST -ne 1 ]; then
|
||||
echo "$name" >> $statefile
|
||||
fi
|
||||
done
|
||||
xm list | grep -v "^Name .* Time(s)$" | while read -r name domid mem cpu state time console; do
|
||||
name=$(echo "$name" | sed -e"s/[-.]/_/g")
|
||||
TEST=$(grep "^${name}$" "$statefile" | wc -l)
|
||||
if [ "$TEST" -ne 1 ]; then
|
||||
echo "$name" >> "$statefile"
|
||||
fi
|
||||
done
|
||||
|
||||
FIRST=1
|
||||
cat $statefile | sort | \
|
||||
while read name; do
|
||||
FIRST=1
|
||||
sort < "$statefile" | while read -r name; do
|
||||
echo "$name.label $name"
|
||||
echo "$name.type COUNTER"
|
||||
if [ $FIRST -eq 1 ]; then
|
||||
echo "$name.draw AREA"
|
||||
FIRST=0
|
||||
else
|
||||
echo "$name.draw STACK"
|
||||
fi
|
||||
if [ "$FIRST" -eq 1 ]; then
|
||||
echo "$name.draw AREA"
|
||||
FIRST=0
|
||||
else
|
||||
echo "$name.draw STACK"
|
||||
fi
|
||||
echo "$name.min 0"
|
||||
echo "$name.max 100"
|
||||
echo "$name.info % of the CPU time spent for $name"
|
||||
@ -66,12 +64,10 @@ if [ "$1" = "config" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
xm list | grep -v "^Name .* Time(s)$" | \
|
||||
while read name domid mem cpu state time console; do
|
||||
name=`echo $name | sed -e "s/[-.]/_/g"`
|
||||
# only seconds
|
||||
time=`echo $time | sed -e "s/\..//"`
|
||||
# scale 60s/60s => 100%/60s
|
||||
time=`echo "$time*100/60" | bc`
|
||||
# shellcheck disable=SC2034
|
||||
xm list | grep -v "^Name .* Time(s)$" | while read -r name domid mem cpu state time console; do
|
||||
name=$(echo "$name" | sed -e "s/[-.]/_/g")
|
||||
# scale 60s/60s => 100%/60s
|
||||
time=$(echo "$time" | awk '{print ($1 * 100 / 60) }')
|
||||
echo "$name.value $time"
|
||||
done
|
||||
|
@ -31,11 +31,10 @@ if [ "$1" = "config" ]; then
|
||||
echo 'graph_vlabel MB'
|
||||
echo 'graph_category Virtualization'
|
||||
echo 'graph_info This graph shows of many mS wall time where used by a domain'
|
||||
# xm info | while read name bla value; do echo "$name $value"; done
|
||||
$XM info | while read name bla value; do
|
||||
#total_memory 2047
|
||||
#free_memory 1476
|
||||
name=`echo $name | sed -e"s/-/_/"`
|
||||
"$XM" info | while read -r name bla value; do
|
||||
# total_memory 2047
|
||||
# free_memory 1476
|
||||
name=$(echo "$name" | sed -e"s/-/_/")
|
||||
|
||||
if [ "$name" = "total_memory" ]; then
|
||||
echo "$name.label $name"
|
||||
@ -55,13 +54,10 @@ if [ "$1" = "config" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
$XM info | while read name bla value; do
|
||||
name=`echo $name | sed -e"s/-/_/"`
|
||||
if [ "$name" = "total_memory" ]; then
|
||||
echo "$name.value $value"
|
||||
fi
|
||||
if [ "$name" = "free_memory" ]; then
|
||||
# shellcheck disable=SC2034
|
||||
"$XM" info | while read -r name bla value; do
|
||||
name=$(echo "$name" | sed -e"s/-/_/")
|
||||
if [ "$name" = "total_memory" ] || [ "$name" = "free_memory" ]; then
|
||||
echo "$name.value $value"
|
||||
fi
|
||||
done
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -27,44 +27,43 @@ fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo 'graph_title Xen Traffic'
|
||||
# shellcheck disable=SC2016
|
||||
echo 'graph_vlabel bits received (-) / sent (+) per ${graph_period}'
|
||||
echo 'graph_args --base 1024 -l 0'
|
||||
echo 'graph_category Virtualization'
|
||||
DOMAINS=$(xm list | awk '{print $1}' | egrep -v "^(Name|Domain-0)")
|
||||
DOMAINS=$(xm list | awk '{print $1}' | grep -v -E "^(Name|Domain-0)")
|
||||
for dom in $DOMAINS; do
|
||||
name=$( echo $dom | tr .- __ )
|
||||
name=$( echo "$dom" | tr .- __ )
|
||||
#echo $name"UP.label $name"
|
||||
#echo $name"DOWN.label $name"
|
||||
|
||||
echo $name'Down.label received'
|
||||
echo $name'Down.type COUNTER'
|
||||
echo $name'Down.graph no'
|
||||
echo "${name}Down.label received"
|
||||
echo "${name}Down.type COUNTER"
|
||||
echo "${name}Down.graph no"
|
||||
echo "${name}Down.cdef ${name}Down,8,*"
|
||||
echo "${name}Up.label ${name}"
|
||||
echo $name'Up.type COUNTER'
|
||||
echo "${name}Up.type COUNTER"
|
||||
echo "${name}Up.negative ${name}Down"
|
||||
echo "${name}Up.cdef ${name}Up,8,*"
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
DOMAINS=$(xm list | awk '{print $1}' | egrep -v "^(Name|Domain-0)")
|
||||
DOMAINS=$(xm list | awk '{print $1}' | grep -v -E "^(Name|Domain-0)")
|
||||
for dom in $DOMAINS; do
|
||||
dev=$( xm list $dom --long | awk '/vifname / { print $2 }' | sed 's/)//' )
|
||||
if [ "$dev" = "" ]; then
|
||||
dev=$( xm network-list $dom |\
|
||||
egrep "^[0-9]+" | sed 's@^.*vif/\([0-9]*\)/\([0-9]*\).*$@vif\1.\2@')
|
||||
fi
|
||||
name=$( echo $dom | tr .- __ )
|
||||
dev=$( xm list "$dom" --long | awk '/vifname / { print $2 }' | sed 's/)//' )
|
||||
if [ -z "$dev" ]; then
|
||||
dev=$( xm network-list "$dom" | grep '^[0-9]\+' | sed 's@^.*vif/\([0-9]*\)/\([0-9]*\).*$@vif\1.\2@')
|
||||
fi
|
||||
name=$( echo "$dom" | tr .- __ )
|
||||
#awk -v name="$name" -v interface="$dev" -F'[: \t]+' \
|
||||
#'{ sub(/^ */,""); if ($1 == interface) \
|
||||
#print name"DOWN.value "$2"\n"name"UP.value "$10; }' /proc/net/dev
|
||||
awk -v name="$name" -v interface="$dev" \
|
||||
'BEGIN { gsub(/\./, "\\.", interface) } \
|
||||
'BEGIN { gsub(/\./, "\\.", interface) }
|
||||
$1 ~ "^" interface ":" {
|
||||
split($0, a, /: */); $0 = a[2]; \
|
||||
print name"Down.value " $1 "\n"name"Up.value " $9 \
|
||||
split($0, a, /: */); $0 = a[2];
|
||||
print name"Down.value " $1 "\n"name"Up.value " $9;
|
||||
}' \
|
||||
/proc/net/dev
|
||||
done
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user