Talk:Monitoring openvz resources using munin

From OpenVZ Virtuozzo Containers Wiki
Revision as of 12:06, 29 June 2007 by Arpad (talk | contribs) (New page: I made another version which can handle per VE graphs and labelling. This is good for me, because I can present this graphs to my subscribers. <pre> #!/bin/sh # # plugin to monitor OpenVZ...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

I made another version which can handle per VE graphs and labelling. This is good for me, because I can present this graphs to my subscribers.

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

VEID=$(basename $0 | sed -e 's/^vz_//g' -e 's/_.*$//g')
NAME="$VEID: "$(basename $0 | sed -e 's/^vz_[0-9]\+_//' -e 's/_.*//' -e 's/-/ /g')
ATTRS=$(basename $0 | sed -e 's/^vz_[0-9]\+_[^_]\+_//g' -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/$VEID/resources ]
        then
            cat /proc/bc/$VEID/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 $NAME"
        echo 'graph_category OpenVZ'
        echo "graph_info '$NAME'"


        grep -E $ATTRS /proc/bc/$VEID/resources |
        while read str
        do
                vals=($str)
                name=${vals[0]}
                echo ${name}.label $name
                echo "${name}.warning  ${vals[3]}"
                echo "${name}.critical  ${vals[4]}"
        done

        exit 0
fi


grep -E "$ATTRS" /proc/bc/$VEID/resources | while read str
do
        vals=($str)
        name=${vals[0]}
        echo "${name}.value ${vals[1]}"
done

Then I can made links to the /etc/munin/plugins in this way:

vz_1013_Filesystem-informations_numfile_numflock -> /root/munin/vz
vz_1013_Memory_privvmpages -> /root/munin/vz
vz_1013_Network-buffers_tcpsndbuf_tcprcvbuf_dgramrcvbuf_othersockbuf -> /root/munin/vz
vz_1013_Number-of-processes_numproc -> /root/munin/vz
vz_1013_Number-of-sockets_numtcpsock_numothersock -> /root/munin/vz

It's not better or worster than the original. It has just different purpose. Maybe this can be put on the front page as an option.