File: cisco

package info (click to toggle)
logwatch 5.2.2-5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,112 kB
  • ctags: 42
  • sloc: perl: 9,032; sh: 65; makefile: 54
file content (401 lines) | stat: -rwxr-xr-x 13,900 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
#!/usr/bin/perl -w
##########################################################################
# $Id: cisco,v 1.2 2004/06/21 15:07:21 kirk Exp $
##########################################################################

########################################################
# This was written and is maintained by:
#    Laurent DUFOUR <laurent.dufour@havas.com>,<dufour_l@hotmail.com>
#    based on the work of
#    Kirk Bauer <kirk@kaybee.org>
#
# Please send all comments, suggestions, bug reports,
#    etc, to laurent.dufour@havas.com
########################################################

use Logwatch ':all';

$Detail = $ENV{'LOGWATCH_DETAIL_LEVEL'} || 0;

my ($month,$day,$time,$host,$process,$conn,$msg);

while (defined($ThisLine = <STDIN>)) {

($month,$day,$time,$host,$process,$conn,$msg)=split(/ +/,$ThisLine,7);

   if ( ($ThisLine =~ /(ISDN-6-.+)/ ) or
         ($ThisLine =~ /Copyright/ ) or 
         ($ThisLine =~ /Cisco Internetwork Operating System Software/ ) or 
         ($ThisLine =~ /IOS \(tm\)/ ) or 
         ($ThisLine =~ /accept udp/ ) or
         ($ThisLine =~ /accept tcp/ ) or
         ($ThisLine =~ /accept icmp/ ) or
         ($ThisLine =~ /accept ip/ ) or
         ($ThisLine =~ /denied udp/ ) or
         ($ThisLine =~ /denied tcp/ ) or
         ($ThisLine =~ /denied icmp/ ) or
         ($ThisLine =~ /denied ip/ )
    ) {
      # don't care about this, will code this later
   }
   elsif ( ($interface,$errortype,$withwho) = ($ThisLine =~ /duplex mismatch discovered on (.+) \(.*\), with (.*)/) ) {
      $DuplexMismatched{$host}{$interface," with ",$errortype}++;
   }
   elsif ( ($interface,$vlan_number,$withwho) = ($ThisLine =~ /Native VLAN mismatch discovered on (.+) \(([^ ]+)\), with ([^ ]+)/) ) {
      $VLANMismatched{$host}{$interface," vlan ",$vlan_number}++;
   }
   elsif ( ($interface) = ($ThisLine =~ /NVLANMISMATCH:Native vlan mismatch detected on port (.*)/) ) {
      $VLANMismatched{$host}{$interface}++;
   }
   elsif ( ($interface,$state) = ($ThisLine =~ /Interface (.+), changed state to (.*)/) ) {
      $InterfaceState{$host}{$interface," ",$state}++;
   }
   elsif ( ($interface,$state) = ($ThisLine =~ /Line protocol on Interface (.+), changed state to (.*)/) ) {
      $LineProtocolInterfaceState{$host}{$interface," ",$state}++;
   }
   elsif ( ($interface_experiencing_error) = ($ThisLine =~ /ERROR: (.*) is experiencing errors/) ) {
      $InterfaceError{$host}{$interface_experiencing_error}++;
   }
   elsif ( ($interface) = ($ThisLine =~ /DUPLEXMISMATCH:Full\/half duplex mismatch detected on port (.*)/) ) {
      $DuplexMismatched{$host}{$interface}++;
   }
   elsif ( ($interface,$state,$destination_port) = ($ThisLine =~ /PORTFROMSTP:Port (.+) (.+) bridge port (.*)/) ) {
      $PortStateBridge{$host}{$interface," ",$state," ",$destination_port}++;
   }
   elsif ( ($interface,$state,$destination_port) = ($ThisLine =~ /PORTTOSTP:Port (.+) (.+) bridge port (.*)/) ) {
      $PortStateBridge{$host}{$interface," ",$state," ",$destination_port}++;
   }
   elsif ( ($Unit) = ($ThisLine =~ /Unit (.*), excessive modem control changes/) ) {
    $ModemChange{$host}{$Unit}++;
   }
   elsif ( ($ThisLine =~ /Compiled/) ) {
      $Started{$host}++;
   }
   elsif ( ($message) = ($ThisLine =~ /RELOAD: (.*)/) ) {
      $ReloadRequested{$host}{$message}++;
   }
   elsif ( ($message) = ($ThisLine =~ /RESTART: (.*)/) ) {
      $Restarted{$host}{$message}++;
   }
   elsif ( ($interface) = ($ThisLine =~ /LOSTCARR: (.*)/) ) {
      $LostCarrier{$host}{$interface}++;
   }
   elsif ( ($interface) = ($ThisLine =~ /DUPADDR: (.*)/) ) {
      $DuplicateAddress{$host}{$interface}++;
   }
   elsif ( ($interface) = ($ThisLine =~ /TRUNKPORTON:Port (.*)/) ) {
      $TRUNKPORTON{$host}{$interface}++;
   }
   elsif ( ($interface) = ($ThisLine =~ /TRUNKPORTOFF:Port (.*)/) ) {
      $TRUNKPORTOFF{$host}{$interface}++;
   }
   elsif ( ($interface) = ($ThisLine =~ /EXCESSCOLL: (.*)/) ) {
      $ExcessiveCollision{$host}{$interface}++;
   }
   elsif ( ($interface) = ($ThisLine =~ /LATECOLL: (.*)/) ) {
      $LateCollision{$host}{$interface}++;
   }
   elsif ( ($interface) = ($ThisLine =~ /UNDERFLO: (.*)/) ) {
      $Underflow{$host}{$interface}++;
   }
   elsif ( ($interface) = ($ThisLine =~ /P2_WARN: (.*)/) ) {
      $InvalidMulticast{$host}{$interface}++;
   }
   elsif ( ($interface) = ($ThisLine =~ /CONFIG.+: (.*)/) ) {
      $Configured{$host}{$interface}++;
   }
   elsif ( ($interface) = ($ThisLine =~ /CONFIG: (.*)/) ) {
      $Configured{$host}{$interface}++;
   }
   elsif ( ($interface) = ($ThisLine =~ /LINK_FLAP: (.*)/) ) {
      $Flapping{$host}{$interface}++;
   }
   elsif ( ($interface) = ($ThisLine =~ /ERR_DISABLE: (.*)/) ) {
      $Flapping{$host}{$interface}++;
   }
   elsif ( ($interface) = ($ThisLine =~ /LOGIN_FAIL:User (.*)/) ) {
      $LoginFail{$host}{$interface}++; 
   }
   elsif ( ($interface) = ($ThisLine =~ /RSHPORTATTEMPT: (.*)/) ) {
      $RSHELLFail{$host}{$interface}++;
   }
   elsif ( ($interface) = ($ThisLine =~ /SPANTREE.+: (.*)/) ) {
      $SpantreeFailure{$host}{$interface}++;
   }
   elsif ( ($interface) = ($ThisLine =~ /DHCPD-4-DECLINE_CONFLICT: (.*)/) ) {
      $DHCPConflict{$host}{$interface}++;
   }
   elsif ( ($interface) = ($ThisLine =~ /COUNTERS: (.*)/) ) {
      $CountersMsg{$host}{$interface}++;
   }
   else {
      # Report any unmatched entries...
      push @OtherList,$ThisLine;
   }
}

