File: netscreen

package info (click to toggle)
logwatch 7.14-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,572 kB
  • sloc: perl: 8,290; sh: 354; makefile: 38
file content (627 lines) | stat: -rw-r--r-- 22,694 bytes parent folder | download | duplicates (3)
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
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627

########################################################
# Please file all bug reports, patches, and feature
# requests under:
#      https://sourceforge.net/p/logwatch/_list/tickets
# and copy:
#    Laurent DUFOUR <laurent.dufour@havas.com>
# Help requests and discusion can be filed under:
#      https://sourceforge.net/p/logwatch/discussion/
########################################################

########################################################
# 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
########################################################

#####################################################
## Copyright (c) 2008 Laurent DUFOUR
## Covered under the included MIT/X-Consortium License:
##    http://www.opensource.org/licenses/mit-license.php
## All modifications and contributions by other persons to
## this script are assumed to have been donated to the
## Logwatch project and thus assume the above copyright
## and licensing terms.  If you want to make contributions
## under your own copyright or a different license this
## must be explicitly stated in the contribution an the
## Logwatch project reserves the right to not accept such
## contributions.  If you have made significant
## contributions to this script and want to claim
## copyright please contact logwatch-devel@lists.sourceforge.net.
#########################################################

use Logwatch ':all';
use strict;

my $Debug = ValueOrDefault($ENV{'LOGWATCH_DEBUG'}, 0);
my $Detail = ValueOrDefault($ENV{'LOGWATCH_DETAIL_LEVEL'}, 0);
my $DebugCounter = 0;

#Init String Containers
my (
$Temp,      $dst_ip,    $interface,
$src_ip,
);
#Init hashes
my (
%BadLogins,             %BadSPI,                %DHCPAssigned,
%DHCPReleased,          %DNSRefreshed,          %HeartBeatDisabled,
%HeartBeatLost,         %HeartBeatMissing,      %IllegalUsers,
%InitAggMode,           %InitMainMode,          %InitPh2,
%NTPFailed,             %NTPUpdated,            %NegoCompleted,
%Ph1Aborted,            %Ph1CompleteAggMode,    %Ph1CompleteMainMode,
%Ph1DstStartAggMode,    %Ph1DstStartMainMode,   %Ph2NegoAdded,
%Ph2NegoAlready,        %Ph2RcvMsg,             %ReceiveDOI,
%ReceivedDOI,           %ReloadRequested,       %Restarted,
%RetransmissionReached, %Started,               %SysCfgSaved,
%SyslogFacility,        %SyslogHost,            %Users,
%VPNDown,               %VPNUp,
);
#Init Array
my @OtherList = ();

# Avoid "Use of uninitialized value" warning messages.
sub ValueOrDefault {
    my ($value, $default) = @_;
    return ($value ? $value : $default);
}

if ( $Debug >= 5 ) {
    print STDERR "\n\nDEBUG: Inside NETSCREEN Filter \n\n";
    $DebugCounter = 1;
}


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

