Compatibility SNMPv3
This commit is contained in:
parent
92d74efee2
commit
71a8d8f8db
|
@ -11,8 +11,8 @@
|
||||||
# help : ./check_snmp_win.pl -h
|
# help : ./check_snmp_win.pl -h
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use Net::SNMP;
|
|
||||||
use Getopt::Long;
|
use Getopt::Long;
|
||||||
|
require "@NAGIOS_PLUGINS@/Centreon/SNMP/Utils.pm";
|
||||||
|
|
||||||
# Nagios specific
|
# Nagios specific
|
||||||
|
|
||||||
|
@ -20,6 +20,15 @@ use lib "@NAGIOS_PLUGINS@";
|
||||||
use utils qw(%ERRORS $TIMEOUT);
|
use utils qw(%ERRORS $TIMEOUT);
|
||||||
#my $TIMEOUT = 5;
|
#my $TIMEOUT = 5;
|
||||||
#my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
|
#my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
|
||||||
|
my %OPTION = (
|
||||||
|
"host" => undef,
|
||||||
|
"snmp-community" => "public", "snmp-version" => 1, "snmp-port" => 161,
|
||||||
|
"snmp-auth-key" => undef, "snmp-auth-user" => undef, "snmp-auth-password" => undef, "snmp-auth-protocol" => "MD5",
|
||||||
|
"snmp-priv-key" => undef, "snmp-priv-password" => undef, "snmp-priv-protocol" => "DES",
|
||||||
|
"maxrepetitions" => undef,
|
||||||
|
"64-bits" => undef,
|
||||||
|
);
|
||||||
|
my $session_params;
|
||||||
|
|
||||||
# SNMP Datas for processes (MIB II)
|
# SNMP Datas for processes (MIB II)
|
||||||
my $process_table= '1.3.6.1.2.1.25.4.2.1';
|
my $process_table= '1.3.6.1.2.1.25.4.2.1';
|
||||||
|
@ -47,10 +56,6 @@ my $win_serv_uninst = '1.3.6.1.4.1.77.1.2.3.1.4';
|
||||||
my $Version='0.5';
|
my $Version='0.5';
|
||||||
my $Name='check_snmp_win';
|
my $Name='check_snmp_win';
|
||||||
|
|
||||||
my $o_host = undef; # hostname
|
|
||||||
my $o_community =undef; # community
|
|
||||||
my $o_port = 161; # port
|
|
||||||
my $o_version2 = undef; #use snmp v2c
|
|
||||||
my $o_descr = undef; # description filter
|
my $o_descr = undef; # description filter
|
||||||
my @o_descrL = undef; # Service descriprion list.
|
my @o_descrL = undef; # Service descriprion list.
|
||||||
my $o_showall = undef; # Show all services even if OK
|
my $o_showall = undef; # Show all services even if OK
|
||||||
|
@ -61,34 +66,31 @@ my $o_verb= undef; # verbose mode
|
||||||
my $o_version= undef; # print version
|
my $o_version= undef; # print version
|
||||||
my $o_noreg= undef; # Do not use Regexp for name
|
my $o_noreg= undef; # Do not use Regexp for name
|
||||||
my $o_timeout= 5; # Default 5s Timeout
|
my $o_timeout= 5; # Default 5s Timeout
|
||||||
# SNMP V3 specific
|
|
||||||
my $o_login= undef; # snmp v3 login
|
|
||||||
my $o_passwd= undef; # snmp v3 passwd
|
|
||||||
|
|
||||||
# functions
|
# functions
|
||||||
|
|
||||||
sub p_version { print "$Name version : $Version\n"; }
|
sub p_version { print "$Name version : $Version\n"; }
|
||||||
|
|
||||||
sub print_usage {
|
sub print_usage {
|
||||||
print "Usage: $Name [-v] -H <host> -C <snmp_community> [-2] | (-l login -x passwd) [-p <port>] -n <name>[,<name2] [-T=service] [-r] [-s] [-N=<n>] [-t <timeout>] [-V]\n";
|
print "Usage: $Name [-v] -H <host> -C <snmp_community> | (-l login -x passwd) [-p <port>] -n <name>[,<name2] [-T=service] [-r] [-s] [-N=<n>] [-t <timeout>] [-V]\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
sub isnotnum { # Return true if arg is not a number
|
sub isnotnum { # Return true if arg is not a number
|
||||||
my $num = shift;
|
my $num = shift;
|
||||||
if ( $num =~ /^-?(\d+\.?\d*)|(^\.\d+)$/ ) { return 0 ;}
|
if ( $num =~ /^-?(\d+\.?\d*)|(^\.\d+)$/ ) { return 0 ;}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub is_pattern_valid { # Test for things like "<I\s*[^>" or "+5-i"
|
sub is_pattern_valid { # Test for things like "<I\s*[^>" or "+5-i"
|
||||||
my $pat = shift;
|
my $pat = shift;
|
||||||
if (!defined($pat)) { $pat=" ";} # Just to get rid of compilation time warnings
|
if (!defined($pat)) { $pat=" ";} # Just to get rid of compilation time warnings
|
||||||
return eval { "" =~ /$pat/; 1 } || 0;
|
return eval { "" =~ /$pat/; 1 } || 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get the alarm signal (just in case snmp timout screws up)
|
# Get the alarm signal (just in case snmp timout screws up)
|
||||||
$SIG{'ALRM'} = sub {
|
$SIG{'ALRM'} = sub {
|
||||||
print ("ERROR: Alarm signal (Nagios time-out)\n");
|
print ("ERROR: Alarm signal (Nagios time-out)\n");
|
||||||
exit $ERRORS{"UNKNOWN"};
|
exit $ERRORS{"UNKNOWN"};
|
||||||
};
|
};
|
||||||
|
|
||||||
sub help {
|
sub help {
|
||||||
|
@ -104,8 +106,6 @@ sub help {
|
||||||
name or IP address of host to check
|
name or IP address of host to check
|
||||||
-C, --community=COMMUNITY NAME
|
-C, --community=COMMUNITY NAME
|
||||||
community name for the host's SNMP agent (implies SNMP v1 or v2c with option)
|
community name for the host's SNMP agent (implies SNMP v1 or v2c with option)
|
||||||
-2, --v2c
|
|
||||||
Use snmp v2c
|
|
||||||
-l, --login=LOGIN
|
-l, --login=LOGIN
|
||||||
Login for snmpv3 authentication (implies v3 protocol with MD5)
|
Login for snmpv3 authentication (implies v3 protocol with MD5)
|
||||||
-x, --passwd=PASSWD
|
-x, --passwd=PASSWD
|
||||||
|
@ -142,49 +142,56 @@ EOT
|
||||||
sub verb { my $t=shift; print $t,"\n" if defined($o_verb) ; }
|
sub verb { my $t=shift; print $t,"\n" if defined($o_verb) ; }
|
||||||
|
|
||||||
sub decode_utf8 { # just replaces UFT8 caracters by "."
|
sub decode_utf8 { # just replaces UFT8 caracters by "."
|
||||||
my $utfstr=shift;
|
my $utfstr=shift;
|
||||||
if (substr($utfstr,0,2) ne "0x") { return $utfstr; }
|
if (substr($utfstr,0,2) ne "0x") { return $utfstr; }
|
||||||
my @stringL=split(//,$utfstr);
|
my @stringL=split(//,$utfstr);
|
||||||
my $newstring="";
|
my $newstring="";
|
||||||
for (my $i=2;$i<$#stringL;$i+=2) {
|
for (my $i=2;$i<$#stringL;$i+=2) {
|
||||||
if ( ($stringL[$i] . $stringL[$i+1]) eq "c3") {
|
if ( ($stringL[$i] . $stringL[$i+1]) eq "c3") {
|
||||||
$i+=2;$newstring .= ".";
|
$i+=2;$newstring .= ".";
|
||||||
} else {
|
} else {
|
||||||
$newstring .= chr(hex($stringL[$i] . $stringL[$i+1]));
|
$newstring .= chr(hex($stringL[$i] . $stringL[$i+1]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $newstring;
|
return $newstring;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub check_options {
|
sub check_options {
|
||||||
Getopt::Long::Configure ("bundling");
|
Getopt::Long::Configure ("bundling");
|
||||||
GetOptions(
|
GetOptions(
|
||||||
'v' => \$o_verb, 'verbose' => \$o_verb,
|
"H|hostname|host=s" => \$OPTION{'host'},
|
||||||
|
"C|community=s" => \$OPTION{'snmp-community'},
|
||||||
|
"snmp|snmp-version=s" => \$OPTION{'snmp-version'},
|
||||||
|
"p|port|P|snmpport|snmp-port=i" => \$OPTION{'snmp-port'},
|
||||||
|
"l|login|username=s" => \$OPTION{'snmp-auth-user'},
|
||||||
|
"x|passwd|authpassword|password=s" => \$OPTION{'snmp-auth-password'},
|
||||||
|
"k|authkey=s" => \$OPTION{'snmp-auth-key'},
|
||||||
|
"authprotocol=s" => \$OPTION{'snmp-auth-protocol'},
|
||||||
|
"privpassword=s" => \$OPTION{'snmp-priv-password'},
|
||||||
|
"privkey=s" => \$OPTION{'snmp-priv-key'},
|
||||||
|
"privprotocol=s" => \$OPTION{'snmp-priv-protocol'},
|
||||||
|
"maxrepetitions=s" => \$OPTION{'maxrepetitions'},
|
||||||
|
"64-bits" => \$OPTION{'64-bits'},
|
||||||
|
'v' => \$o_verb, 'verbose' => \$o_verb,
|
||||||
'h' => \$o_help, 'help' => \$o_help,
|
'h' => \$o_help, 'help' => \$o_help,
|
||||||
'H:s' => \$o_host, 'hostname:s' => \$o_host,
|
't:i' => \$o_timeout, 'timeout:i' => \$o_timeout,
|
||||||
'p:i' => \$o_port, 'port:i' => \$o_port,
|
|
||||||
'C:s' => \$o_community, 'community:s' => \$o_community,
|
|
||||||
'l:s' => \$o_login, 'login:s' => \$o_login,
|
|
||||||
'x:s' => \$o_passwd, 'passwd:s' => \$o_passwd,
|
|
||||||
't:i' => \$o_timeout, 'timeout:i' => \$o_timeout,
|
|
||||||
'n:s' => \$o_descr, 'name:s' => \$o_descr,
|
'n:s' => \$o_descr, 'name:s' => \$o_descr,
|
||||||
'r' => \$o_noreg, 'noregexp' => \$o_noreg,
|
'r' => \$o_noreg, 'noregexp' => \$o_noreg,
|
||||||
'T:s' => \$o_type, 'type:s' => \$o_type,
|
'T:s' => \$o_type, 'type:s' => \$o_type,
|
||||||
'N:i' => \$o_number, 'number:i' => \$o_number,
|
'N:i' => \$o_number, 'number:i' => \$o_number,
|
||||||
'2' => \$o_version2, 'v2c' => \$o_version2,
|
's' => \$o_showall, 'showall' => \$o_showall,
|
||||||
's' => \$o_showall, 'showall' => \$o_showall,
|
'V' => \$o_version, 'version' => \$o_version
|
||||||
'V' => \$o_version, 'version' => \$o_version
|
|
||||||
);
|
);
|
||||||
if (defined ($o_help)) { help(); exit $ERRORS{"UNKNOWN"}};
|
if (defined ($o_help)) { help(); exit $ERRORS{"UNKNOWN"}};
|
||||||
if (defined($o_version)) { p_version(); exit $ERRORS{"UNKNOWN"}};
|
if (defined($o_version)) { p_version(); exit $ERRORS{"UNKNOWN"}};
|
||||||
# check snmp information
|
# check snmp information
|
||||||
if ( !defined($o_community) && (!defined($o_login) || !defined($o_passwd)) )
|
($session_params) = Centreon::SNMP::Utils::check_snmp_options($ERRORS{'UNKNOWN'}, \%OPTION);
|
||||||
{ print "Put snmp login info!\n"; print_usage(); exit $ERRORS{"UNKNOWN"}}
|
|
||||||
# Check compulsory attributes
|
# Check compulsory attributes
|
||||||
if ( $o_type ne "service" ) {
|
if ( $o_type ne "service" ) {
|
||||||
print "Invalid check type !\n"; print_usage(); exit $ERRORS{"UNKNOWN"}
|
print "Invalid check type !\n"; print_usage(); exit $ERRORS{"UNKNOWN"}
|
||||||
}
|
}
|
||||||
if ( ! defined($o_descr) || ! defined($o_host) ) { print_usage(); exit $ERRORS{"UNKNOWN"}};
|
if ( ! defined($o_descr) ) { print_usage(); exit $ERRORS{"UNKNOWN"}};
|
||||||
@o_descrL=split(/,/,$o_descr);
|
@o_descrL=split(/,/,$o_descr);
|
||||||
foreach my $List (@o_descrL) {
|
foreach my $List (@o_descrL) {
|
||||||
if ( ! is_pattern_valid ($List) ) { print "Invalid pattern ! ";print_usage(); exit $ERRORS{"UNKNOWN"} }
|
if ( ! is_pattern_valid ($List) ) { print "Invalid pattern ! ";print_usage(); exit $ERRORS{"UNKNOWN"} }
|
||||||
|
@ -202,69 +209,18 @@ check_options();
|
||||||
|
|
||||||
# Check gobal timeout if snmp screws up
|
# Check gobal timeout if snmp screws up
|
||||||
if (defined($TIMEOUT)) {
|
if (defined($TIMEOUT)) {
|
||||||
verb("Alarm at $TIMEOUT");
|
verb("Alarm at $TIMEOUT");
|
||||||
alarm($TIMEOUT);
|
alarm($TIMEOUT);
|
||||||
} else {
|
} else {
|
||||||
verb("no timeout defined : $o_timeout + 10");
|
verb("no timeout defined : $o_timeout + 10");
|
||||||
alarm ($o_timeout+10);
|
alarm ($o_timeout+10);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Connect to host
|
# Connect to host
|
||||||
my ($session,$error);
|
my $session = Centreon::SNMP::Utils::connection($ERRORS{'UNKNOWN'}, $session_params);
|
||||||
if ( defined($o_login) && defined($o_passwd)) {
|
|
||||||
# SNMPv3 login
|
|
||||||
verb("SNMPv3 login");
|
|
||||||
($session, $error) = Net::SNMP->session(
|
|
||||||
-hostname => $o_host,
|
|
||||||
-version => '3',
|
|
||||||
-username => $o_login,
|
|
||||||
-authpassword => $o_passwd,
|
|
||||||
-authprotocol => 'md5',
|
|
||||||
-privpassword => $o_passwd,
|
|
||||||
-timeout => $o_timeout
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
if (defined ($o_version2)) {
|
|
||||||
# SNMPv2 Login
|
|
||||||
($session, $error) = Net::SNMP->session(
|
|
||||||
-hostname => $o_host,
|
|
||||||
-version => 2,
|
|
||||||
-community => $o_community,
|
|
||||||
-port => $o_port,
|
|
||||||
-timeout => $o_timeout
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
# SNMPV1 login
|
|
||||||
($session, $error) = Net::SNMP->session(
|
|
||||||
-hostname => $o_host,
|
|
||||||
-community => $o_community,
|
|
||||||
-port => $o_port,
|
|
||||||
-timeout => $o_timeout
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$session->max_msg_size(10000);
|
|
||||||
verb($session->max_msg_size);
|
|
||||||
#print $session->max_msg_size(),"\n";
|
|
||||||
|
|
||||||
if (!defined($session)) {
|
|
||||||
printf("ERROR: %s.\n", $error);
|
|
||||||
exit $ERRORS{"UNKNOWN"};
|
|
||||||
}
|
|
||||||
|
|
||||||
# Look for process in name or path name table
|
# Look for process in name or path name table
|
||||||
my $resultat=undef;
|
my $resultat = Centreon::SNMP::Utils::get_snmp_table($win_serv_name, $session, $ERRORS{'UNKNOWN'}, \%OPTION);
|
||||||
|
|
||||||
$resultat = (Net::SNMP->VERSION < 4) ?
|
|
||||||
$session->get_table($win_serv_name)
|
|
||||||
: $session->get_table(Baseoid => $win_serv_name);
|
|
||||||
|
|
||||||
if (!defined($resultat)) {
|
|
||||||
printf("ERROR: Process name table : %s.\n", $session->error);
|
|
||||||
$session->close;
|
|
||||||
exit $ERRORS{"UNKNOWN"};
|
|
||||||
}
|
|
||||||
|
|
||||||
my @tindex = undef;
|
my @tindex = undef;
|
||||||
my @oids = undef;
|
my @oids = undef;
|
||||||
|
@ -277,64 +233,54 @@ my $count_oid = 0;
|
||||||
verb("Filter : $o_descr");
|
verb("Filter : $o_descr");
|
||||||
|
|
||||||
foreach my $key ( keys %$resultat) {
|
foreach my $key ( keys %$resultat) {
|
||||||
my $descr_d=decode_utf8($$resultat{$key});
|
my $descr_d=decode_utf8($$resultat{$key});
|
||||||
verb("Desc : $descr_d");
|
verb("Desc : $descr_d");
|
||||||
# test by regexp or exact match
|
# test by regexp or exact match
|
||||||
my $test=undef;
|
my $test=undef;
|
||||||
foreach my $List (@o_descrL) {
|
foreach my $List (@o_descrL) {
|
||||||
if (!($test)) {
|
if (!($test)) {
|
||||||
$test = defined($o_noreg)
|
$test = defined($o_noreg)
|
||||||
? $descr_d eq $List
|
? $descr_d eq $List
|
||||||
: $descr_d =~ /$List/i;
|
: $descr_d =~ /$List/i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($test) {
|
if ($test) {
|
||||||
# get the full description
|
# get the full description
|
||||||
$descr[$num_int]=$descr_d;
|
$descr[$num_int]=$descr_d;
|
||||||
# get the index number of the process
|
# get the index number of the process
|
||||||
$key =~ s/$win_serv_name\.//;
|
$key =~ s/$win_serv_name\.//;
|
||||||
$tindex[$num_int] = $key;
|
$tindex[$num_int] = $key;
|
||||||
# put the oid of running state in an array.
|
# put the oid of running state in an array.
|
||||||
$oids[$count_oid++]=$win_serv_state . "." . $tindex[$num_int];
|
$oids[$count_oid++]=$win_serv_state . "." . $tindex[$num_int];
|
||||||
verb("Name : $descr[$num_int], Index : $tindex[$num_int]");
|
verb("Name : $descr[$num_int], Index : $tindex[$num_int]");
|
||||||
$num_int++;
|
$num_int++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $num_int == 0) {
|
if ( $num_int == 0) {
|
||||||
if (defined ($o_number) && ($o_number ==0)) {
|
if (defined ($o_number) && ($o_number ==0)) {
|
||||||
print "No services ",(defined ($o_noreg)) ? "named \"" : "matching \"", $o_descr, "\" found : OK\n";
|
print "No services ",(defined ($o_noreg)) ? "named \"" : "matching \"", $o_descr, "\" found : OK\n";
|
||||||
exit $ERRORS{"OK"};
|
exit $ERRORS{"OK"};
|
||||||
} else {
|
} else {
|
||||||
print "No services ",(defined ($o_noreg)) ? "named \"" : "matching \"", $o_descr, "\" found : CRITICAL\n";
|
print "No services ",(defined ($o_noreg)) ? "named \"" : "matching \"", $o_descr, "\" found : CRITICAL\n";
|
||||||
exit $ERRORS{"CRITICAL"};
|
exit $ERRORS{"CRITICAL"};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
my $result=undef;
|
my $result = Centreon::SNMP::Utils::get_snmp_leef(\@oids, $session, $ERRORS{'UNKNOWN'});
|
||||||
my $num_int_ok=0;
|
my $num_int_ok=0;
|
||||||
|
|
||||||
$result = (Net::SNMP->VERSION < 4) ?
|
|
||||||
$session->get_request(@oids)
|
|
||||||
: $session->get_request(Varbindlist => \@oids);
|
|
||||||
|
|
||||||
if (!defined($result)) { printf("ERROR: running table : %s.\n", $session->error); $session->close;
|
|
||||||
exit $ERRORS{"UNKNOWN"};
|
|
||||||
}
|
|
||||||
|
|
||||||
$session->close;
|
|
||||||
|
|
||||||
my $output=undef;
|
my $output=undef;
|
||||||
#Check if service are in active state
|
#Check if service are in active state
|
||||||
for (my $i=0; $i< $num_int; $i++) {
|
for (my $i=0; $i< $num_int; $i++) {
|
||||||
my $state=$$result{$win_serv_state . "." . $tindex[$i]};
|
my $state=$$result{$win_serv_state . "." . $tindex[$i]};
|
||||||
verb ("Process $tindex[$i] in state $state");
|
verb ("Process $tindex[$i] in state $state");
|
||||||
if ($state == 1) {
|
if ($state == 1) {
|
||||||
$num_int_ok++
|
$num_int_ok++
|
||||||
} else {
|
} else {
|
||||||
$output .= ", " if defined($output);
|
$output .= ", " if defined($output);
|
||||||
$output .= $descr[$i] . " : " . $win_serv_state_label{$state};
|
$output .= $descr[$i] . " : " . $win_serv_state_label{$state};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
my $force_critical=0;
|
my $force_critical=0;
|
||||||
|
@ -342,41 +288,39 @@ my $force_critical=0;
|
||||||
# Show the services that are not present
|
# Show the services that are not present
|
||||||
# Or all of them with -s option
|
# Or all of them with -s option
|
||||||
foreach my $List (@o_descrL) {
|
foreach my $List (@o_descrL) {
|
||||||
my $test=0;
|
my $test=0;
|
||||||
for (my $i=0; $i< $num_int; $i++) {
|
for (my $i=0; $i< $num_int; $i++) {
|
||||||
if ( !defined($o_noreg) && ($descr[$i] =~ /$List/i) ) { $test++; }
|
if ( !defined($o_noreg) && ($descr[$i] =~ /$List/i) ) { $test++; }
|
||||||
if ( defined($o_noreg) && ($descr[$i] eq $List) ) { $test++; }
|
if ( defined($o_noreg) && ($descr[$i] eq $List) ) { $test++; }
|
||||||
}
|
}
|
||||||
if ($test==0) {
|
if ($test==0) {
|
||||||
$output .= ", " if defined($output);
|
$output .= ", " if defined($output);
|
||||||
$output .= "\"" . $List . "\" not active";
|
$output .= "\"" . $List . "\" not active";
|
||||||
# Force a critical state (could otherwise lead to false OK)
|
# Force a critical state (could otherwise lead to false OK)
|
||||||
$force_critical=1;
|
$force_critical=1;
|
||||||
} elsif ( defined ($o_showall) ) {
|
} elsif ( defined ($o_showall) ) {
|
||||||
$output .= ", " if defined($output);
|
$output .= ", " if defined($output);
|
||||||
$output .= "\"" . $List . "\" active";
|
$output .= "\"" . $List . "\" active";
|
||||||
if ($test != 1) {
|
if ($test != 1) {
|
||||||
$output .= "(" .$test . " services)";
|
$output .= "(" .$test . " services)";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined ($output) ) {
|
if (defined ($output) ) {
|
||||||
print $output, " : ";
|
print $output, " : ";
|
||||||
} else {
|
} else {
|
||||||
print $num_int_ok, " services active (", (defined ($o_noreg)) ? "named \"" : "matching \"", $o_descr, "\") : ";
|
print $num_int_ok, " services active (", (defined ($o_noreg)) ? "named \"" : "matching \"", $o_descr, "\") : ";
|
||||||
}
|
}
|
||||||
|
|
||||||
$o_number = $#o_descrL+1 if (!defined($o_number));
|
$o_number = $#o_descrL+1 if (!defined($o_number));
|
||||||
|
|
||||||
if (($num_int_ok < $o_number)||($force_critical == 1)) {
|
if (($num_int_ok < $o_number)||($force_critical == 1)) {
|
||||||
print "CRITICAL\n";
|
print "CRITICAL\n";
|
||||||
exit $ERRORS{"CRITICAL"};
|
exit $ERRORS{"CRITICAL"};
|
||||||
} elsif ($num_int_ok > $o_number) {
|
} elsif ($num_int_ok > $o_number) {
|
||||||
print "WARNING\n";
|
print "WARNING\n";
|
||||||
exit $ERRORS{"WARNING"};
|
exit $ERRORS{"WARNING"};
|
||||||
}
|
}
|
||||||
print "OK\n";
|
print "OK\n";
|
||||||
exit $ERRORS{"OK"};
|
exit $ERRORS{"OK"};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue