Difference between revisions of "Monitoring openvz resources using munin"

From OpenVZ Virtuozzo Containers Wiki
Jump to: navigation, search
m (categorized)
m (munin plugin: use source tags)
Line 1: Line 1:
 
[[Category: Monitoring]]
 
[[Category: Monitoring]]
 +
 +
{{wikify}}
  
 
== munin plugin ==
 
== munin plugin ==
Line 5: Line 7:
 
The plugin listed below grabs all the beancounters' values.
 
The plugin listed below grabs all the beancounters' values.
  
<pre>#!/bin/sh
+
<source lang="bash">
 +
#!/bin/sh
 
#
 
#
 
# plugin to monitor OpenVZ bean counters.
 
# plugin to monitor OpenVZ bean counters.
Line 78: Line 81:
 
         done
 
         done
  
</pre>
+
</source>
  
 
Please note, you have to configure plugin to run as root:
 
Please note, you have to configure plugin to run as root:
Line 99: Line 102:
 
e.g.: vebc_numflock_numpty_numsiginfo_101
 
e.g.: vebc_numflock_numpty_numsiginfo_101
  
<pre>
+
<source lang="bash">
 
#!/bin/sh
 
#!/bin/sh
 
#
 
#
Line 238: Line 241:
 
done
 
done
  
</pre>
+
</source>
  
 
This is not too performant but should do and the graphs are much
 
This is not too performant but should do and the graphs are much
 
more readable then the first solution.
 
more readable then the first solution.

Revision as of 08:27, 25 December 2007


Yellowpin.svg Note: this article is not formatted according to this Wiki standards. Please help reformatting it in a better way.

munin plugin

The plugin listed below grabs all the beancounters' 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.


Extended Version for old system using user_beancounter.

Put it with the munin plugins and make a link for every graph which should be produced named like:

vebc_VALUENAME1_VALUENAME2_..._VEID

e.g.: vebc_numflock_numpty_numsiginfo_101

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

ATTR=`basename $0 | sed -e 's/^vebc_.*_//'`
STATS=`basename $0 | sed -e 's/^vebc_//' -e 's/_[0-9]*$//' -e 's/_/ /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 beancounter for VE$ATTR: $STATS"
        echo "graph_category VE$ATTR"
        echo "graph_info 'VE bean counters info'"

        readme="false"
        cat /proc/user_beancounters | while read myid stuff; do

                line=""

                if [ "$myid" == "$ATTR:" ]; then

                        readme="true"
                        line="$stuff"
                        echo $line
                else

                        loid=`echo $myid | sed -e 's/.*:/:/'`

                        if [ "$loid" == ":" ]; then

                                readme="false"
                        fi
                        if [ "$readme" == "true" ]; then

                                line="$myid $stuff"
                        echo $line
                        fi
                fi

        done | while read name value top warn max; do

                okname="dummy"

                for statname in $STATS; do

                        if [ "$name" == "$statname" ]; then

                                okname=$name
                        fi

                done

                if [ "$okname" != "dummy" ]; then

                        echo $okname.label $name
                        echo $okname.warning $warn
                        echo $okname.critical $max
                fi
        done

        exit 0
fi;


readme="false"
cat /proc/user_beancounters | while read myid stuff; do

        line=""

        if [ "$myid" == "$ATTR:" ]; then

                readme="true"
                line="$stuff"
                echo $line
        else

                loid=`echo $myid | sed -e 's/.*:/:/'`

                if [ "$loid" == ":" ]; then

                        readme="false"
                fi

                if [ "$readme" == "true" ]; then

                        line="$myid $stuff"
                echo $line
                fi
        fi
done | while read name value x; do

        okname="dummy"

        for statname in $STATS; do

                if [ "$name" == "$statname" ]; then

                        okname=$name
                fi
        done

        if [ "$okname" != "dummy" ]; then

                echo $okname.value $value
        fi

done

This is not too performant but should do and the graphs are much more readable then the first solution.