Open main menu

OpenVZ Virtuozzo Containers Wiki β

Changes

Monitoring openvz resources using nagios and snmp

624 bytes added, 07:51, 7 April 2009
check_vzquota Without SNMP: ! script changed ! , state UNKNOWN and CRITICAL added
#!/bin/bash
RET=0
DATA=`echo;sudo /usr/sbin/vzlist -1 | xargs -I {} bash -c "echo {}:;sudo /usr/sbin/vzquota stat {}| sed 's/\*//g'"`if [ -z "$DATA" ]; then echo "UNKNOWN - VZquota stats are not readable or empty. Maybe it is only readable for root and this script should be called by sudo."; exit 3;fi 
echo "$DATA" | perl -n -e'
my $vid ;
my $ret=0 ;
my $crit="";
my $warn="";
my $ok="";
while(<STDIN>){
my %vid;
$softlimit=$3 ;
$hardlimit=$4 ;
if ( $usage >= $hardlimit ){ $crit=$crit."VZquota limit exceeded on $vid: $resource usage->$usage, softlimit->$softlimit, hardlimit->$hardlimit, time->$time, expire->$expire " ; $ret=2; } elsif ( $usage >= $softlimit ){ print $warn=$warn."WARNING: VZquota limit exceeded on $vid: $resource usage->$usage, softlimit->$softlimit, hardlimit->$hardlimit, time->$time, expire->$expire " ;
$ret=1;
}
print $ok=$ok."$vid:$resource $usage/$softlimit ";
}
}
if ($ret == 0) {
print "OK - $ok";
} elsif ($ret == 1) {
print "WARNING - $warn";
} else {
print "CRITICAL - $crit";
}
exit($ret);
echo
exit $RET
 
</source>
The script calls <code>/usr/sbin/vzlist</code> by sudo. When doing this it normally needs a password, which check_nrpe will not know. Because of this it is necessary that you append a line like the following to <code>/etc/sudors</code> (user name an path should be adapted to the right ones on your system):
15
edits