while (defined(my $ThisLine = <STDIN>)) {
    if ( $Debug >= 30 ) {
	print STDERR "DEBUG($DebugCounter): $ThisLine";
	$DebugCounter++;
    }

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

   if ( ($ThisLine =~ /traffic/ ) or
         ($ThisLine =~ /Copyright/ ) or
         ($ThisLine =~ /removed due to simultaneous rekey/ ) or
         ($ThisLine =~ /Responded to the first peer message/ ) or
         ($ThisLine =~ /NBR change/ ) 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) = ($ThisLine =~ /vpn "(.*)" is up./) ) {
      $VPNUp{$host}{$interface}++;
   }
   elsif ( ($interface) = ($ThisLine =~ /vpn "(.*)" is down./) ) {
      $VPNDown{$host}{$interface}++;
   }
   elsif ( ($src_ip,$dst_ip,$msg) = ($ThisLine =~ /IKE<(.+)> >> <(.+)> Phase 1: Initiated negotiations in aggressive mode. (.*)/) ) {
      $InitAggMode{$host}{$src_ip," ",$dst_ip}++;
   }
   elsif ( ($src_ip,$dst_ip,$msg) = ($ThisLine =~ /IKE<(.+)> >> <(.+)> Phase 1: Initiated negotiations in main mode. (.*)/) ) {
      $InitMainMode{$host}{$src_ip," ",$dst_ip}++;
   }
   elsif ( ($dst_ip,$msg) = ($ThisLine =~ /IKE<(.+)> Phase 2: Initiated negotiation. (.*)/) ) {
      $InitPh2{$host}{$dst_ip}++;
   }
   elsif ( ($dst_ip,$msg) = ($ThisLine =~ /IKE<(.+)> Phase 1: Completed Main mode negotiations (.*)/) ) {
      $Ph1CompleteMainMode{$host}{$dst_ip}++;
   }
   elsif ( ($dst_ip,$msg) = ($ThisLine =~ /IKE<(.+)> Phase 1: Aborted negotiations because the time limit has elapsed. (.*)/) ) {
      $Ph1Aborted{$host}{$dst_ip}++;
   }
   elsif ( ($dst_ip,$msg) = ($ThisLine =~ /IKE<(.+)> Phase 1: Completed Aggressive mode negotiations (.*)/) ) {
      $Ph1CompleteAggMode{$host}{$dst_ip}++;
   }
   elsif ( ($dst_ip,$msg) = ($ThisLine =~ /IKE<(.+)> Heartbeats have been disabled because the peer is not sending them. (.*)/) ) {
      $HeartBeatDisabled{$host}{LookupIP($dst_ip)}++;
   }
   elsif ( ($dst_ip,$msg) = ($ThisLine =~ /IKE<(.+)> Heartbeats have been lost (.*)/) ) {
      $HeartBeatLost{$host}{LookupIP($dst_ip)}++;
   }
   elsif ( ($dst_ip,$msg) = ($ThisLine =~ /IKE<(.+)> Received notify message for DOI (.*)/) ) {
      $ReceiveDOI{$host}{LookupIP($dst_ip)}++;
   }
   elsif ( ($dst_ip,$msg) = ($ThisLine =~ /IKE<(.+)> Missing heartbeats have exceeded the threshold. (.*)/) ) {
      $HeartBeatMissing{$host}{LookupIP($dst_ip)}++;
   }
   elsif ( ($dst_ip,$msg) = ($ThisLine =~ /IKE<(.+)>: Received a bad SPI (.*)/) ) {
      $BadSPI{$host}{$dst_ip}++;
   }
   elsif ( ($dst_ip,$msg) = ($ThisLine =~ /IKE<(.+)> Phase 1: Responder starts AGGRESSIVE mode negotiations. (.*)/) ) {
      $Ph1DstStartAggMode{$host}{$dst_ip}++;
   }
   elsif ( ($dst_ip,$msg) = ($ThisLine =~ /IKE<(.+)> Phase 1: Responder starts MAIN mode negotiations. (.*)/) ) {
      $Ph1DstStartMainMode{$host}{$dst_ip}++;
   }
   elsif ( ($dst_ip,$msg) = ($ThisLine =~ /IKE<(.+)> Added Phase 2 session tasks to the task list. (.*)/) ) {
      $Ph2NegoAdded{$host}{$dst_ip}++;
   }
   elsif ( ($dst_ip,$msg) = ($ThisLine =~ /IKE<(.+)> Phase 2 negotiation request is already in the task list. (.*)/) ) {
      $Ph2NegoAlready{$host}{$dst_ip}++;
   }
   elsif ( ($dst_ip,$msg) = ($ThisLine =~ /System Config saved from host (\d+\.\d+\.\d+\.\d+) (.*)/) ) {
      $SysCfgSaved{$host}{LookupIP($dst_ip)}++;
   }

   elsif ( ($dst_ip,$msg) = ($ThisLine =~ /The system configuration was saved from host (.+) by (.*)/) ) {
      $SysCfgSaved{$host}{LookupIP($dst_ip)}++;
   }
   elsif ( ($dst_ip,$msg) = ($ThisLine =~ /IKE<(.+)> Phase 2: Received a message but did not check a policy because id-mode is set to IP or policy-checking is disabled. (.*)/) ) {
      $Ph2RcvMsg{$host}{$dst_ip}++;
   }
   elsif ( ($ThisLine =~ /Compiled/) ) {
      $Started{$host}++;
   }
   elsif ( ($ThisLine =~ /Phase 1: Retransmission limit has been reached./) ) {
      $RetransmissionReached{$host}++;
   }
   elsif ( ($ThisLine =~ /Completed negotiations with SPI/) ) {
      $NegoCompleted{$host}++;
   }
   elsif ( ($ThisLine =~ /DNS entries have been automatically refreshed./) ) {
      $DNSRefreshed{$host}++;
   }
   elsif ( ($ThisLine =~ /DNS has been refreshed./) ) {
      $DNSRefreshed{$host}++;
   }
   elsif ( ($ThisLine =~ /Syslog host domain name has been changed/) ) {
      $SyslogHost{$host}++;
   }
   elsif ( ($ThisLine =~ /Syslog facility has been changed/) ) {
      $SyslogFacility{$host}++;
   }
   elsif ( ($ThisLine =~ /Syslog security facility has been changed/) ) {
      $SyslogFacility{$host}++;
   }
   elsif ( ($ThisLine =~ /The system clock has been updated through NTP./) ) {
      $NTPUpdated{$host}++;
   }
   elsif ( ($ThisLine =~ /failed to get clock through NTP/) ) {
      $NTPFailed{$host}++;
   }
   elsif ( ($message) = ($ThisLine =~ /A DHCP- assigned IP address (.*)/) ) {
      $DHCPAssigned{$host}{"A DHCP- assigned IP address"}++;
   }
   elsif ( ($message) = ($ThisLine =~ /One or more DHCP-assigned IP addresses have been manually released. (.*)/) ) {
      $DHCPReleased{$host}{"One or more DHCP-assigned IP addresses have been manually released."}++;
   }
   elsif ( ($message) = ($ThisLine =~ /RELOAD: (.*)/) ) {
      $ReloadRequested{$host}{$message}++;
   }
   elsif ( ($message) = ($ThisLine =~ /RESTART: (.*)/) ) {
      $Restarted{$host}{$message}++;
   }
   elsif ( ($interface) = ($ThisLine =~ /Admin User "(\S+)" logged in for Web\((\S+)\) management \(port (\d+)\) from (.+):(.+). (.*)/) ) {
       if ($Debug >= 5) {
	   print STDERR "DEBUG: Found -$1 logged in from $4 using $2\n";
       }
       if ($Detail >= 20) {
	   $Users{$host}{$2}{$4}{$1}++;
       } else {
	   $Users{$host}{$2}{$4}{"(all)"}++;
       }
   }
   elsif ( $ThisLine =~ m/Admin user (\S+) login attempt for (\S+) management \(port (\d+)\) from (.+):(.+). failed. (.*)/ ) {
       if ( $Debug >= 5 ) {
	   print STDERR "DEBUG: Found -Failed login- line\n";
       }
       my $name = LookupIP($4);
       $BadLogins{$host}{"$1/$2 from $name"}++;
   }
   elsif ( $ThisLine =~ m/SSH client at (.+) has attempted to make an SCS connection to interface untrust with IP (.+) but failed (.*)/ ) {
       my $name = LookupIP($2);
       $Temp = "SSH from $name";
       $BadLogins{$host}{$Temp}++;
       $IllegalUsers{$host}{$Temp}++;
   }
else {
      # Report any unmatched entries...
      push @OtherList,$ThisLine;
   }
}

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

if (keys %RetransmissionReached) {
   print "\nDevice where retransmission limit has been reached:\n";
   foreach my $ThisOne (keys %RetransmissionReached) {
      print "   " . $ThisOne . ":\n";
      foreach my $ThatOne (keys %{$RetransmissionReached{$ThisOne}}) {
         print "\t " .$ThatOne . "\t: " . $RetransmissionReached{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

if ( ( $Detail >= 15 ) and (keys %NegoCompleted) ) {
   print "\nDevice wich completed negotiations with SPI:\n";
   foreach my $ThisOne (keys %NegoCompleted) {
      print "   " . $ThisOne . ":\n";
      foreach my $ThatOne (keys %{$NegoCompleted{$ThisOne}}) {
         print "\t " .$ThatOne . "\t: " . $NegoCompleted{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

if (keys %NTPUpdated) {
   print "\nDevice where The system clock has been updated through NTP :\n";
   foreach my $ThisOne (keys %NTPUpdated) {
      print "   " . $ThisOne . ":\n";
      foreach my $ThatOne (keys %{$NTPUpdated{$ThisOne}}) {
         print "\t " .$ThatOne . "\t: " . $NTPUpdated{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

if (keys %NTPFailed) {
   print "\nDevice where failed to get clock through NTP :\n";
   foreach my $ThisOne (keys %NTPFailed) {
      print "   " . $ThisOne . ":\n";
      foreach my $ThatOne (keys %{$NTPFailed{$ThisOne}}) {
         print "\t " .$ThatOne . "\t: " . $NTPFailed{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

if (keys %DNSRefreshed) {
   print "\nDevice where DNS have been refreshed  :\n";
   foreach my $ThisOne (keys %DNSRefreshed) {
      print "   " . $ThisOne . ":\n";
      foreach my $ThatOne (keys %{$DNSRefreshed{$ThisOne}}) {
         print "\t " .$ThatOne . "\t: " . $DNSRefreshed{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

if (keys %DNSRefreshed) {
   print "\nDevice where DNS have been refreshed  :\n";
   foreach my $ThisOne (keys %DNSRefreshed) {
      print "   " . $ThisOne . ":\n";
      foreach my $ThatOne (keys %{$DNSRefreshed{$ThisOne}}) {
         print "\t " .$ThatOne . "\t: " . $DNSRefreshed{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

if ( ( $Detail >= 15 ) and (keys %DHCPAssigned) ) {
   print "\nDevice where DHCP have been assigned  :\n";
   foreach my $ThisOne (keys %DHCPAssigned) {
      print "   " . $ThisOne . ":\n";
      foreach my $ThatOne (keys %{$DHCPAssigned{$ThisOne}}) {
         print "\t " .$ThatOne . "\t: " . $DHCPAssigned{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

if ( ( $Detail >= 15 ) and (keys %DHCPReleased) ) {
   print "\nDevice where DHCP have been released  :\n";
   foreach my $ThisOne (keys %DHCPReleased) {
      print "   " . $ThisOne . ":\n";
      foreach my $ThatOne (keys %{$DHCPReleased{$ThisOne}}) {
         print "\t " .$ThatOne . "\t: " . $DHCPReleased{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

if (keys %SyslogFacility) {
   print "\nDevice where Syslog facility has been changed  :\n";
   foreach my $ThisOne (keys %SyslogFacility) {
      print "   " . $ThisOne . ":\n";
      foreach my $ThatOne (keys %{$SyslogFacility{$ThisOne}}) {
         print "\t " .$ThatOne . "\t: " . $SyslogFacility{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

if (keys %SyslogHost) {
   print "\nDevice where Syslog host has been changed  :\n";
   foreach my $ThisOne (keys %SyslogHost) {
      print "   " . $ThisOne . ":\n";
      foreach my $ThatOne (keys %{$SyslogHost{$ThisOne}}) {
         print "\t " .$ThatOne . "\t: " . $SyslogHost{$ThisOne}{$ThisOne} . " Time(s)\n";
      }
   }
}


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

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

if (keys %HeartBeatDisabled) {
   print "\nDevice where heartbeat have been disabled because of peer :\n";
   foreach my $ThisOne (keys %HeartBeatDisabled) {
      print "   " . $ThisOne . ":\n";
      foreach my $ThatOne (keys %{$HeartBeatDisabled{$ThisOne}}) {
         print "\t " .$ThatOne . "\t: " . $HeartBeatDisabled{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

if (keys %HeartBeatLost) {
   print "\nDevice where heartbeat have been lost :\n";
   foreach my $ThisOne (keys %HeartBeatLost) {
      print "   " . $ThisOne . ":\n";
      foreach my $ThatOne (keys %{$HeartBeatLost{$ThisOne}}) {
         print "\t " .$ThatOne . "\t: " . $HeartBeatLost{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

if (keys %HeartBeatMissing) {
   print "\nDevice where missing heartbeats have exceeded the threshold. :\n";
   foreach my $ThisOne (keys %HeartBeatMissing) {
      print "   " . $ThisOne . ":\n";
      foreach my $ThatOne (keys %{$HeartBeatMissing{$ThisOne}}) {
         print "\t " .$ThatOne . "\t: " . $HeartBeatMissing{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

if (keys %BadSPI) {
   print "\nDevice receiving a bad SPI :\n";
   foreach my $ThisOne (keys %BadSPI) {
      print "   " . $ThisOne . ":\n";
      foreach my $ThatOne (keys %{$BadSPI{$ThisOne}}) {
         print "\t " .$ThatOne . "\t: " . $BadSPI{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

if (keys %ReceivedDOI) {
   print "\nDevice where notify message for DOI hed been received :\n";
   foreach my $ThisOne (keys %ReceivedDOI) {
      print "   " . $ThisOne . ":\n";
      foreach my $ThatOne (keys %{$ReceivedDOI{$ThisOne}}) {
         print "\t " .$ThatOne . "\t: " . $ReceivedDOI{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

if (keys %VPNUp) {
   print "\nVPN Up on :\n";
   foreach my $ThisOne (keys %VPNUp) {
      print "   " . $ThisOne . ":\n";
      foreach my $ThatOne (keys %{$VPNUp{$ThisOne}}) {
         print "\t " .$ThatOne . "\t: " . $VPNUp{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

if (keys %VPNDown) {
   print "\nVPN Down on :\n";
   foreach my $ThisOne (keys %VPNDown) {
      print "   " . $ThisOne . ":\n";
      foreach my $ThatOne (keys %{$VPNDown{$ThisOne}}) {
         print "\t " .$ThatOne . "\t: " . $VPNDown{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

if ($Detail >= 15) {

if (keys %InitAggMode) {
   print "\nDevice initiating phase 1 aggressive mode:\n";
   foreach my $ThisOne (keys %InitAggMode) {
      print "   " . $ThisOne . ":\n";
      foreach my $ThatOne (keys %{$InitAggMode{$ThisOne}}) {
         print "\t " .$ThatOne . "\t: " . $InitAggMode{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

if (keys %InitMainMode) {
   print "\nDevice initiating phase 1 main mode:\n";
   foreach my $ThisOne (keys %InitMainMode) {
      print "   " . $ThisOne . ":\n";
      foreach my $ThatOne (keys %{$InitMainMode{$ThisOne}}) {
         print "\t " .$ThatOne . "\t: " . $InitMainMode{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

if (keys %Ph1DstStartAggMode) {
   print "\nDevice with Phase 1: Responder starts AGGRESSIVE mode negotiations. :\n";
   foreach my $ThisOne (keys %Ph1DstStartAggMode) {
      print "   " . $ThisOne . ":\n";
      foreach my $ThatOne (keys %{$Ph1DstStartAggMode{$ThisOne}}) {
         print "\t " .$ThatOne . "\t: " . $Ph1DstStartAggMode{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

if (keys %Ph1DstStartMainMode) {
   print "\nDevice with Phase 1: Responder starts MAIN mode negotiations. :\n";
   foreach my $ThisOne (keys %Ph1DstStartMainMode) {
      print "   " . $ThisOne . ":\n";
      foreach my $ThatOne (keys %{$Ph1DstStartMainMode{$ThisOne}}) {
         print "\t " .$ThatOne . "\t: " . $Ph1DstStartMainMode{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}


if (keys %Ph1CompleteAggMode) {
   print "\nDevice with Phase 1: Completed Aggressive mode negotiations :\n";
   foreach my $ThisOne (keys %Ph1CompleteAggMode) {
      print "   " . $ThisOne . ":\n";
      foreach my $ThatOne (keys %{$Ph1CompleteAggMode{$ThisOne}}) {
         print "\t " .$ThatOne . "\t: " . $Ph1CompleteAggMode{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

if (keys %Ph1CompleteMainMode) {
   print "\nDevice with Phase 1: Completed Main mode negotiations :\n";
   foreach my $ThisOne (keys %Ph1CompleteMainMode) {
      print "   " . $ThisOne . ":\n";
      foreach my $ThatOne (keys %{$Ph1CompleteMainMode{$ThisOne}}) {
         print "\t " .$ThatOne . "\t: " . $Ph1CompleteMainMode{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

if (keys %Ph1Aborted) {
   print "\nDevice with Phase 1: Aborted negotiations because the time limit has elapsed. :\n";
   foreach my $ThisOne (keys %Ph1Aborted) {
      print "   " . $ThisOne . ":\n";
      foreach my $ThatOne (keys %{$Ph1Aborted{$ThisOne}}) {
         print "\t " .$ThatOne . "\t: " . $Ph1Aborted{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

if (keys %InitPh2) {
   print "\nDevice initiating phase 2 :\n";
   foreach my $ThisOne (keys %InitPh2) {
      print "   " . $ThisOne . ":\n";
      foreach my $ThatOne (keys %{$InitPh2{$ThisOne}}) {
         print "\t " .$ThatOne . "\t: " . $InitPh2{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

if (keys %Ph2NegoAdded) {
   print "\nDevice with Added Phase 2 session tasks to the task list. :\n";
   foreach my $ThisOne (keys %Ph2NegoAdded) {
      print "   " . $ThisOne . ":\n";
      foreach my $ThatOne (keys %{$Ph2NegoAdded{$ThisOne}}) {
         print "\t " .$ThatOne . "\t: " . $Ph2NegoAdded{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

if (keys %Ph2NegoAlready) {
   print "\nDevice with Phase 2 negotiation request is already in the task list. :\n";
   foreach my $ThisOne (keys %Ph2NegoAlready) {
      print "   " . $ThisOne . ":\n";
      foreach my $ThatOne (keys %{$Ph2NegoAlready{$ThisOne}}) {
         print "\t " .$ThatOne . "\t: " . $Ph2NegoAlready{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

if (keys %Ph2RcvMsg) {
   print "\nDevice with Phase 2: Received a message but did not check a policy because id-mode is set to IP or policy-checking is disabled. :\n";
   foreach my $ThisOne (keys %Ph2RcvMsg) {
      print "   " . $ThisOne . ":\n";
      foreach my $ThatOne (keys %{$Ph2RcvMsg{$ThisOne}}) {
         print "\t " .$ThatOne . "\t: " . $Ph2RcvMsg{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}

}


if (keys %SysCfgSaved) {
   print "\nDevice where system config have been saved :\n";
   foreach my $ThisOne (keys %SysCfgSaved) {
      print "   " . $ThisOne . ":\n";
      foreach my $ThatOne (keys %{$SysCfgSaved{$ThisOne}}) {
         print "\t " .$ThatOne . "\t: " . $SysCfgSaved{$ThisOne}{$ThatOne} . " Time(s)\n";
      }
   }
}



if (keys %BadLogins) {
    print "\nFailed logins from these:\n";
    foreach my $ThisOne (keys %BadLogins) {
	    print "   " . $ThisOne . ":\n";
	    for (sort keys %{$BadLogins{$ThisOne}}) {
	        print "\t   $_: $BadLogins{$ThisOne}{$_} Time(s)\n";
	    }
    }
}

if (keys %IllegalUsers) {
    print "\nIllegal users from these:\n";
    foreach my $ThisOne (keys %IllegalUsers) {
	    print "   " . $ThisOne . ":\n";
    	for (sort keys %{$IllegalUsers{$ThisOne}}) {
	        print "\t   $_: $IllegalUsers{$ThisOne}{$_} Time(s)\n";
	    }
    }
}


if (keys %Users) {
    print "\nUsers logging in through :\n";
    foreach my $ThisOne (keys %Users) {
        print "   " . $ThisOne . ":\n";

        foreach my $user (sort {$a cmp $b} keys %{$Users{$ThisOne}}) {
            print "   $user:\n";
            my $totalSort = TotalCountOrder(%{$Users{$ThisOne}{$user}}, \&SortIP);
            foreach my $ip (sort $totalSort keys %{$Users{$ThisOne}{$user}}) {
	            my $name = LookupIP($ip);
	            if ($Detail >= 20) {
                    print "      $name:\n";
                    my $sort = CountOrder(%{$Users{$ThisOne}{$user}{$ip}});
                    foreach my $method (sort $sort keys %{$Users{$ThisOne}{$user}{$ip}}) {
		                my $val = $Users{$ThisOne}{$user}{$ip}{$method};
		                my $plural = ($val > 1) ? "s" : "";
		                print "         $method: $val time$plural\n";
                    }
	            } else {
                    my $val = (values %{$Users{$ThisOne}{$user}{$ip}})[0];
                    my $plural = ($val > 1) ? "s" : "";
                    print "      $name: $val time$plural\n";
	            }
            }
        }
    }
}


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

exit(0);
# Local Variables:
# mode: perl
# perl-indent-level: 3
# indent-tabs-mode: nil
# End: