diff options
author | Thomas Guyot-Sionnest <dermoth@aei.ca> | 2010-04-21 23:04:06 -0400 |
---|---|---|
committer | Thomas Guyot-Sionnest <dermoth@aei.ca> | 2010-04-21 23:04:06 -0400 |
commit | 00bf32bb6088557d69f91a41f3a556c3e495cd46 (patch) | |
tree | c2268859553f5107e726a95aee67d8afd1f2a4db | |
parent | 47d04677b7a8b12b00e4f4c2a815514ad56b1239 (diff) | |
download | monitoring-plugins-00bf32bb6088557d69f91a41f3a556c3e495cd46.tar.gz |
Fix tests and update NEWS file
-rw-r--r-- | NEWS | 1 | ||||
-rwxr-xr-x | plugins/tests/check_snmp.t | 53 |
2 files changed, 50 insertions, 4 deletions
@@ -22,6 +22,7 @@ This file documents the major additions and syntax changes between releases. | |||
22 | Fix compilation error of pst3 in Solaris 8 | 22 | Fix compilation error of pst3 in Solaris 8 |
23 | Fix check_radius returning OK on unexpected results (Craig Leres - #2911752) | 23 | Fix check_radius returning OK on unexpected results (Craig Leres - #2911752) |
24 | Fix translations when extra-opts aren't enabled (Jan Wagner - #2832884) | 24 | Fix translations when extra-opts aren't enabled (Jan Wagner - #2832884) |
25 | Fix parsing of multi-line strings in check_snmp (broken in 1.4.14) and enhance output in such case (#2832451) | ||
25 | WARNINGS | 26 | WARNINGS |
26 | Updated developer documentation to say that performance labels should not have an equals sign or | 27 | Updated developer documentation to say that performance labels should not have an equals sign or |
27 | single quote in the label | 28 | single quote in the label |
diff --git a/plugins/tests/check_snmp.t b/plugins/tests/check_snmp.t index 5605b003..b5f3f89e 100755 --- a/plugins/tests/check_snmp.t +++ b/plugins/tests/check_snmp.t | |||
@@ -8,8 +8,18 @@ use Test::More; | |||
8 | use NPTest; | 8 | use NPTest; |
9 | use FindBin qw($Bin); | 9 | use FindBin qw($Bin); |
10 | 10 | ||
11 | # Check that all dependent modules are available | ||
12 | eval { | ||
13 | require NetSNMP::OID; | ||
14 | require NetSNMP::agent; | ||
15 | require NetSNMP::ASN; | ||
16 | }; | ||
17 | |||
18 | if ($@) { | ||
19 | plan skip_all => "Missing required module for test: $@"; | ||
20 | } | ||
21 | |||
11 | my $port_snmp = 16100 + int(rand(100)); | 22 | my $port_snmp = 16100 + int(rand(100)); |
12 | my $running = 1; | ||
13 | 23 | ||
14 | 24 | ||
15 | # Start up server | 25 | # Start up server |
@@ -41,7 +51,7 @@ if ($ARGV[0] && $ARGV[0] eq "-d") { | |||
41 | } | 51 | } |
42 | } | 52 | } |
43 | 53 | ||
44 | my $tests = 3; | 54 | my $tests = 9; |
45 | if (-x "./check_snmp") { | 55 | if (-x "./check_snmp") { |
46 | plan tests => $tests; | 56 | plan tests => $tests; |
47 | } else { | 57 | } else { |
@@ -53,11 +63,46 @@ my $res; | |||
53 | $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"); | 63 | $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"); |
54 | cmp_ok( $res->return_code, '==', 0, "Exit OK when querying a multi-line string" ); | 64 | cmp_ok( $res->return_code, '==', 0, "Exit OK when querying a multi-line string" ); |
55 | like($res->output, '/^SNMP OK - /', "String contains SNMP OK"); | 65 | like($res->output, '/^SNMP OK - /', "String contains SNMP OK"); |
56 | like($res->output, '/'.quotemeta('SNMP OK - "Cisco Internetwork Operating System SoftwareIOS (tm) Catalyst 4000 L3 Switch Software (cat4000-I9K91S-M), Version | 66 | like($res->output, '/'.quotemeta('SNMP OK - Cisco Internetwork Operating System Software | |
67 | .1.3.6.1.4.1.8072.3.2.67.0: | ||
68 | "Cisco Internetwork Operating System Software | ||
69 | IOS (tm) Catalyst 4000 \"L3\" Switch Software (cat4000-I9K91S-M), Version | ||
57 | 12.2(20)EWA, RELEASE SOFTWARE (fc1) | 70 | 12.2(20)EWA, RELEASE SOFTWARE (fc1) |
58 | Technical Support: http://www.cisco.com/techsupport | 71 | Technical Support: http://www.cisco.com/techsupport |
59 | Copyright (c) 1986-2004 by cisco Systems, Inc. | 72 | Copyright (c) 1986-2004 by cisco Systems, Inc. |
60 | "').'/m', "String contains all lines"); | 73 | "').'/m', "String contains all lines"); |
61 | 74 | ||
62 | print $res->output; | 75 | # sysContact.0 is "Alice" (from our snmpd.conf) |
76 | $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"); | ||
77 | cmp_ok( $res->return_code, '==', 0, "Exit OK when querying multi-line OIDs" ); | ||
78 | like($res->output, '/^SNMP OK - /', "String contains SNMP OK"); | ||
79 | like($res->output, '/'.quotemeta('SNMP OK - Cisco Internetwork Operating System Software Alice Kisco Outernetwork Oserating Gystem Totware | | ||
80 | .1.3.6.1.4.1.8072.3.2.67.0: | ||
81 | "Cisco Internetwork Operating System Software | ||
82 | IOS (tm) Catalyst 4000 \"L3\" Switch Software (cat4000-I9K91S-M), Version | ||
83 | 12.2(20)EWA, RELEASE SOFTWARE (fc1) | ||
84 | Technical Support: http://www.cisco.com/techsupport | ||
85 | Copyright (c) 1986-2004 by cisco Systems, Inc. | ||
86 | " | ||
87 | .1.3.6.1.4.1.8072.3.2.67.1: | ||
88 | "Kisco Outernetwork Oserating Gystem Totware | ||
89 | Copyleft (c) 2400-2689 by kisco Systrems, Inc."').'/m', "String contains all lines with multiple OIDs"); | ||
90 | |||
91 | $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.2"); | ||
92 | like($res->output, '/'.quotemeta('SNMP OK - This should not confuse check_snmp \"parser\" | | ||
93 | .1.3.6.1.4.1.8072.3.2.67.2: | ||
94 | "This should not confuse check_snmp \"parser\" | ||
95 | into thinking there is no 2nd line"').'/m', "Attempt to confuse parser No.1"); | ||
96 | |||
97 | $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.3"); | ||
98 | like($res->output, '/'.quotemeta('SNMP OK - It\'s getting even harder if the line | | ||
99 | .1.3.6.1.4.1.8072.3.2.67.3: | ||
100 | "It\'s getting even harder if the line | ||
101 | ends with with this: C:\\\\"').'/m', "Attempt to confuse parser No.2"); | ||
102 | |||
103 | $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.4"); | ||
104 | like($res->output, '/'.quotemeta('SNMP OK - And now have fun with with this: \"C:\\\\\" | | ||
105 | .1.3.6.1.4.1.8072.3.2.67.4: | ||
106 | "And now have fun with with this: \"C:\\\\\" | ||
107 | because we\'re not done yet!"').'/m', "Attempt to confuse parser No.3"); | ||
63 | 108 | ||