Open main menu

OpenVZ Virtuozzo Containers Wiki β

Monitoring openvz resources using munin

Revision as of 01:37, 25 June 2007 by Alexkuklin (talk | contribs)

munin plugin

The plugin listed below grabs all the bean counters' values.

#!/bin/sh
#
# plugin to monitor OpenVZ bean counters.
#
#
#%# family=auto
#%# capabilities=autoconf suggest

ATTR=`basename $0 | sed 's/^vebc_//g'`

if [ "$1" = "autoconf" ]; then
        if [ -r /proc/bc/0/resources ]; then
                echo yes
                exit 0
        else
                echo "no (/proc/bc/0/resources not found)"
                exit 1
        fi
fi

if [ "$1" = "suggest" ]; then

        if [ -r /proc/bc/0/resources ]; then
            cat /proc/bc/0/resources |
            while read str; do

                vals=($str)
                echo ${vals[0]}
            done

                exit 0
        else
                exit 1
        fi
fi


if [ "$1" = "config" ]; then

#       echo "graph_order down up"
        echo "graph_title $ATTR beancounter for VE's"
        echo 'graph_category system'
        echo "graph_info 'VE bean counters info'"


        for VEID in `ls -d1 /proc/bc/???`; do
            id=`basename $VEID`
            grep $ATTR $VEID/resources |
            while read str; do

                vals=($str)
                name=${vals[0]}
                echo ${id}.label $id
                echo "${id}.warning  ${vals[3]}"
                echo "${id}.critical  ${vals[4]}"
            done
        done

        exit 0
fi;


        for VEID in `ls -d1 /proc/bc/???`; do
            id=`basename $VEID`
            grep $ATTR $VEID/resources |
            while read str; do

                vals=($str)
                name=${vals[0]}
                echo "$id.value ${vals[1]}"
            done
        done

Please note, you have to configure plugin to run as root:

[vebc*] user root

at /etc/munin/plugin-conf.d/ somewhere.