15
edits
Changes
→check_ubc Without SNMP: Resourcename can now be a link to OpenVZ-Wiki for more information in case of troubles
<source lang="bash">
#!/bin/bash
# Servicestate description can have a http-link to the openvz-wiki
# in case that a ressource is warning/critical. To use it:
# 1. set "escape_html_tags=0" in nagios/etc/cgi.cfg
# 2. set "my $linked=1;" in the first perl lines in this script
#
export FILE=/tmp/check_ubc
RET=0
ubc_file='/proc/user_beancounters';
DATA='';
fi
if [ -z "$DATA" ]; then
echo "UNKNOWN- $ubc_file is 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'
use Data::Dumper;
my $linked=1; # 0:plain text output, 1:resourcename is a http-link to OpenVZ-wiki
my $file=$ENV{"FILE"};
my $ret=0 ;
${beancounters{$vid}}{$resource}=[$held , $maxheld , $barrier , $limit ,$failcnt ];
if ( ($held > $barrier) && ($barrier != 0) ) {
print "WARNING: Limits on $vid: ".&url($resource ,$linked)." held->$held , barrier->$barrier ( limit->$limit ) " ;
$ret=1;
}
my $limit=$beancounters{$vmachine_id}{$resource}[3];
if ( $failcnt_old < $failcnt ){
print "CRITICAL: Incrased failcnt $vmachine_id: ".url($resource ,$linked)." from $failcnt_old to $failcnt (held->$held , maxheld->$maxheld , barrier->$barrier , limit->$limit ) " ;
$ret=2;
}
}
sub url { my ($name,$with_link) = @_; if ($with_link) { return "<a target=\"_blank\" href=\"http://wiki.openvz.org/".$name."#".$name."\">$name</a>"; } else { return $name; }}
if ($ret == 0 ) { print "OK. \n" ; }
# print Dumper(%beancounters_old) ;