Imported Upstream version 2.0
This commit is contained in:
parent
c89ccc3c74
commit
0841b5c7c7
165 changed files with 25440 additions and 4442 deletions
|
@ -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" );
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue