Editing Monitoring openvz resources using nagios and snmp
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 5: | Line 5: | ||
</pre> | </pre> | ||
− | edit '''/etc/default/snmpd''' : remove ''-u snmp'' and replace ''127.0.0.1'' with your ip | + | edit '''/etc/default/snmpd''' : remove ''-u snmp'' and replace ''127.0.0.1'' with your ip, Full'''/etc/default/snmpd''' example: |
<pre> | <pre> | ||
export MIBDIRS=/usr/share/snmp/mibs | export MIBDIRS=/usr/share/snmp/mibs | ||
Line 26: | Line 26: | ||
<pre> | <pre> | ||
/etc/init.d/snmpd stop | /etc/init.d/snmpd stop | ||
− | echo rouser my_username priv | + | echo rouser my_username priv > /etc/snmp/snmpd.conf |
echo "extend .1.3.6.1.4.1.2021.51 beancounters /bin/cat /proc/user_beancounters" >> /etc/snmp/snmpd.conf | echo "extend .1.3.6.1.4.1.2021.51 beancounters /bin/cat /proc/user_beancounters" >> /etc/snmp/snmpd.conf | ||
echo "extend .1.3.6.1.4.1.2021.52 vzquota /bin/cat /proc/vz/vzquota" >> /etc/snmp/snmpd.conf | echo "extend .1.3.6.1.4.1.2021.52 vzquota /bin/cat /proc/vz/vzquota" >> /etc/snmp/snmpd.conf | ||
Line 32: | Line 32: | ||
/etc/init.d/snmpd start | /etc/init.d/snmpd start | ||
</pre> | </pre> | ||
− | |||
− | |||
Testing snmp: | Testing snmp: | ||
<pre> | <pre> | ||
− | snmpwalk -v 3 -u | + | snmpwalk -v 3 -u my_usrname -l authPriv -a MD5 -A my_password -x DES -X my_password 207.46.250.119 |
</pre> | </pre> | ||
Line 210: | Line 208: | ||
##################################################################################### | ##################################################################################### | ||
− | if [ $RET1 -gt $RET2 ]; then | + | if [ $RET1 -gt $RET2 ]; then |
RET=$RET1 | RET=$RET1 | ||
else | else | ||
Line 221: | Line 219: | ||
exit $RET | exit $RET | ||
</source> | </source> | ||
− | |||
=== check_vzquota Without SNMP === | === check_vzquota Without SNMP === | ||
<source lang="bash"> | <source lang="bash"> | ||
#!/bin/bash | #!/bin/bash | ||
RET=0 | RET=0 | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | echo | + | echo `cat /proc/vz/vzquota` | perl -n -e' |
my $vid ; | my $vid ; | ||
my $ret=0 ; | my $ret=0 ; | ||
− | |||
− | |||
− | |||
while(<STDIN>){ | while(<STDIN>){ | ||
my %vid; | my %vid; | ||
− | |||
if ( /\D*(\d+):.*/ ){ $vid=$1; } | if ( /\D*(\d+):.*/ ){ $vid=$1; } | ||
− | if ( /\s*(\S+)\s+(\d+)\s+(\d+)\s+(\d+).*/ ){ | + | if ( /\s*(\S+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+).*/ ){ |
$resource=$1 ; | $resource=$1 ; | ||
$usage=$2 ; | $usage=$2 ; | ||
$softlimit=$3 ; | $softlimit=$3 ; | ||
$hardlimit=$4 ; | $hardlimit=$4 ; | ||
− | + | $time=$5 ; | |
− | + | $expire=$6 ; | |
− | + | if ( $usage >= $softlimit ){ | |
− | + | print "WARNING: VZquota limit exceeded on $vid: $resource usage->$usage, softlimit->$softlimit, hardlimit->$hardlimit, time->$time, expire->$expire " ; | |
− | |||
$ret=1; | $ret=1; | ||
} | } | ||
− | + | print "$vid:$resource Usage: $usage Softlimit: $softlimit "; | |
} | } | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
} | } | ||
exit($ret); | exit($ret); | ||
' | ' | ||
RET=$? | RET=$? | ||
+ | echo | ||
exit $RET | exit $RET | ||
</source> | </source> | ||
− | |||
− | |||
− | |||
=== check_ubc Without SNMP === | === check_ubc Without SNMP === | ||
<source lang="bash"> | <source lang="bash"> | ||
#!/bin/bash | #!/bin/bash | ||
− | |||
− | |||
− | |||
− | |||
− | |||
export FILE=/tmp/check_ubc | export FILE=/tmp/check_ubc | ||
RET=0 | RET=0 | ||
− | + | ||
− | + | DATA=`cat /proc/user_beancounters` | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
if [ -f $FILE ]; then | if [ -f $FILE ]; then | ||
echo "$DATA" | perl -n -e' | echo "$DATA" | perl -n -e' | ||
use Data::Dumper; | use Data::Dumper; | ||
− | |||
my $file=$ENV{"FILE"}; | my $file=$ENV{"FILE"}; | ||
my $ret=0 ; | my $ret=0 ; | ||
Line 329: | Line 284: | ||
${beancounters{$vid}}{$resource}=[$held , $maxheld , $barrier , $limit ,$failcnt ]; | ${beancounters{$vid}}{$resource}=[$held , $maxheld , $barrier , $limit ,$failcnt ]; | ||
if ( ($held > $barrier) && ($barrier != 0) ) { | if ( ($held > $barrier) && ($barrier != 0) ) { | ||
− | print "WARNING: Limits on $vid: | + | print "WARNING: Limits on $vid: $resource held->$held , barrier->$barrier ( limit->$limit ) " ; |
$ret=1; | $ret=1; | ||
} | } | ||
Line 362: | Line 317: | ||
my $limit=$beancounters{$vmachine_id}{$resource}[3]; | my $limit=$beancounters{$vmachine_id}{$resource}[3]; | ||
if ( $failcnt_old < $failcnt ){ | if ( $failcnt_old < $failcnt ){ | ||
− | print "CRITICAL: | + | print "CRITICAL: Incrased failcnt $vmachine_id: $resource from $failcnt_old to $failcnt (held->$held , maxheld->$maxheld , barrier->$barrier , limit->$limit ) " ; |
$ret=2; | $ret=2; | ||
} | } | ||
Line 370: | Line 325: | ||
} | } | ||
− | + | ||
− | + | if ($ret == 0 ) { print "OK. \n" ; } | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | if ($ret == 0 ) { print "OK | ||
# print Dumper(%beancounters_old) ; | # print Dumper(%beancounters_old) ; | ||
# print "\n"; | # print "\n"; | ||
Line 390: | Line 338: | ||
exit $RET | exit $RET | ||
</source> | </source> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |