diff options
author | Matthias Eble <psychotrahe@gmx.de> | 2009-06-11 17:20:55 +0200 |
---|---|---|
committer | Matthias Eble <psychotrahe@gmx.de> | 2009-06-11 17:20:55 +0200 |
commit | edda2536e589810070abcb59e3cb2b3d0b334a01 (patch) | |
tree | c65405f5ce165c2a1d0c87c7f826440990353705 /plugins-scripts/t/check_ifstatus.t | |
parent | e16b35b2ca960f8e56c17013a749e181d429a725 (diff) | |
download | monitoring-plugins-edda2536e589810070abcb59e3cb2b3d0b334a01.tar.gz |
Fixed SNMPv3 behaviour of check_ifstatus. Added -P to define privprotocol (#2343438 - Robin Schroeder)
check_ifstatus didn't function correctly with SNMPv3. This is fixed now.
Created argument-hash for SNMP session creation. This removes redundant code.
Session creation was moved out of process_arguments() and now takes place
after setting the timeout handler.
Additionally the -P argument was added to specify the privprotocol.
Diffstat (limited to 'plugins-scripts/t/check_ifstatus.t')
-rw-r--r-- | plugins-scripts/t/check_ifstatus.t | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/plugins-scripts/t/check_ifstatus.t b/plugins-scripts/t/check_ifstatus.t new file mode 100644 index 00000000..c5169d90 --- /dev/null +++ b/plugins-scripts/t/check_ifstatus.t | |||
@@ -0,0 +1,63 @@ | |||
1 | #! /usr/bin/perl -w -I .. | ||
2 | # | ||
3 | # SNMP Test via check_ifoperstatus | ||
4 | # | ||
5 | # | ||
6 | |||
7 | use strict; | ||
8 | use Test::More; | ||
9 | use NPTest; | ||
10 | |||
11 | my $tests = 9; | ||
12 | plan tests => $tests; | ||
13 | my $res; | ||
14 | |||
15 | my $plugin = "check_ifstatus"; | ||
16 | SKIP: { | ||
17 | skip "$plugin is not created", $tests if ( ! -x $plugin ); | ||
18 | |||
19 | my $host_snmp = getTestParameter( "host_snmp", "NP_HOST_SNMP", "localhost", | ||
20 | "A host providing an SNMP Service"); | ||
21 | |||
22 | my $snmp_community = getTestParameter( "snmp_community", "NP_SNMP_COMMUNITY", "public", | ||
23 | "The SNMP Community string for SNMP Testing (assumes snmp v1)" ); | ||
24 | |||
25 | my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", | ||
26 | "The hostname of system not responsive to network requests" ); | ||
27 | |||
28 | my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", | ||
29 | "An invalid (not known to DNS) hostname" ); | ||
30 | |||
31 | $res = NPTest->testCmd( "./$plugin" ); | ||
32 | is( $res->return_code, 3, "No arguments" ); | ||
33 | like( $res->output, '/usage/', "Output contains usage" ); | ||
34 | |||
35 | $res = NPTest->testCmd( "./$plugin -H fakehost -v 3 --seclevel rubbish --secname foobar" ); | ||
36 | is( $res->return_code, 3, "invalid seclevel" ); | ||
37 | like( $res->output, "/Must define a valid security level/", "Output contains 'Must define a valid security level'" ); | ||
38 | |||
39 | SKIP: { | ||
40 | skip "no snmp host defined", 2 if ( ! $host_snmp ); | ||
41 | |||
42 | $res = NPTest->testCmd( "./$plugin -H $host_snmp -C $snmp_community "); | ||
43 | like($res->output, '/^.*host.*interfaces up/', "String contains host.*interfaces up"); | ||
44 | |||
45 | $res = NPTest->testCmd( "./$plugin -H $host_snmp -C rubbish"); | ||
46 | cmp_ok( $res->return_code, '==', 2, "Exit CRITICAL for community 'rubbish'" ); | ||
47 | |||
48 | } | ||
49 | |||
50 | SKIP: { | ||
51 | skip "no non responsive host defined", 1 if ( ! $host_nonresponsive ); | ||
52 | $res = NPTest->testCmd( "./$plugin -H $host_nonresponsive -C $snmp_community"); | ||
53 | cmp_ok( $res->return_code, '==', 2, "Exit CRITICAL with non responsive host" ); | ||
54 | } | ||
55 | |||
56 | SKIP: { | ||
57 | skip "no invalid host defined", 2 if ( ! $hostname_invalid ); | ||
58 | $res = NPTest->testCmd( "./$plugin -H $hostname_invalid -C $snmp_community"); | ||
59 | cmp_ok( $res->return_code, '==', 3, "Exit UNKNOWN with invalid host" ); | ||
60 | like($res->output, "/Unable to resolve.*$hostname_invalid/", "String matches unable to resolve.*$hostname_invalid"); | ||
61 | } | ||
62 | |||
63 | } | ||