#!/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
#%# capabilities=autoconf

ATTRIBUTE=`basename $0 | sed 's/^openvz_//g'`


if [ "$1" = "autoconf" ]; then
        echo yes
        exit 0
fi

if [ "$1" = "config" ]; then
        echo "graph_title $ATTRIBUTE"
        echo "graph_args --base 1000 -l 0"
        echo "graph_scale yes"
        echo "graph_vlabel $ATTRIBUTE Value"
        echo "graph_category openvz"
        echo "graph_info This graph shows OpenVZ: $ATTRIBUTE"
        vzlist -a -H -o hostname | awk '{gsub(/\./,"_",$1)
        print("'$ATTRIBUTE'"$1".label "$1"\n" \
        "'$ATTRIBUTE'"$1".info '$ATTRIBUTE' for VE"$1)}'
        exit 0
fi

vzlist -a -H -o hostname,$ATTRIBUTE | awk '{gsub(/\./,"_",$1)
         print("'$ATTRIBUTE'"$1".value "$2)}'

exit 0

