diff options
Diffstat (limited to 'plugins/t/check_snmp.t')
-rw-r--r-- | plugins/t/check_snmp.t | 91 |
1 files changed, 48 insertions, 43 deletions
diff --git a/plugins/t/check_snmp.t b/plugins/t/check_snmp.t index 162b0b9b..b45b6c01 100644 --- a/plugins/t/check_snmp.t +++ b/plugins/t/check_snmp.t | |||
@@ -1,52 +1,57 @@ | |||
1 | #! /usr/bin/perl -w | 1 | #! /usr/bin/perl -w -I .. |
2 | # | ||
3 | # Simple Network Management Protocol (SNMP) Test via check_snmp | ||
4 | # | ||
5 | # $Id$ | ||
6 | # | ||
2 | 7 | ||
3 | use strict; | 8 | use strict; |
4 | use Helper; | ||
5 | use Cache; | ||
6 | use Test; | 9 | use Test; |
7 | use vars qw($tests); | 10 | use NPTest; |
8 | 11 | ||
9 | BEGIN {$tests = 8; plan tests => $tests} | 12 | use vars qw($tests); |
13 | BEGIN {$tests = 12; plan tests => $tests} | ||
10 | 14 | ||
11 | my $null = ''; | ||
12 | my $cmd; | ||
13 | my $str; | ||
14 | my $t; | 15 | my $t; |
15 | my $community=get_option("snmp_community","SNMP community name"); | 16 | |
16 | 17 | if ( -x "./check_snmp" ) | |
17 | exit(0) unless (-x "./check_snmp"); | 18 | { |
18 | 19 | my $host_snmp = getTestParameter( "host_snmp", "NP_HOST_SNMP", "localhost", | |
19 | $cmd = "./check_snmp -H 127.0.0.1 -C $community -o system.sysUpTime.0 -w 1: -c 1:"; | 20 | "A host providing an SNMP Service"); |
20 | $str = `$cmd`; | 21 | |
21 | $t += ok $?>>8,0; | 22 | my $snmp_community = getTestParameter( "snmp_community", "NP_SNMP_COMMUNITY", "public", |
22 | print "Test was: $cmd\n" if ($?); | 23 | "The SNMP Community string for SNMP Testing" ); |
23 | chomp $str; | 24 | |
24 | $t += ok $str, '/^SNMP OK - \d+/'; | 25 | my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", |
25 | 26 | "The hostname of system not responsive to network requests" ); | |
26 | $cmd = "./check_snmp -H 127.0.0.1 -C $community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 1:1 -c 1:1"; | 27 | |
27 | $str = `$cmd`; | 28 | my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", |
28 | $t += ok $?>>8,0; | 29 | "An invalid (not known to DNS) hostname" ); |
29 | print "Test was: $cmd\n" if ($?); | 30 | |
30 | chomp $str; | 31 | my %exceptions = ( 3 => "No SNMP Server present?" ); |
31 | $t += ok $str, '/^SNMP OK - 1\s*$/'; | 32 | |
32 | 33 | ||
33 | $cmd = "./check_snmp -H 127.0.0.1 -C $community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 0 -c 1:"; | 34 | $t += checkCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -w 1: -c 1:", |
34 | $str = `$cmd`; | 35 | { 0 => 'continue', 3 => 'skip' }, '/^SNMP OK - \d+/', %exceptions ); |
35 | $t += ok $?>>8,1; | 36 | |
36 | print "Test was: $cmd\n" unless ($?); | 37 | $t += checkCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 1:1 -c 1:1", |
37 | chomp $str; | 38 | { 0 => 'continue', 3 => 'skip' }, '/^SNMP OK - 1\s*$/', %exceptions ); |
38 | $t += ok $str, '/^SNMP WARNING - \*1\*\s*$/'; | 39 | |
39 | 40 | $t += checkCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 0 -c 1:", | |
40 | $cmd = "./check_snmp -H 127.0.0.1 -C $community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w :0 -c 0"; | 41 | { 1 => 'continue', 3 => 'skip' }, '/^SNMP WARNING - \*1\*\s*$/', %exceptions ); |
41 | $str = `$cmd`; | 42 | |
42 | $t += ok $?>>8,2; | 43 | $t += checkCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w :0 -c 0", |
43 | print "Test was: $cmd\n" unless ($?); | 44 | { 2 => 'continue', 3 => 'skip' }, '/^SNMP CRITICAL - \*1\*\s*$/', %exceptions ); |
44 | chomp $str; | 45 | |
45 | $t += ok $str, '/^SNMP CRITICAL - \*1\*\s*$/'; | 46 | $t += checkCmd( "./check_snmp -H $host_nonresponsive -C $snmp_community -o system.sysUpTime.0 -w 1: -c 1:", 3, '/SNMP problem - /' ); |
46 | 47 | ||
47 | #host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 = 1 | 48 | $t += checkCmd( "./check_snmp -H $hostname_invalid -C $snmp_community -o system.sysUpTime.0 -w 1: -c 1:", 3, '/SNMP problem - /' ); |
48 | #enterprises.ucdavis.memory.memAvailSwap.0 | 49 | |
49 | #./check_snmp 127.0.0.1 -C staff -o enterprises.ucdavis.diskTable.dskEntry.dskAvail.1,enterprises.ucdavis.diskTable.dskEntry.dskPercent.1 -w 100000: -c 50000: -l Space on root -u 'bytes free (','% used)' | 50 | } |
51 | else | ||
52 | { | ||
53 | $t += skipMissingCmd( "./check_snmp", $tests ); | ||
54 | } | ||
50 | 55 | ||
51 | exit(0) if defined($Test::Harness::VERSION); | 56 | exit(0) if defined($Test::Harness::VERSION); |
52 | exit($tests - $t); | 57 | exit($tests - $t); |