if (keys %Started) {
   print "\nDevice started :\n";
   foreach $ThisOne (keys %Started) {
      print "   " . $ThisOne . ":\n";
      foreach $ThatOne (keys %{$Started{$ThisOne}}) {
         print "\t Started" .$ThatOne . "\t: " . $Started{$ThisOne} . " Time(s)\n";
      }
   }
}

if (keys %Restarted) {
   print "\nDevice restarted :\n";
   foreach $ThisOne (keys %Restarted) {
      print "   " . $ThisOne . ":\n";
      foreach $ThatOne (keys %{$Restarted{$ThisOne}}) {
         print "\t " .$ThatOne . "\t: " . $Restarted{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

if (keys %ReloadRequested) {
   print "\nDevice reload requested :\n";
   foreach $ThisOne (keys %ReloadRequested) {
      print "   " . $ThisOne . ":\n";
      foreach $ThatOne (keys %{$ReloadRequested{$ThisOne}}) {
         print "\t " .$ThatOne . "\t: " . $ReloadRequested{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}


if (keys %DuplexMismatched) {
   print "\nDuplex Mismatch warning:\n";
   foreach $ThisOne (keys %DuplexMismatched) {
      print "   " . $ThisOne . ":\n";
      foreach $ThatOne (keys %{$DuplexMismatched{$ThisOne}}) {
         print "\tPort or Interface " .$ThatOne . "\t: " . $DuplexMismatched{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

if (keys %VLANMismatched) {
   print "\nNative VLAN mismatch warning:\n";
   foreach $ThisOne (keys %VLANMismatched) {
      print "   " . $ThisOne . ":\n";
      foreach $ThatOne (keys %{$VLANMismatched{$ThisOne}}) {
         print "\tPort or Interface " .$ThatOne . "\t: " . $VLANMismatched{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

if (keys %TRUNKPORTON) {
   print "\nPort/Interface trunk on :\n";
   foreach $ThisOne (keys %TRUNKPORTON) {
      print "   " . $ThisOne . ":\n";
      foreach $ThatOne (keys %{$TRUNKPORTON{$ThisOne}}) {
         print "\tPort or Interface " .$ThatOne . "\t: " . $TRUNKPORTON{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

if (keys %TRUNKPORTOFF) {
   print "\nPort/Interface trunk off :\n";
   foreach $ThisOne (keys %TRUNKPORTOFF) {
      print "   " . $ThisOne . ":\n";
      foreach $ThatOne (keys %{$TRUNKPORTOFF{$ThisOne}}) {
         print "\tPort or Interface " .$ThatOne . "\t: " . $TRUNKPORTOFF{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

if (keys %PortStateBridge) {
   print "\nPort/Interface left/joined bridge :\n";
   foreach $ThisOne (keys %PortStateBridge) {
      print "   " . $ThisOne . ":\n";
      foreach $ThatOne (keys %{$PortStateBridge{$ThisOne}}) {
         print "\tPort or Interface " .$ThatOne . "\t: " . $PortStateBridge{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}


if (( $Detail >= 5 ) and (keys %InterfaceState)) {
   print "\nPort/Interface state change :\n";
   foreach $ThisOne (keys %InterfaceState) {
      print "   " . $ThisOne . ":\n";
      foreach $ThatOne (keys %{$InterfaceState{$ThisOne}}) {
         print "\tPort or Interface " .$ThatOne . "\t: " . $InterfaceState{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

if (keys %Flapping) {
   print "\nPort/Interface Flapping :\n";
   foreach $ThisOne (keys %Flapping) {
      print "   " . $ThisOne . ":\n";
      foreach $ThatOne (keys %{$Flapping{$ThisOne}}) {
         print "\tPort or Interface " .$ThatOne . "\t: " . $Flapping{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

if (keys %$DuplicateAddress) {
   print "\nPort/Interface duplicate address :\n";
   foreach $ThisOne (keys %$DuplicateAddress) {
      print "   " . $ThisOne . ":\n";
      foreach $ThatOne (keys %{$$DuplicateAddress{$ThisOne}}) {
         print "\t " .$ThatOne . "\t: " . $DuplicateAddress{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}


if (keys %InvalidMulticast) {
   print "\nPort/Interface invalid multicast :\n";
   foreach $ThisOne (keys %InvalidMulticast) {
      print "   " . $ThisOne . ":\n";
      foreach $ThatOne (keys %{$InvalidMulticast{$ThisOne}}) {
         print "\tPort or Interface " .$ThatOne . "\t: " . $InvalidMulticast{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

if (keys %SpantreeFailure) {
   print "\nPort/Interface spantree failure :\n";
   foreach $ThisOne (keys %SpantreeFailure) {
      print "   " . $ThisOne . ":\n";
      foreach $ThatOne (keys %{$SpantreeFailure{$ThisOne}}) {
         print "\t " .$ThatOne . "\t: " . $SpantreeFailure{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}



if (keys %LineProtocolInterfaceState) {
   print "\nLine protocol on Port/Interface changed state :\n";
   foreach $ThisOne (keys %LineProtocolInterfaceState) {
      print "   " . $ThisOne . ":\n";
      foreach $ThatOne (keys %{$LineProtocolInterfaceState{$ThisOne}}) {
         print "\tPort or Interface " .$ThatOne . "\t: " . $LineProtocolInterfaceState{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

if (keys %Underflow) {
   print "\nPort/Interface transmit error(underflow) :\n";
   foreach $ThisOne (keys %Underflow) {
      print "   " . $ThisOne . ":\n";
      foreach $ThatOne (keys %{$Underflow{$ThisOne}}) {
         print "\tPort or Interface " .$ThatOne . "\t: " . $Underflow{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

if (keys %LostCarrier) {
   print "\nPort/Interface transmit error (lost carrier) :\n";
   foreach $ThisOne (keys %LostCarrier) {
      print "   " . $ThisOne . ":\n";
      foreach $ThatOne (keys %{$LostCarrier{$ThisOne}}) {
         print "\t " .$ThatOne . "\t: " . $LostCarrier{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

if (keys %LateCollision) {
   print "\nPort/Interface transmit error (Late collision) :\n";
   foreach $ThisOne (keys %LateCollision) {
      print "   " . $ThisOne . ":\n";
      foreach $ThatOne (keys %{$LateCollision{$ThisOne}}) {
         print "\tPort or Interface " .$ThatOne . "\t: " . $LateCollision{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

if (keys %ExcessiveCollision) {
   print "\nPort/Interface Excessive collision :\n";
   foreach $ThisOne (keys %ExcessiveCollision) {
      print "   " . $ThisOne . ":\n";
      foreach $ThatOne (keys %{$ExcessiveCollision{$ThisOne}}) {
         print "\tPort or Interface " .$ThatOne . "\t: " . $ExcessiveCollision{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}


if (keys %InterfaceError) {
   print "\nPort/Interface experiencing error :\n";
   foreach $ThisOne (keys %InterfaceError) {
      print "   " . $ThisOne . ":\n";
      foreach $ThatOne (keys %{$InterfaceError{$ThisOne}}) {
         print "\tPort or Interface " .$ThatOne . "\t: " . $InterfaceError{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

if (keys %ModemChange) {
   print "\nExcessive modem control changes:\n";
   foreach $ThisOne (keys %ModemChange) {
      print "   " . $ThisOne . ":\n";
      foreach $ThatOne (keys %{$ModemChange{$ThisOne}}) {
         print "\tUnit " .$ThatOne . "\t: " . $ModemChange{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

if (keys %CountersMsg) {
   print "\nCounters chnages:\n";
   foreach $ThisOne (keys %CountersMsg) {
      print "   " . $ThisOne . ":\n";
      foreach $ThatOne (keys %{$CountersMsg{$ThisOne}}) {
         print "\t " .$ThatOne . "\t: " . $CountersMsg{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

if (keys %Configured) {
   print "\nDevice configured by :\n";
   foreach $ThisOne (keys %Configured) {
      print "   " . $ThisOne . ":\n";
      foreach $ThatOne (keys %{$Configured{$ThisOne}}) {
         print "\t " .$ThatOne . "\t: " . $Configured{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

if (keys %LoginFail) {
   print "\nLogin failed on device :\n";
   foreach $ThisOne (keys %LoginFail) {
      print "   " . $ThisOne . ":\n";
      foreach $ThatOne (keys %{$LoginFail{$ThisOne}}) {
         print "\t " .$ThatOne . "\t: " . $LoginFail{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

if (keys %RSHELLFail) {
   print "\nRemote Shell Login failed on device :\n";
   foreach $ThisOne (keys %RSHELLFail) {
      print "   " . $ThisOne . ":\n";
      foreach $ThatOne (keys %{$RSHELLFail{$ThisOne}}) {
         print "\t " .$ThatOne . "\t: " . $RSHELLFail{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}


if (keys %DHCPConflict) {
   print "\nDHCP Conflict on device :\n";
   foreach $ThisOne (keys %DHCPConflict) {
      print "   " . $ThisOne . ":\n";
      foreach $ThatOne (keys %{$DHCPConflict{$ThisOne}}) {
         print "\t " .$ThatOne . "\t: " . $DHCPConflict{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}


if ($#OtherList >= 0) {
   print "\n**Unmatched Entries**\n";
   print @OtherList;
}

exit(0);