Imported Upstream version 2.0
This commit is contained in:
		
							parent
							
								
									c89ccc3c74
								
							
						
					
					
						commit
						0841b5c7c7
					
				
					 165 changed files with 25440 additions and 4442 deletions
				
			
		| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
# Country Name (2 letter code) [AU]:UK
 | 
			
		||||
# State or Province Name (full name) [Some-State]:Derbyshire
 | 
			
		||||
# Locality Name (eg, city) []:Belper
 | 
			
		||||
# Organization Name (eg, company) [Internet Widgits Pty Ltd]:Nagios Plugins
 | 
			
		||||
# Organization Name (eg, company) [Internet Widgits Pty Ltd]:Monitoring Plugins
 | 
			
		||||
# Organizational Unit Name (eg, section) []:
 | 
			
		||||
# Common Name (eg, YOUR name) []:Ton Voon
 | 
			
		||||
# Email Address []:tonvoon@mac.com
 | 
			
		||||
| 
						 | 
				
			
			@ -20,8 +20,9 @@ use FindBin qw($Bin);
 | 
			
		|||
my $common_tests = 70;
 | 
			
		||||
my $ssl_only_tests = 8;
 | 
			
		||||
# Check that all dependent modules are available
 | 
			
		||||
eval "use HTTP::Daemon 6.01;";
 | 
			
		||||
plan skip_all => 'HTTP::Daemon >= 6.01 required' if $@;
 | 
			
		||||
eval {
 | 
			
		||||
	require HTTP::Daemon;
 | 
			
		||||
	require HTTP::Status;
 | 
			
		||||
	require HTTP::Response;
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			@ -392,27 +393,21 @@ sub run_common_tests {
 | 
			
		|||
		skip "This doesn't seems to work all the time", 1 unless ($ENV{HTTP_EXTERNAL});
 | 
			
		||||
		$cmd = "$command -f follow -u /redir_external -t 5";
 | 
			
		||||
		eval {
 | 
			
		||||
			local $SIG{ALRM} = sub { die "alarm\n" };
 | 
			
		||||
			alarm(2);
 | 
			
		||||
			$result = NPTest->testCmd( $cmd );
 | 
			
		||||
			alarm(0); };
 | 
			
		||||
		is( $@, "alarm\n", $cmd );
 | 
			
		||||
			$result = NPTest->testCmd( $cmd, 2 );
 | 
			
		||||
		};
 | 
			
		||||
		like( $@, "/timeout in command: $cmd/", $cmd );
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	$cmd = "$command -u /timeout -t 5";
 | 
			
		||||
	eval {
 | 
			
		||||
		local $SIG{ALRM} = sub { die "alarm\n" };
 | 
			
		||||
		alarm(2);
 | 
			
		||||
		$result = NPTest->testCmd( $cmd );
 | 
			
		||||
		alarm(0); };
 | 
			
		||||
	is( $@, "alarm\n", $cmd );
 | 
			
		||||
		$result = NPTest->testCmd( $cmd, 2 );
 | 
			
		||||
	};
 | 
			
		||||
	like( $@, "/timeout in command: $cmd/", $cmd );
 | 
			
		||||
 | 
			
		||||
	$cmd = "$command -f follow -u /redir_timeout -t 2";
 | 
			
		||||
	eval {
 | 
			
		||||
		local $SIG{ALRM} = sub { die "alarm\n" };
 | 
			
		||||
		alarm(5);
 | 
			
		||||
		$result = NPTest->testCmd( $cmd );
 | 
			
		||||
		alarm(0); };
 | 
			
		||||
	isnt( $@, "alarm\n", $cmd );
 | 
			
		||||
		$result = NPTest->testCmd( $cmd, 5 );
 | 
			
		||||
	};
 | 
			
		||||
	is( $@, "", $cmd );
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										85
									
								
								plugins/tests/check_procs.t
									
										
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										85
									
								
								plugins/tests/check_procs.t
									
										
									
									
									
										
										
										Normal file → Executable file
									
								
							| 
						 | 
				
			
			@ -18,59 +18,68 @@ my $command = "./check_procs --input-file=tests/var/ps-axwo.darwin";
 | 
			
		|||
 | 
			
		||||
