summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Guyot-Sionnest <dermoth@aei.ca>2010-04-22 03:04:06 (GMT)
committerThomas Guyot-Sionnest <dermoth@aei.ca>2010-04-22 03:04:06 (GMT)
commit00bf32bb6088557d69f91a41f3a556c3e495cd46 (patch)
treec2268859553f5107e726a95aee67d8afd1f2a4db
parent47d04677b7a8b12b00e4f4c2a815514ad56b1239 (diff)
downloadmonitoring-plugins-00bf32bb6088557d69f91a41f3a556c3e495cd46.tar.gz
Fix tests and update NEWS file
-rw-r--r--NEWS1
-rwxr-xr-xplugins/tests/check_snmp.t53
2 files changed, 50 insertions, 4 deletions
diff --git a/NEWS b/NEWS
index d09414c..5ed4cf0 100644
--- a/NEWS
+++ b/NEWS
@@ -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 5605b00..b5f3f89 100755
--- a/plugins/tests/check_snmp.t
+++ b/plugins/tests/check_snmp.t
@@ -8,8 +8,18 @@ use Test::More;
8use NPTest; 8use NPTest;
9use FindBin qw($Bin); 9use FindBin qw($Bin);
10 10
11# Check that all dependent modules are available
12eval {
13 require NetSNMP::OID;
14 require NetSNMP::agent;
15 require NetSNMP::ASN;
16};
17
18if ($@) {
19 plan skip_all => "Missing required module for test: $@";
20}
21
11my $port_snmp = 16100 + int(rand(100)); 22my $port_snmp = 16100 + int(rand(100));
12my $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
44my $tests = 3; 54my $tests = 9;
45if (-x "./check_snmp") { 55if (-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");
54cmp_ok( $res->return_code, '==', 0, "Exit OK when querying a multi-line string" ); 64cmp_ok( $res->return_code, '==', 0, "Exit OK when querying a multi-line string" );
55like($res->output, '/^SNMP OK - /', "String contains SNMP OK"); 65like($res->output, '/^SNMP OK - /', "String contains SNMP OK");
56like($res->output, '/'.quotemeta('SNMP OK - "Cisco Internetwork Operating System SoftwareIOS (tm) Catalyst 4000 L3 Switch Software (cat4000-I9K91S-M), Version 66like($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
69IOS (tm) Catalyst 4000 \"L3\" Switch Software (cat4000-I9K91S-M), Version
5712.2(20)EWA, RELEASE SOFTWARE (fc1) 7012.2(20)EWA, RELEASE SOFTWARE (fc1)
58Technical Support: http://www.cisco.com/techsupport 71Technical Support: http://www.cisco.com/techsupport
59Copyright (c) 1986-2004 by cisco Systems, Inc. 72Copyright (c) 1986-2004 by cisco Systems, Inc.
60"').'/m', "String contains all lines"); 73"').'/m', "String contains all lines");
61 74
62print $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");
77cmp_ok( $res->return_code, '==', 0, "Exit OK when querying multi-line OIDs" );
78like($res->output, '/^SNMP OK - /', "String contains SNMP OK");
79like($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
82IOS (tm) Catalyst 4000 \"L3\" Switch Software (cat4000-I9K91S-M), Version
8312.2(20)EWA, RELEASE SOFTWARE (fc1)
84Technical Support: http://www.cisco.com/techsupport
85Copyright (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
89Copyleft (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");
92like($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\"
95into 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");
98like($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
101ends 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");
104like($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:\\\\\"
107because we\'re not done yet!"').'/m', "Attempt to confuse parser No.3");
63 108