diff options
Diffstat (limited to 'plugins/tests/check_snmp_agent.pl')
-rw-r--r-- | plugins/tests/check_snmp_agent.pl | 78 |
1 files changed, 70 insertions, 8 deletions
diff --git a/plugins/tests/check_snmp_agent.pl b/plugins/tests/check_snmp_agent.pl index 38912e98..608b6f92 100644 --- a/plugins/tests/check_snmp_agent.pl +++ b/plugins/tests/check_snmp_agent.pl | |||
@@ -4,9 +4,10 @@ | |||
4 | # | 4 | # |
5 | 5 | ||
6 | #use strict; # Doesn't work | 6 | #use strict; # Doesn't work |
7 | use warnings; | ||
7 | use NetSNMP::OID qw(:all); | 8 | use NetSNMP::OID qw(:all); |
8 | use NetSNMP::agent; | 9 | use NetSNMP::agent; |
9 | use NetSNMP::ASN qw(ASN_OCTET_STR ASN_COUNTER ASN_COUNTER64 ASN_INTEGER ASN_INTEGER64 ASN_UNSIGNED ASN_UNSIGNED64); | 10 | use NetSNMP::ASN qw(ASN_OCTET_STR ASN_COUNTER ASN_COUNTER64 ASN_INTEGER ASN_INTEGER64 ASN_UNSIGNED ASN_UNSIGNED64 ASN_FLOAT); |
10 | #use Math::Int64 qw(uint64); # Skip that module while we don't need it | 11 | #use Math::Int64 qw(uint64); # Skip that module while we don't need it |
11 | sub uint64 { return $_ } | 12 | sub uint64 { return $_ } |
12 | 13 | ||
@@ -22,21 +23,82 @@ IOS (tm) Catalyst 4000 "L3" Switch Software (cat4000-I9K91S-M), Version | |||
22 | Technical Support: http://www.cisco.com/techsupport | 23 | Technical Support: http://www.cisco.com/techsupport |
23 | Copyright (c) 1986-2004 by cisco Systems, Inc. | 24 | Copyright (c) 1986-2004 by cisco Systems, Inc. |
24 | '; | 25 | '; |
25 | my $multilin2 = "Kisco Outernetwork Oserating Gystem Totware | 26 | my $multiline2 = "Kisco Outernetwork Oserating Gystem Totware |
26 | Copyleft (c) 2400-2689 by kisco Systrems, Inc."; | 27 | Copyleft (c) 2400-2689 by kisco Systrems, Inc."; |
27 | my $multilin3 = 'This should not confuse check_snmp "parser" | 28 | my $multiline3 = 'This should not confuse check_snmp "parser" |
28 | into thinking there is no 2nd line'; | 29 | into thinking there is no 2nd line'; |
29 | my $multilin4 = 'It\'s getting even harder if the line | 30 | my $multiline4 = 'It\'s getting even harder if the line |
30 | ends with with this: C:\\'; | 31 | ends with with this: C:\\'; |
31 | my $multilin5 = 'And now have fun with with this: "C:\\" | 32 | my $multiline5 = 'And now have fun with with this: "C:\\" |
32 | because we\'re not done yet!'; | 33 | because we\'re not done yet!'; |
33 | 34 | ||
34 | # Next are arrays of indexes (Type, initial value and increments) | 35 | # Next are arrays of indexes (Type, initial value and increments) |
35 | # 0..19 <---- please update comment when adding/removing fields | 36 | # 0..19 <---- please update comment when adding/removing fields |
36 | my @fields = (ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_UNSIGNED, ASN_UNSIGNED, ASN_COUNTER, ASN_COUNTER64, ASN_UNSIGNED, ASN_COUNTER, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_INTEGER, ASN_OCTET_STR, ASN_OCTET_STR, ASN_INTEGER ); | 37 | my @fields = (ASN_OCTET_STR, # 0 |
37 | my @values = ($multiline, $multilin2, $multilin3, $multilin4, $multilin5, 4294965296, 1000, 4294965296, uint64("18446744073709351616"), int(rand(2**32)), 64000, "stringtests", "3.5", "87.4startswithnumberbutshouldbestring", '555"I said"', 'CUSTOM CHECK OK: foo is 12345', -2, '-4', '-6.6', 42 ); | 38 | ASN_OCTET_STR, # 1 |
39 | ASN_OCTET_STR, # 2 | ||
40 | ASN_OCTET_STR, # 3 | ||
41 | ASN_OCTET_STR, # 4 | ||
42 | ASN_UNSIGNED, # 5 | ||
43 | ASN_UNSIGNED, # 6 | ||
44 | ASN_COUNTER, # 7 | ||
45 | ASN_COUNTER64, # 8 | ||
46 | ASN_UNSIGNED, # 9 | ||
47 | ASN_COUNTER, # 10 | ||
48 | ASN_OCTET_STR, # 11 | ||
49 | ASN_OCTET_STR, # 12 | ||
50 | ASN_OCTET_STR, # 13 | ||
51 | ASN_OCTET_STR, # 14 | ||
52 | ASN_OCTET_STR, # 15 | ||
53 | ASN_INTEGER, # 16 | ||
54 | ASN_INTEGER, # 17 | ||
55 | ASN_FLOAT, # 18 | ||
56 | ASN_INTEGER # 19 | ||
57 | ); | ||
58 | my @values = ($multiline, # 0 | ||
59 | $multiline2, # 1 | ||
60 | $multiline3, # 2 | ||
61 | $multiline4, # 3 | ||
62 | $multiline5, # 4 | ||
63 | 4294965296, # 5 | ||
64 | 1000, # 6 | ||
65 | 4294965296, # 7 | ||
66 | uint64("18446744073709351616"), # 8 | ||
67 | int(rand(2**32)), # 9 | ||
68 | 64000, # 10 | ||
69 | "stringtests", # 11 | ||
70 | "3.5", # 12 | ||
71 | "87.4startswithnumberbutshouldbestring", # 13 | ||
72 | '555"I said"', # 14 | ||
73 | 'CUSTOM CHECK OK: foo is 12345', # 15 | ||
74 | '-2', # 16 | ||
75 | '-4', # 17 | ||
76 | '-6.6', # 18 | ||
77 | 42 # 19 | ||
78 | ); | ||
38 | # undef increments are randomized | 79 | # undef increments are randomized |
39 | my @incrts = (undef, undef, undef, undef, undef, 1000, -500, 1000, 100000, undef, 666, undef, undef, undef, undef, undef, -1, undef, undef, 0 ); | 80 | my @incrts = ( |
81 | undef, # 0 | ||
82 | undef, # 1 | ||
83 | undef, # 2 | ||
84 | undef, # 3 | ||
85 | undef, # 4 | ||
86 | 1000, # 5 | ||
87 | -500, # 6 | ||
88 | 1000, # 7 | ||
89 | 100000, # 8 | ||
90 | undef, # 9 | ||
91 | 666, # 10 | ||
92 | undef, # 11 | ||
93 | undef, # 12 | ||
94 | undef, # 13 | ||
95 | undef, # 14 | ||
96 | undef, # 15 | ||
97 | -1, # 16 | ||
98 | 0, # 17 | ||
99 | undef, # 18 | ||
100 | 0 # 19 | ||
101 | ); | ||
40 | 102 | ||
41 | # Number of elements in our OID | 103 | # Number of elements in our OID |
42 | my $oidelts; | 104 | my $oidelts; |