$result = NPTest->testCmd( "$command" );
 | 
			
		||||
is( $result->return_code, 0, "Run with no options" );
 | 
			
		||||
like( $result->output, '/^PROCS OK: 95 processes$/', "Output correct" );
 | 
			
		||||
is( $result->output, "PROCS OK: 95 processes | procs=95;;;0;", "Output correct" );
 | 
			
		||||
 | 
			
		||||
$result = NPTest->testCmd( "$command -w 5" );
 | 
			
		||||
is( $result->return_code, 1, "Checking > 5 processes" );
 | 
			
		||||
like( $result->output, '/^PROCS WARNING: 95 processes$/', "Output correct" );
 | 
			
		||||
is( $result->output, "PROCS WARNING: 95 processes | procs=95;5;;0;", "Output correct" );
 | 
			
		||||
 | 
			
		||||
$result = NPTest->testCmd( "$command -w 4 -c 44" );
 | 
			
		||||
is( $result->return_code, 2, "Checking critical" );
 | 
			
		||||
like( $result->output, '/^PROCS CRITICAL: 95 processes$/', "Output correct" );
 | 
			
		||||
is( $result->output, "PROCS CRITICAL: 95 processes | procs=95;4;44;0;", "Output correct" );
 | 
			
		||||
 | 
			
		||||
$result = NPTest->testCmd( "$command -w 100 -c 200" );
 | 
			
		||||
is( $result->return_code, 0, "Checking no threshold breeched" );
 | 
			
		||||
like( $result->output, '/^PROCS OK: 95 processes$/', "Output correct" );
 | 
			
		||||
is( $result->output, "PROCS OK: 95 processes | procs=95;100;200;0;", "Output correct" );
 | 
			
		||||
 | 
			
		||||
$result = NPTest->testCmd( "$command -C launchd -c 5" );
 | 
			
		||||
is( $result->return_code, 2, "Checking processes filtered by command name" );
 | 
			
		||||
like( $result->output, '/^PROCS CRITICAL: 6 processes with command name \'launchd\'$/', "Output correct" );
 | 
			
		||||
is( $result->output, "PROCS CRITICAL: 6 processes with command name 'launchd' | procs=6;;5;0;", "Output correct" );
 | 
			
		||||
 | 
			
		||||
$result = NPTest->testCmd( "$command -u 501 -w 39 -c 41" );
 | 
			
		||||
is( $result->return_code, 1, "Checking processes filtered by userid" );
 | 
			
		||||
like( $result->output, '/^PROCS WARNING: 40 processes with UID = 501 (.*)$/', "Output correct" );
 | 
			
		||||
