Changes

Jump to: navigation, search

Monitoring openvz resources using rrdtool

2,384 bytes added, 15:01, 8 July 2008
no edit summary
mkdir /var/rrd
In /etc/xinetd.d create a file rrdsrvand adjust addresses and paths according to local settings.
service rrdsrv
=== Collect script ===
 
Put the following script on the openvz hardware nodes:
 
#!/bin/sh
PATH="/bin:/sbin:/usr/bin:/usr/sbin"
SENDCOMMAND='netcat 192.168.2.1 13900'
HEARTBEAT=600
function error {
echo $1
exit 1
}
test -r /proc/bc/0/resources || error "Not openvz kernel?"
command='cat'
init=0
update=0
send=0
while [ ! -z "$1" ]; do
case "$1" in
send)
send=1
command=$SENDCOMMAND
;;
init)
init=1
;;
update)
update=1
;;
esac
shift
done
VPSIDS=$(vzlist | awk ' BEGIN { ORS=" "; getline } { print $1 }')
PARAMS=$(cat /proc/bc/0/resources | awk '{ print $1 }'| sort -u | xargs)
if [ "$send" -eq 1 ]; then
# to spread the load we sleep for a random while (between 0 and 60 sec)
number=$RANDOM
let "number %= 60"
sleep $number
fi
for VPSID in $VPSIDS; do
RRDFILENAME="ubc_${VPSID}.rrd"
if [ "$init" -eq 1 ]; then
exists=0
if [ "$send" -eq 1 ]; then
echo "info $RRDFILENAME" | $command | grep -q "No such file or directory" || exists=1
fi
if [ "$exists" -eq 0 ]; then
(
echo -n "create ${RRDFILENAME} "
for param in $PARAMS; do
echo -n "DS:${param}_f:DERIVE:$HEARTBEAT:0:U "
echo -n "DS:${param}_h:GAUGE:$HEARTBEAT:0:U "
echo -n "DS:${param}_b:GAUGE:$HEARTBEAT:0:U "
done
echo -n "RRA:AVERAGE:0.5:1:600 "
echo -n "RRA:AVERAGE:0.5:6:700 "
echo -n "RRA:AVERAGE:0.5:24:775 "
echo -n "RRA:AVERAGE:0.5:288:797 "
echo -n "RRA:MAX:0.5:1:600 "
echo -n "RRA:MAX:0.5:6:700 "
echo -n "RRA:MAX:0.5:24:775 "
echo "RRA:MAX:0.5:288:797"
) | $command
fi
fi
10
edits

Navigation menu