diff options
Diffstat (limited to 'web/attachments/242023-check_ifstatus.patch')
-rw-r--r-- | web/attachments/242023-check_ifstatus.patch | 241 |
1 files changed, 241 insertions, 0 deletions
diff --git a/web/attachments/242023-check_ifstatus.patch b/web/attachments/242023-check_ifstatus.patch new file mode 100644 index 0000000..76f490d --- /dev/null +++ b/web/attachments/242023-check_ifstatus.patch | |||
@@ -0,0 +1,241 @@ | |||
1 | 1a2,12 | ||
2 | > # vim:foldmethod=syntax:tabstop=4:shiftwidth=4 | ||
3 | > # | ||
4 | > # matthew.martin, Tuesday August 14, 2007 | ||
5 | > # Problems with check_ifstatus.pl | ||
6 | > # 1) "No response from remote host" should be unknown, not critical, right? | ||
7 | > # 2) Serial link "dormant" should be critical, not okay | ||
8 | > # 3) dormant, excluded and unused interfaces are not correctly counted | ||
9 | > # 4) default exclusions were broken, fix that and add a couple default exclusions | ||
10 | > # 5) made the formatting in this file more consistent | ||
11 | > # | ||
12 | > # check_ifstatus.pl - nagios plugin | ||
13 | 3,4d13 | ||
14 | < # check_ifstatus.pl - nagios plugin | ||
15 | < # | ||
16 | 29c38 | ||
17 | < # | ||
18 | --- | ||
19 | > # | ||
20 | 36c45 | ||
21 | < use lib "/opt/csw/libexec/nagios-plugins" ; | ||
22 | --- | ||
23 | > use lib "/opt/csw/libexec/nagios-plugins"; | ||
24 | 49d57 | ||
25 | < | ||
26 | 94c102 | ||
27 | < my %excluded ; | ||
28 | --- | ||
29 | > my %excluded; | ||
30 | 97,100d104 | ||
31 | < | ||
32 | < | ||
33 | < | ||
34 | < | ||
35 | 103,104c107,108 | ||
36 | < print ("ERROR: No snmp response from $hostname (alarm timeout)\n"); | ||
37 | < exit $ERRORS{"UNKNOWN"}; | ||
38 | --- | ||
39 | > print ("ERROR: No snmp response from $hostname (alarm timeout)\n"); | ||
40 | > exit $ERRORS{"UNKNOWN"}; | ||
41 | 107,108c111 | ||
42 | < | ||
43 | < #Option checking | ||
44 | --- | ||
45 | > # Option checking | ||
46 | 111,112c114 | ||
47 | < if ($status != 0) | ||
48 | < { | ||
49 | --- | ||
50 | > if ($status != 0) { | ||
51 | 117d118 | ||
52 | < | ||
53 | 127,129d127 | ||
54 | < | ||
55 | < | ||
56 | < | ||
57 | 131,135c129,135 | ||
58 | < | ||
59 | < if (!defined($response = $session->get_table($snmpoid))) { | ||
60 | < $answer=$session->error; | ||
61 | < $session->close; | ||
62 | < $state = 'CRITICAL'; | ||
63 | --- | ||
64 | > if (!defined($response = $session->get_table($snmpoid))) { | ||
65 | > $answer=$session->error; | ||
66 | > $session->close; | ||
67 | > # matthew.martin. Tuesday August 14, 2007 | ||
68 | > # I think a SNMP error should give UNKNOWN, not CRITICAL | ||
69 | > #$state = 'CRITICAL'; | ||
70 | > $state = 'UNKNOWN'; | ||
71 | 138c138 | ||
72 | < }else{ | ||
73 | --- | ||
74 | > } else { | ||
75 | 141,142c141,142 | ||
76 | < exit $ERRORS{$state}; | ||
77 | < } | ||
78 | --- | ||
79 | > exit $ERRORS{$state}; | ||
80 | > } | ||
81 | 144,148c144,148 | ||
82 | < foreach $snmpkey (keys %{$response}) { | ||
83 | < $snmpkey =~ /.*\.(\d+)$/; | ||
84 | < $key = $1; | ||
85 | < $ifStatus{$key}{$snmpoid} = $response->{$snmpkey}; | ||
86 | < } | ||
87 | --- | ||
88 | > foreach $snmpkey (keys %{$response}) { | ||
89 | > $snmpkey =~ /.*\.(\d+)$/; | ||
90 | > $key = $1; | ||
91 | > $ifStatus{$key}{$snmpoid} = $response->{$snmpkey}; | ||
92 | > } | ||
93 | 151d150 | ||
94 | < | ||
95 | 155a155,156 | ||
96 | > # matthew.martin. This script cannot tell that specific logical interfaces are | ||
97 | > # associated with their phys IF so it checks them all. | ||
98 | 158c159,160 | ||
99 | < # skip unused interfaces | ||
100 | --- | ||
101 | > # Skip interfaces flagged with -u (--unused_ports) | ||
102 | > # "A comma separated list of ifIndex values that should be excluded" | ||
103 | 160,163c162,166 | ||
104 | < # check only if interface is administratively up | ||
105 | < if ($ifStatus{$key}{$snmpIfAdminStatus} == 1 ) { | ||
106 | < | ||
107 | < # check only if interface type is not listed in %excluded | ||
108 | --- | ||
109 | > | ||
110 | > # Further checking only if interface is administratively up | ||
111 | > if ($ifStatus{$key}{$snmpIfAdminStatus} == 1 ) { | ||
112 | > | ||
113 | > # Check only if interface type is not listed in %excluded | ||
114 | 170,172c173,175 | ||
115 | < $ifStatus{$key}{$snmpIfName}, | ||
116 | < $ifStatus{$key}{$snmpIfAlias}); | ||
117 | < }else{ | ||
118 | --- | ||
119 | > $ifStatus{$key}{$snmpIfName}, | ||
120 | > $ifStatus{$key}{$snmpIfAlias}); | ||
121 | > } else { | ||
122 | 174c177 | ||
123 | < $ifStatus{$key}{$snmpIfDescr}); | ||
124 | --- | ||
125 | > $ifStatus{$key}{$snmpIfDescr}); | ||
126 | 178c181,182 | ||
127 | < }else{ | ||
128 | --- | ||
129 | > # matthew.martin Interface is listed in %excluded | ||
130 | > } else { | ||
131 | 181c185,187 | ||
132 | < | ||
133 | --- | ||
134 | > # matthew.martin If not administratively up, mark as unused. | ||
135 | > } elsif ($ifStatus{$key}{$snmpIfAdminStatus} == 2 ) { | ||
136 | > $ifunused++; | ||
137 | 183,184c189,195 | ||
138 | < }else{ | ||
139 | < $ifunused++; | ||
140 | --- | ||
141 | > } else { | ||
142 | > # matthew.martin. Original line: | ||
143 | > # $ifunused++; | ||
144 | > # actually matches the flag | ||
145 | > # -u (--unused_ports) A comma separated list of ifIndex values that should be excluded | ||
146 | > # They should be marked as excluded, not unused. | ||
147 | > $ifexclude++; | ||
148 | 188,208c199,224 | ||
149 | < if ($ifdown > 0) { | ||
150 | < $state = 'CRITICAL'; | ||
151 | < $answer = sprintf("host '%s', interfaces up: %d, down: %d, dormant: %d, excluded: %d, unused: %d<BR>", | ||
152 | < $hostname, | ||
153 | < $ifup, | ||
154 | < $ifdown, | ||
155 | < $ifdormant, | ||
156 | < $ifexclude, | ||
157 | < $ifunused); | ||
158 | < $answer = $answer . $ifmessage . "\n"; | ||
159 | < } | ||
160 | < else { | ||
161 | < $state = 'OK'; | ||
162 | < $answer = sprintf("host '%s', interfaces up: %d, down: %d, dormant: %d, excluded: %d, unused: %d", | ||
163 | < $hostname, | ||
164 | < $ifup, | ||
165 | < $ifdown, | ||
166 | < $ifdormant, | ||
167 | < $ifexclude, | ||
168 | < $ifunused); | ||
169 | < } | ||
170 | --- | ||
171 | > # matthew.martin | ||
172 | > # The original has dormant serial interfaces return status of "OK". | ||
173 | > # A dormant serial connection should be CRITICAL, right? | ||
174 | > # I changed the following line to address this: | ||
175 | > #if ($ifdown > 0) { | ||
176 | > if (($ifdown > 0) || ($ifdormant > 0)) { | ||
177 | > $state = 'CRITICAL'; | ||
178 | > $answer = sprintf("host '%s', interfaces up: %d, down: %d, dormant: %d, excluded: %d, unused: %d<BR>", | ||
179 | > $hostname, | ||
180 | > $ifup, | ||
181 | > $ifdown, | ||
182 | > $ifdormant, | ||
183 | > $ifexclude, | ||
184 | > $ifunused); | ||
185 | > $answer = $answer . $ifmessage . "\n"; | ||
186 | > } else { | ||
187 | > $state = 'OK'; | ||
188 | > $answer = sprintf("host '%s', interfaces up: %d, down: %d, dormant: %d, excluded: %d, unused: %d", | ||
189 | > $hostname, | ||
190 | > $ifup, | ||
191 | > $ifdown, | ||
192 | > $ifdormant, | ||
193 | > $ifexclude, | ||
194 | > $ifunused); | ||
195 | > } | ||
196 | > | ||
197 | 248c264 | ||
198 | < printf " in hex with 0x prefix generated by using \"snmpkey\" utility\n"; | ||
199 | --- | ||
200 | > printf " in hex with 0x prefix generated by using \"snmpkey\" utility\n"; | ||
201 | 252c268 | ||
202 | < printf " in hex with 0x prefix generated by using \"snmpkey\" utility\n"; | ||
203 | --- | ||
204 | > printf " in hex with 0x prefix generated by using \"snmpkey\" utility\n"; | ||
205 | 323c339 | ||
206 | < }else{ | ||
207 | --- | ||
208 | > } else { | ||
209 | 326c342 | ||
210 | < }else{ | ||
211 | --- | ||
212 | > } else { | ||
213 | 338c354 | ||
214 | < }else{ | ||
215 | --- | ||
216 | > } else { | ||
217 | 341c357 | ||
218 | < }else{ | ||
219 | --- | ||
220 | > } else { | ||
221 | 370,371d385 | ||
222 | < }else{ | ||
223 | < $excluded{23} = 1; # default PPP(23) if empty list - note (AIX seems to think PPP is 22 according to a post) | ||
224 | 372a387,391 | ||
225 | > # matthew.martin, Tuesday August 14, 2007. In the original this else was nested wrong and never matched | ||
226 | > } else { | ||
227 | > $excluded{23} = 1; # default PPP(23) if empty list - note (AIX seems to think PPP is 22 according to a post) | ||
228 | > $excluded{24} = 1; # matthew.martin, Tuesday August 14, 2007, Nokia, ifDescr.6 = loop0c0 Software Loopback Layer -- ifType.6 = softwareLoopback(24) (taken from a Nokia IP330) | ||
229 | > $excluded{25} = 1; # matthew.martin, Tuesday August 14, 2007, Nokia, ifDescr.1 = pppoe0 Ethernet Layer -- ifType.1 = eon(25) (from a Nokia IP350) | ||
230 | 378c397 | ||
231 | < foreach $key (@unused_ports) { | ||
232 | --- | ||
233 | > foreach $key (@unused_ports) { | ||
234 | 392c411 | ||
235 | < }else{ | ||
236 | --- | ||
237 | > } else { | ||
238 | 450c469 | ||
239 | < }else{ | ||
240 | --- | ||
241 | > } else { | ||