2007-11-20 09:41:08 +01:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Plugin to plot OpenVZ VE Stats
|
|
|
|
#
|
|
|
|
# by Rene Weselowski
|
|
|
|
# http://www.dead.at
|
|
|
|
#
|
|
|
|
# Parameters:
|
|
|
|
#
|
|
|
|
# config (required)
|
|
|
|
# autoconf (optional - used by munin-config)
|
|
|
|
#
|
|
|
|
# $Log$
|
|
|
|
#
|
|
|
|
#%# family=auto
|
2016-10-17 02:59:11 +02:00
|
|
|
#%# capabilities=autoconf suggest
|
2007-11-20 09:41:08 +01:00
|
|
|
|
2016-10-17 03:03:46 +02:00
|
|
|
ATTRIBUTE=$(basename "$0" | sed 's/^openvz_//g')
|
2007-11-20 09:41:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
if [ "$1" = "autoconf" ]; then
|
2016-10-17 02:55:39 +02:00
|
|
|
if which vzlist >/dev/null; then
|
|
|
|
echo yes
|
|
|
|
else
|
|
|
|
echo "no (missing 'vzlist' executable)"
|
|
|
|
fi
|
2007-11-20 09:41:08 +01:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2016-10-17 02:59:11 +02:00
|
|
|
if [ "$1" = "suggest" ]; then
|
|
|
|
echo "laverage"
|
|
|
|
echo "status"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2007-11-20 09:41:08 +01:00
|
|
|
if [ "$1" = "config" ]; then
|
|
|
|
echo "graph_title $ATTRIBUTE"
|
|
|
|
echo "graph_args --base 1000 -l 0"
|
|
|
|
echo "graph_scale yes"
|
|
|
|
echo "graph_vlabel $ATTRIBUTE Value"
|
2017-02-23 15:31:40 +01:00
|
|
|
echo "graph_category virtualization"
|
2007-11-20 09:41:08 +01:00
|
|
|
echo "graph_info This graph shows OpenVZ: $ATTRIBUTE"
|
2016-10-17 02:52:08 +02:00
|
|
|
vzlist -a -H --no-trim -o hostname | awk '{gsub(/\./,"_",$1)
|
2016-10-17 03:03:46 +02:00
|
|
|
print("'$ATTRIBUTE'"$1".label "$1"\n" \
|
|
|
|
"'$ATTRIBUTE'"$1".info '$ATTRIBUTE' for VE"$1)}'
|
2007-11-20 09:41:08 +01:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2013-03-07 08:51:18 +01:00
|
|
|
filter() { cat; }
|
|
|
|
[ "$ATTRIBUTE" = 'laverage' ] && filter() { sed -e 's/[0-9\.]*\/\(.*\)\/.*$/\1/g'; }
|
|
|
|
[ "$ATTRIBUTE" = 'status' ] && filter() { sed -e 's/running/10/g;s/stopped/0/g'; }
|
|
|
|
#TODO: filter for uptime
|
|
|
|
|
2016-10-17 03:03:46 +02:00
|
|
|
vzlist -a -H --no-trim -o "hostname,$ATTRIBUTE" | filter | awk '{gsub(/\./,"_",$1)
|
2007-11-20 09:41:08 +01:00
|
|
|
print("'$ATTRIBUTE'"$1".value "$2)}'
|
|
|
|
|
|
|
|
exit 0
|