Random Project

servicecount warning/critical

Hi, thanks for this pluging, as was searching for a pluging as I’m using one Nagios server to monitor other Nagios Servers.

I just changed the subroutine check_s_count() to show warning if any service is warning, same idea to critical services.

sub check_s_count(){
my $line;
my $counter_service_checks=0;
my $counter_warning=0;
my $counter_critical=0;

open (FILE, $file)
or die $!;
$/ = “”;

foreach $line(){
if($line=~/servicestatus/){
$counter_service_checks++;
}

if($line=~/plugin_output/){
if($line=~/WARNING/){
$counter_warning++;
}
}
if($line=~/plugin_output/){
if($line=~/CRITICAL/){
$counter_critical++;
}
}
}

close (FILE);

# filling vars for print
$text=(“Service Checks: $counter_service_checks – Service Warning: $counter_warning – Service Critial: $counter_critical”);
$perfdat=(“count=$counter_service_checks”);

# this ugly thing is needed to return OK:
$warning=2;
$critical=3;

$value=1;
if($counter_warning>0){
$value=$warning;
}
if($counter_critical>0){
$value=$critical;
}

}