SKIP: {
 | 
			
		||||
    skip 'user with uid 501 required', 4 unless getpwuid(501);
 | 
			
		||||
 | 
			
		||||
$result = NPTest->testCmd( "$command -C launchd -u 501" );
 | 
			
		||||
is( $result->return_code, 0, "Checking processes filtered by command name and userid" );
 | 
			
		||||
like( $result->output, '/^PROCS OK: 1 process with command name \'launchd\', UID = 501 (.*)$/', "Output correct" );
 | 
			
		||||
    $result = NPTest->testCmd( "$command -u 501 -w 39 -c 41" );
 | 
			
		||||
    is( $result->return_code, 1, "Checking processes filtered by userid" );
 | 
			
		||||
    like( $result->output, '/^PROCS WARNING: 40 processes with UID = 501 (.*)$/', "Output correct" );
 | 
			
		||||
 | 
			
		||||
$result = NPTest->testCmd( "$command -u -2 -w 2:2" );
 | 
			
		||||
is( $result->return_code, 1, "Checking processes with userid=-2" );
 | 
			
		||||
like( $result->output, '/^PROCS WARNING: 3 processes with UID = -2 \(nobody\)$/', "Output correct" );
 | 
			
		||||
    $result = NPTest->testCmd( "$command -C launchd -u 501" );
 | 
			
		||||
    is( $result->return_code, 0, "Checking processes filtered by command name and userid" );
 | 
			
		||||
    like( $result->output, '/^PROCS OK: 1 process with command name \'launchd\', UID = 501 (.*)$/', "Output correct" );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
$result = NPTest->testCmd( "$command -u -2 -w 3:3" );
 | 
			
		||||
is( $result->return_code, 0, "Checking processes with userid=-2 past threshold" );
 | 
			
		||||
like( $result->output, '/^PROCS OK: 3 processes with UID = -2 \(nobody\)$/', "Output correct" );
 | 
			
		||||
SKIP: {
 | 
			
		||||
    skip 'user with uid -2 required', 8 unless getpwuid(-2);
 | 
			
		||||
    skip 'uid -2 must have name "nobody"', 8 unless getpwuid(-2) eq 'nobody';
 | 
			
		||||
 | 
			
		||||
$result = NPTest->testCmd( "$command -u -2 -a usb" );
 | 
			
		||||
is( $result->return_code, 0, "Checking processes with userid=-2 and usb in arguments" );
 | 
			
		||||
like( $result->output, '/^PROCS OK: 1 process with UID = -2 \(nobody\), args \'usb\'/', "Output correct" );
 | 
			
		||||
    $result = NPTest->testCmd( "$command -u -2 -w 2:2" );
 | 
			
		||||
    is( $result->return_code, 1, "Checking processes with userid=-2" );
 | 
			
		||||
    like( $result->output, '/^PROCS WARNING: 3 processes with UID = -2 \(nobody\)$/', "Output correct" );
 | 
			
		||||
 | 
			
		||||
$result = NPTest->testCmd( "$command -u -2 -a UsB" );
 | 
			
		||||
is( $result->return_code, 0, "Checking case sensitivity of args" );
 | 
			
		||||
like( $result->output, '/^PROCS OK: 0 processes with UID = -2 \(nobody\), args \'UsB\'/', "Output correct" );
 | 
			
		||||
    $result = NPTest->testCmd( "$command -u -2 -w 3:3" );
 | 
			
		||||
    is( $result->return_code, 0, "Checking processes with userid=-2 past threshold" );
 | 
			
		||||
    like( $result->output, '/^PROCS OK: 3 processes with UID = -2 \(nobody\)$/', "Output correct" );
 | 
			
		||||
 | 
			
		||||
    $result = NPTest->testCmd( "$command -u -2 -a usb" );
 | 
			
		||||
    is( $result->return_code, 0, "Checking processes with userid=-2 and usb in arguments" );
 | 
			
		||||
    like( $result->output, '/^PROCS OK: 1 process with UID = -2 \(nobody\), args \'usb\'/', "Output correct" );
 | 
			
		||||
 | 
			
		||||
    $result = NPTest->testCmd( "$command -u -2 -a UsB" );
 | 
			
		||||
    is( $result->return_code, 0, "Checking case sensitivity of args" );
 | 
			
		||||
    like( $result->output, '/^PROCS OK: 0 processes with UID = -2 \(nobody\), args \'UsB\'/', "Output correct" );
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
$result = NPTest->testCmd( "$command --ereg-argument-array='mdworker.*501'" );
 | 
			
		||||
is( $result->return_code, 0, "Checking regexp search of arguments" );
 | 
			
		||||
is( $result->output, "PROCS OK: 1 process with regex args 'mdworker.*501'", "Output correct" );
 | 
			
		||||
is( $result->output, "PROCS OK: 1 process with regex args 'mdworker.*501' | procs=1;;;0;", "Output correct" );
 | 
			
		||||
 | 
			
		||||
$result = NPTest->testCmd( "$command --vsz 1000000" );
 | 
			
		||||
is( $result->return_code, 0, "Checking filter by VSZ" );
 | 
			
		||||
like( $result->output, '/^PROCS OK: 24 processes with VSZ >= 1000000$/', "Output correct" );
 | 
			
		||||
is( $result->output, 'PROCS OK: 24 processes with VSZ >= 1000000 | procs=24;;;0;', "Output correct" );
 | 
			
		||||
 | 
			
		||||
$result = NPTest->testCmd( "$command --rss 100000" );
 | 
			
		||||
is( $result->return_code, 0, "Checking filter by RSS" );
 | 
			
		||||
like( $result->output, '/^PROCS OK: 3 processes with RSS >= 100000$/', "Output correct" );
 | 
			
		||||
is( $result->output, 'PROCS OK: 3 processes with RSS >= 100000 | procs=3;;;0;', "Output correct" );
 | 
			
		||||
 | 
			
		||||
$result = NPTest->testCmd( "$command -s S" );
 | 
			
		||||
is( $result->return_code, 0, "Checking filter for sleeping processes" );
 | 
			
		||||
| 
						 | 
				
			
			@ -86,34 +95,38 @@ like( $result->output, '/^PROCS CRITICAL: 39 processes with PPID = 1/', "Output
 | 
			
		|||
 | 
			
		||||
$result = NPTest->testCmd( "$command -P 0.71" );
 | 
			
		||||
is( $result->return_code, 0, "Checking filter for percentage cpu > 0.71" );
 | 
			
		||||
is( $result->output, 'PROCS OK: 7 processes with PCPU >= 0.71', "Output correct" );
 | 
			
		||||
is( $result->output, 'PROCS OK: 7 processes with PCPU >= 0.71 | procs=7;;;0;', "Output correct" );
 | 
			
		||||
 | 
			
		||||
$result = NPTest->testCmd( "$command -P 0.70" );
 | 
			
		||||
is( $result->return_code, 0, "Checking filter for percentage cpu > 0.70" );
 | 
			
		||||
is( $result->output, 'PROCS OK: 8 processes with PCPU >= 0.70', "Output correct" );
 | 
			
		||||
is( $result->output, 'PROCS OK: 8 processes with PCPU >= 0.70 | procs=8;;;0;', "Output correct" );
 | 
			
		||||
 | 
			
		||||
$result = NPTest->testCmd( "$command --metric=CPU -w 8" );
 | 
			
		||||
is( $result->return_code, 1, "Checking against metric of CPU > 8" );
 | 
			
		||||
is( $result->output, 'CPU WARNING: 1 warn out of 95 processes', "Output correct" );
 | 
			
		||||
is( $result->output, 'CPU WARNING: 1 warn out of 95 processes | procs=95;;;0; procs_warn=1;;;0; procs_crit=0;;;0;', "Output correct" );
 | 
			
		||||
 | 
			
		||||
# TODO: Because of a conversion to int, if CPU is 1.45%, will not alert, but 2.01% will.
 | 
			
		||||
$result = NPTest->testCmd( "$command --metric=CPU -w 1 -u 501 -v" );
 | 
			
		||||
is( $result->return_code, 1, "Checking against metric of CPU > 1 with uid=501 - TODO" );
 | 
			
		||||
is( $result->output, 'CPU WARNING: 2 warn out of 40 processes with UID = 501 (tonvoon) [Skype, PubSubAgent]', "Output correct" );
 | 
			
		||||
SKIP: {
 | 
			
		||||
    skip 'user with uid 501 required', 2 unless getpwuid(501);
 | 
			
		||||
 | 
			
		||||
    $result = NPTest->testCmd( "$command --metric=CPU -w 1 -u 501 -v" );
 | 
			
		||||
    is( $result->return_code, 1, "Checking against metric of CPU > 1 with uid=501 - TODO" );
 | 
			
		||||
    is( $result->output, 'CPU WARNING: 2 warn out of 40 processes with UID = 501 (tonvoon) [Skype, PubSubAgent]', "Output correct" );
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
$result = NPTest->testCmd( "$command --metric=VSZ -w 1200000 -v" );
 | 
			
		||||
is( $result->return_code, 1, "Checking against VSZ > 1.2GB" );
 | 
			
		||||
is( $result->output, 'VSZ WARNING: 4 warn out of 95 processes [WindowServer, Safari, Mail, Skype]', "Output correct" );
 | 
			
		||||
is( $result->output, 'VSZ WARNING: 4 warn out of 95 processes [WindowServer, Safari, Mail, Skype] | procs=95;;;0; procs_warn=4;;;0; procs_crit=0;;;0;', "Output correct" );
 | 
			
		||||
 | 
			
		||||
$result = NPTest->testCmd( "$command --metric=VSZ -w 1200000 -v" );
 | 
			
		||||
is( $result->return_code, 1, "Checking against VSZ > 1.2GB" );
 | 
			
		||||
is( $result->output, 'VSZ WARNING: 4 warn out of 95 processes [WindowServer, Safari, Mail, Skype]', "Output correct" );
 | 
			
		||||
is( $result->output, 'VSZ WARNING: 4 warn out of 95 processes [WindowServer, Safari, Mail, Skype] | procs=95;;;0; procs_warn=4;;;0; procs_crit=0;;;0;', "Output correct" );
 | 
			
		||||
 | 
			
		||||
$result = NPTest->testCmd( "$command --metric=RSS -c 70000 -v" );
 | 
			
		||||
is( $result->return_code, 2, "Checking against RSS > 70MB" );
 | 
			
		||||
is( $result->output, 'RSS CRITICAL: 5 crit, 0 warn out of 95 processes [WindowServer, SystemUIServer, Safari, Mail, Safari]', "Output correct" );
 | 
			
		||||
is( $result->output, 'RSS CRITICAL: 5 crit, 0 warn out of 95 processes [WindowServer, SystemUIServer, Safari, Mail, Safari] | procs=95;;;0; procs_warn=0;;;0; procs_crit=5;;;0;', "Output correct" );
 | 
			
		||||
 | 
			
		||||
$result = NPTest->testCmd( "$command --ereg-argument-array='(nosuchname|nosuch2name)'" );
 | 
			
		||||
is( $result->return_code, 0, "Checking no pipe symbol in output" );
 | 
			
		||||
is( $result->output, "PROCS OK: 0 processes with regex args '(nosuchname,nosuch2name)'", "Output correct" );
 | 
			
		||||
is( $result->output, "PROCS OK: 0 processes with regex args '(nosuchname,nosuch2name)' | procs=0;;;0;", "Output correct" );
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,7 +8,7 @@ use Test::More;
 | 
			
		|||
use NPTest;
 | 
			
		||||
use FindBin qw($Bin);
 | 
			
		||||
 | 
			
		||||
my $tests = 53;
 | 
			
		||||
my $tests = 67;
 | 
			
		||||
# Check that all dependent modules are available
 | 
			
		||||
eval {
 | 
			
		||||
	require NetSNMP::OID;
 | 
			
		||||
| 
						 | 
				
			
			@ -59,7 +59,7 @@ if ($ARGV[0] && $ARGV[0] eq "-d") {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
# We should merge that with $ENV{'NPTEST_CACHE'}, use one dir for all test data
 | 
			
		||||
$ENV{'NAGIOS_PLUGIN_STATE_DIRECTORY'} ||= "/var/tmp";
 | 
			
		||||
$ENV{'MP_STATE_PATH'} ||= "/var/tmp";
 | 
			
		||||
 | 
			
		||||
my $res;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -79,7 +79,7 @@ Copyright (c) 1986-2004 by cisco Systems, Inc.
 | 
			
		|||
$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.0 -o sysContact.0 -o .1.3.6.1.4.1.8072.3.2.67.1");
 | 
			
		||||
cmp_ok( $res->return_code, '==', 0, "Exit OK when querying multi-line OIDs" );
 | 
			
		||||
like($res->output, '/^SNMP OK - /', "String contains SNMP OK");
 | 
			
		||||
like($res->output, '/'.quotemeta('SNMP OK - Cisco Internetwork Operating System Software Alice Kisco Outernetwork Oserating Gystem Totware | 
 | 
			
		||||
like($res->output, '/'.quotemeta('SNMP OK - Cisco Internetwork Operating System Software ').'"?Alice"?'.quotemeta(' Kisco Outernetwork Oserating Gystem Totware | 
 | 
			
		||||
.1.3.6.1.4.1.8072.3.2.67.0:
 | 
			
		||||
"Cisco Internetwork Operating System Software
 | 
			
		||||
IOS (tm) Catalyst 4000 \"L3\" Switch Software (cat4000-I9K91S-M), Version
 | 
			
		||||
| 
						 | 
				
			
			@ -109,7 +109,7 @@ like($res->output, '/'.quotemeta('SNMP OK - And now have fun with with this: \"C
 | 
			
		|||
"And now have fun with with this: \"C:\\\\\"
 | 
			
		||||
because we\'re not done yet!"').'/m', "Attempt to confuse parser No.3");
 | 
			
		||||
 | 
			
		||||
system("rm -f ".$ENV{'NAGIOS_PLUGIN_STATE_DIRECTORY'}."/check_snmp/*");
 | 
			
		||||
system("rm -f ".$ENV{'MP_STATE_PATH'}."/check_snmp/*");
 | 
			
		||||
$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -w 600" );
 | 
			
		||||
is($res->return_code, 0, "Returns OK");
 | 
			
		||||
is($res->output, "No previous data to calculate rate - assume okay");
 | 
			
		||||
| 
						 | 
				
			
			@ -214,3 +214,31 @@ $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1
 | 
			
		|||
is($res->return_code, 0, "String check should check whole string, not a parsed number" );
 | 
			
		||||
is($res->output, 'SNMP OK - "CUSTOM CHECK OK: foo is 12345" | ', "String check witn numbers returns whole string");
 | 
			
		||||
 | 
			
		||||
$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.16 -w -2: -c -3:" );
 | 
			
		||||
is($res->return_code, 0, "Negative integer check OK" );
 | 
			
		||||
is($res->output, 'SNMP OK - -2 | iso.3.6.1.4.1.8072.3.2.67.16=-2 ', "Negative integer check OK output" );
 | 
			
		||||
 | 
			
		||||
$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.16 -w -2: -c -3:" );
 | 
			
		||||
is($res->return_code, 1, "Negative integer check WARNING" );
 | 
			
		||||
is($res->output, 'SNMP WARNING - *-3* | iso.3.6.1.4.1.8072.3.2.67.16=-3 ', "Negative integer check WARNING output" );
 | 
			
		||||
 | 
			
		||||
$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.16 -w -2: -c -3:" );
 | 
			
		||||
is($res->return_code, 2, "Negative integer check CRITICAL" );
 | 
			
		||||
is($res->output, 'SNMP CRITICAL - *-4* | iso.3.6.1.4.1.8072.3.2.67.16=-4 ', "Negative integer check CRITICAL output" );
 | 
			
		||||
 | 
			
		||||
$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.17 -w -3: -c -6:" );
 | 
			
		||||
is($res->return_code, 1, "Negative integer as string, WARNING" );
 | 
			
		||||
is($res->output, 'SNMP WARNING - *-4* | iso.3.6.1.4.1.8072.3.2.67.17=-4 ', "Negative integer as string, WARNING output" );
 | 
			
		||||
 | 
			
		||||
$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.17 -w -2: -c -3:" );
 | 
			
		||||
is($res->return_code, 2, "Negative integer as string, CRITICAL" );
 | 
			
		||||
is($res->output, 'SNMP CRITICAL - *-4* | iso.3.6.1.4.1.8072.3.2.67.17=-4 ', "Negative integer as string, CRITICAL output" );
 | 
			
		||||
 | 
			
		||||
$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.18 -c ~:-6.5" );
 | 
			
		||||
is($res->return_code, 0, "Negative float OK" );
 | 
			
		||||
is($res->output, 'SNMP OK - -6.6 | iso.3.6.1.4.1.8072.3.2.67.18=-6.6 ', "Negative float OK output" );
 | 
			
		||||
 | 
			
		||||
$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.18 -w ~:-6.65 -c ~:-6.55" );
 | 
			
		||||
is($res->return_code, 1, "Negative float WARNING" );
 | 
			
		||||
is($res->output, 'SNMP WARNING - *-6.6* | iso.3.6.1.4.1.8072.3.2.67.18=-6.6 ', "Negative float WARNING output" );
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
use NetSNMP::OID qw(:all);
 | 
			
		||||
use NetSNMP::agent;
 | 
			
		||||
use NetSNMP::ASN qw(ASN_OCTET_STR ASN_COUNTER ASN_COUNTER64 ASN_INTEGER ASN_INTEGER64 ASN_UNSIGNED ASN_UNSIGNED64);
 | 
			
		||||
#use Math::Int64 qw(uint64); # Skip that module whie we don't need it
 | 
			
		||||
#use Math::Int64 qw(uint64); # Skip that module while we don't need it
 | 
			
		||||
sub uint64 { return $_ }
 | 
			
		||||
 | 
			
		||||
if (!$agent) {
 | 
			
		||||
| 
						 | 
				
			
			@ -16,8 +16,6 @@ if (!$agent) {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
my $baseoid = '.1.3.6.1.4.1.8072.3.2.67';
 | 
			
		||||
# Next are arrays of indexes (Type, initial value and increments)
 | 
			
		||||
# Undef miltipliers are randomized
 | 
			
		||||
my $multiline = 'Cisco Internetwork Operating System Software
 | 
			
		||||
IOS (tm) Catalyst 4000 "L3" Switch Software (cat4000-I9K91S-M), Version
 | 
			
		||||
12.2(20)EWA, RELEASE SOFTWARE (fc1)
 | 
			
		||||
| 
						 | 
				
			
			@ -33,10 +31,12 @@ ends with with this: C:\\';
 | 
			
		|||
my $multilin5 = 'And now have fun with with this: "C:\\"
 | 
			
		||||
because we\'re not done yet!';
 | 
			
		||||
 | 
			
		||||
# 0..15 <---- please update comment when adding/removing fields
 | 
			
		||||
my @fields = (ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_UNSIGNED, ASN_UNSIGNED, ASN_COUNTER, ASN_COUNTER64, ASN_UNSIGNED, ASN_COUNTER, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR );
 | 
			
		||||
my @values = ($multiline, $multilin2, $multilin3, $multilin4, $multilin5, 4294965296, 1000, 4294965296, uint64("18446744073709351616"), int(rand(2**32)), 64000, "stringtests", "3.5", "87.4startswithnumberbutshouldbestring", '555"I said"', 'CUSTOM CHECK OK: foo is 12345' );
 | 
			
		||||
my @incrts = (undef, undef, undef, undef, undef, 1000, -500, 1000, 100000, undef, 666, undef, undef, undef, undef, undef );
 | 
			
		||||
# Next are arrays of indexes (Type, initial value and increments)
 | 
			
		||||
# 0..16 <---- please update comment when adding/removing fields
 | 
			
		||||
my @fields = (ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_UNSIGNED, ASN_UNSIGNED, ASN_COUNTER, ASN_COUNTER64, ASN_UNSIGNED, ASN_COUNTER, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_INTEGER, ASN_OCTET_STR, ASN_OCTET_STR );
 | 
			
		||||
my @values = ($multiline, $multilin2, $multilin3, $multilin4, $multilin5, 4294965296, 1000, 4294965296, uint64("18446744073709351616"), int(rand(2**32)), 64000, "stringtests", "3.5", "87.4startswithnumberbutshouldbestring", '555"I said"', 'CUSTOM CHECK OK: foo is 12345', -2, '-4', '-6.6' );
 | 
			
		||||
# undef increments are randomized
 | 
			
		||||
my @incrts = (undef, undef, undef, undef, undef, 1000, -500, 1000, 100000, undef, 666, undef, undef, undef, undef, undef, -1, undef, undef );
 | 
			
		||||
 | 
			
		||||
# Number of elements in our OID
 | 
			
		||||
my $oidelts;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -31,7 +31,7 @@ S        0  6907     1  2308  892  0.0 mysqld_safe      /bin/sh /usr/bin/mysqld_
 | 
			
		|||
S      103  6944  6907 123220 27724  0.0 mysqld         /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-locking --port=3306 --socket=/var/run/mysqld/mysqld.sock
 | 
			
		||||
S        0  6945  6907  1488  420  0.0 logger           logger -p daemon.err -t mysqld_safe -i -t mysqld
 | 
			
		||||
S     1001 17778     1  6436 1588  0.0 snmpd            /usr/sbin/snmpd -u nagios -Lsd -Lf /dev/null -p/var/run/snmpd.pid
 | 
			
		||||
Ss       0 17789     1  9496 5556  0.0 snmptrapd        /usr/sbin/snmptrapd -t -m ALL -M /usr/share/snmp/mibs:/usr/local/nagios/snmp/load -p /var/run/snmptrapd.pid
 | 
			
		||||
Ss       0 17789     1  9496 5556  0.0 snmptrapd        /usr/sbin/snmptrapd -t -m ALL -M /usr/share/snmp/mibs:/usr/local/monitoring/snmp/load -p /var/run/snmptrapd.pid
 | 
			
		||||
Ss       0   847  2319 14452 1752  0.0 sshd             sshd: tonvoon [priv]
 | 
			
		||||
S     1000   857   847 14616 1832  0.0 sshd             sshd: tonvoon@pts/3
 | 
			
		||||
Ss    1000   860   857  2984 1620  0.0 bash             -bash
 | 
			
		||||
| 
						 | 
				
			
			@ -79,6 +79,6 @@ Ss    1001 23783     1  3220  764  0.0 ndo2db           /usr/local/nagios/bin/nd
 | 
			
		|||
Ss    1001 23784     1  6428 4948  0.0 import_ndologsd  import_ndologsd
 | 
			
		||||
S+    1001  9803 18955  4132 1936  0.0 ssh              ssh altinity@cube02.lei.altinity
 | 
			
		||||
S     1001 22505 22324 20256 1616  0.0 nagios           ../../bin/nagios -d /usr/local/nagios/etc/nagios.cfg
 | 
			
		||||
S     1001 22506 22505  1676  608  0.0 check_ping       /usr/local/nagios/libexec/check_ping -H 192.168.10.23 -w 3000.0,80% -c 5000.0,100% -p 1
 | 
			
		||||
S     1001 22506 22505  1676  608  0.0 check_ping       /usr/local/libexec/check_ping -H 192.168.10.23 -w 3000.0,80% -c 5000.0,100% -p 1
 | 
			
		||||
S     1001 22507 22506  1660  492  0.0 ping             /bin/ping -n -U -w 10 -c 1 192.168.10.23
 | 
			
		||||
R+    1001 22508 23370  2308  680  0.0 ps               ps axwo stat uid pid ppid vsz rss pcpu comm args
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue