Codebase list logwatch / 75be1f8
Import upstream version 7.5.5 Willi Mann authored 3 years ago Debian Janitor committed 3 years ago
29 changed file(s) with 339 addition(s) and 451 deletion(s). Raw diff Collapse all Expand all
340340 When specifying filenames for either the LogFile or Archive statements,
341341 you can use standard regexps (for example, *, ?, or [0-9]). In addition,
342342 filenames with spaces are possible by enclosing them in single quotes.
343 Similarly, filename case can be preserved by quoting the filename.
344 Single-quoted strings do not expand regexp characters; double-quoted
345 strings do.
343346
344347 For either the LogFile or Archive statements, the corresponding files
345348 need not exist. In that case, the statement is ignored. Because of this,
0 Copyright (c) 2002-2018 Kirk Bauer
0 Copyright (c) 2002-2021 Kirk Bauer
11
22 Permission is hereby granted, free of charge, to any person obtaining a copy of
33 this software and associated documentation files (the "Software"), to deal in
00 <!-- Start footer.html -->
11 <div class=\"copyright\">
22 <hr>
3 <p>Logwatch &copy;Copyright 2002-2006 Kirk Bauer</p>
3 <p>Logwatch &copy;Copyright 2002-2021 Kirk Bauer</p>
44 <p>
55 Permission is hereby granted, free of charge, to any person obtaining a copy of
66 this software and associated documentation files (the "Software"), to deal in
77 h2 {color: white; border-bottom: 1px solid silver; font-family: sans-serif; }
88 h3 {color: white; border-bottom: 1px solid silver; font-family: sans-serif; }
99 th {background: #6D88AD; text-align: left; font-family: sans-serif; }
10 td {background: #EFEFEF; text-align: left; font-family: courier,serif; font-size: 10px; }
10 td {background: #EFEFEF; text-align: left; font-family: monospace; font-size: 10px; }
1111 li { font-family: sans-serif; }
1212 .ref {padding-left: 1%; }
1313 .service {padding-left: 1%; }
00 # What actual file? Defaults to LogPath if not absolute path....
11 LogFile = dnf.rpm.log
22
3 # Logrotate format
34 Archive = dnf.rpm.log-*
5 # DNF internal rotation format
6 Archive = dnf.rpm.log.*
47
58 # Keep only the lines in the proper date range...
69 *ApplyStdDate = "%b %d %H:%M:%S"
1313 LogFile = messages
1414
1515 # Only give lines pertaining to the OMSA service...
16 *OnlyService = lvm
16 *OnlyService = "(?:lvm|dmeventd)"
1717 *RemoveHeaders
1818
1919 #########################################################
4242 # specified threshold
4343 #$illegal_users_threshold = 4
4444
45 # Set to No to disable IP lookups
46 $sshd_ip_lookup = Yes
47
4548
4649 ########################################################
4750 # This was written and is maintained by:
00 Summary: Analyzes and Reports on system logs
11 Name: logwatch
2 Version: 7.5.4
2 Version: 7.5.5
33 Release: 1
44 License: MIT
55 Group: Applications/System
99
1010 ########################################################
1111 # Specify version and build-date:
12 my $Version = '7.5.4';
13 my $VDate = '07/22/20';
12 my $Version = '7.5.5';
13 my $VDate = '01/22/21';
1414
1515 #######################################################
1616 # Logwatch was originally written by:
291291 if ( $Config{'encode'} eq "base64" ) {
292292 eval "require MIME::Base64";
293293 if ($@) {
294 print STDERR "No MIME::Base64 installed can not use --encode\n";
294 print STDERR "No MIME::Base64 installed; can not use --encode\n";
295295 } else {
296296 import MIME::Base64;
297297 }
12011201 if ( $Config{'encode'} eq "base64" ) {
12021202 $out_mime .= "Content-transfer-encoding: base64\n";
12031203 } else {
1204 $out_mime .= "Content-Transfer-Encoding: 7bit\n";
1204 $out_mime .= "Content-Transfer-Encoding: 8bit\n";
12051205 }
12061206 #Config{output} html
12071207 if ( $Config{'format'} eq "html" ) {
15121512 #Printing starts here $out_mime $out_head $out_reference $out_body $out_foot
15131513 if (defined fileno OUTFILE) {
15141514 print OUTFILE $out_mime if $out_mime;
1515 if ( $Config{'encode'} eq "base64" ) {
15161515 my $out = '';
15171516 $out .= $out_head if $out_head;
15181517 $out .= $out_reference if $out_reference;
15211520 $out_body{$_} = ''; #We should track this down out_body could be an array instead also -mgt
15221521 }
15231522 $out .= $out_foot if $out_foot;
1523 if ( $Config{'encode'} eq "base64" ) {
15241524 print OUTFILE encode_base64($out);
15251525 } else {
1526 print OUTFILE $out_head if $out_head;
1527 print OUTFILE $out_reference if $out_reference;
1528 foreach ( 0 .. $index_par ) {
1529 print OUTFILE $out_body{$_} if defined( $out_body{$_} );
1530 $out_body{$_} = '';
1531 }
1532 print OUTFILE $out_foot if $out_foot;
1526 print OUTFILE $out;
15331527 }
15341528 }
15351529 #ends here
3535 use strict;
3636 use Logwatch ':all';
3737
38 my (%denials, %grants, %loads);
38 my (%denials, %allowed, %loads);
3939 my %OtherList;
4040 my $othercount = 0;
4141 my $Debug = ($ENV{'LOGWATCH_DEBUG'} || 0);
5454 my $ThisLine;
5555 my %Warning = ();
5656 my %AuditctlStatus = ();
57 my %unconfineds = ();
5758
5859 print STDERR "\n\nDEBUG: Inside audit filter\n\n" if ( $Debug >= 5 );
5960
127128 $AuditctlStatus{$status}++;
128129 } elsif ( $ThisLine =~ /audit\([0-9]+\.[0-9]+:[0-9]+\): apparmor=/) {
129130 # AppArmor
130 if ( $ThisLine =~ /apparmor="STATUS" operation="profile_(load|replace)" name="([^"]+)"/ ) {
131 if ( $ThisLine =~ /apparmor="STATUS" operation="profile_(load|replace)" (?:profile="unconfined")?name="([^"]+)"/ ) {
131132 # type=1400 audit(1314853473.168:33616): apparmor="STATUS" operation="profile_replace" name="/usr/lib/apache2/mpm-prefork/apache2//DEFAULT_URI" pid=26566 comm="apparmor_parser"
132133 $loads{$2}++;
133 } elsif ( $ThisLine =~ /apparmor="DENIED" operation="([^"]+)" parent=\d+ profile="([^"]+)" name="([^"]+)" pid=\d+ comm="([^"]+)"/ ) {
134 } elsif ( $ThisLine =~ /apparmor="STATUS" operation="profile_(load|replace)" profile="unconfined" name="([^"]+)"/ ) {
135 # type=1400 audit(1462209116.753:18): apparmor="STATUS" operation="profile_replace" profile="unconfined" name="/usr/sbin/named" pid=22094 comm="apparmor_parser"
136 # type=1400 audit(1462209262.641:2): apparmor="STATUS" operation="profile_load" profile="unconfined" name="/usr/bin/freshclam" pid=1760 comm="apparmor_parser"
137 $unconfineds{$2}++;
138 } elsif ( $ThisLine =~ /apparmor="DENIED" operation="([^"]+)" (?:parent=\d+ )?profile="([^"]+)" name="([^"]+)" pid=\d+ comm="([^"]+)"/ ) {
134139 # type=1400 audit(1314853822.672:33649): apparmor="DENIED" operation="mknod" parent=27250 profile="/usr/lib/apache2/mpm-prefork/apache2//example.com" name="/usr/share/wordpress/1114140474e5f13bea68a4.tmp" pid=27289 comm="apache2" requested_mask="c" denied_mask="c" fsuid=33 ouid=33
135140 # type=1400 audit(1315353795.331:33657): apparmor="DENIED" operation="exec" parent=14952 profile="/usr/lib/apache2/mpm-prefork/apache2//example.com" name="/usr/lib/sm.bin/sendmail" pid=14953 comm="sh" requested_mask="x" denied_mask="x" fsuid=33 ouid=0
141 # type=1400 audit(1597683992.796:8057): apparmor="DENIED" operation="exec" profile="/usr/bin/evince" name="/usr/lib/uim/uim-helper-server" pid=1687330 comm="evince" requested_mask="x" denied_mask="x" fsuid=1000 ouid=0: 1 Time(s)
136142 $denials{$1.' '.$3.' ('.$2.' via '.$4 . ')'}++;
143 } elsif ( $ThisLine =~ /apparmor="DENIED" operation="([^"]+)" info="([^"]+)" error=-*[0-9]+ profile="([^"]+)" name="([^"]+)" pid=\d+ comm="([^"]+)"/ ) {
144 # type=1400 audit(1597690743.153:8073): apparmor="DENIED" operation="mount" info="failed flags match" error=-13 profile="lxd-open-iscsi-review-mp389234-groovy_</var/snap/lxd/common/lxd>" name="/run/" pid=1694826 comm="mount" flags="rw, nosuid, nodev, remount": 1 Time(s)
145 $denials{$1.' '.$4.' ('.$3.' via '.$5 .': '.$2. ')'}++;
137146 } elsif ( $ThisLine =~ /apparmor="ALLOWED" operation="([^"]+)" (info="([^"]+)" )?(error=[+-]?\d+ )?(parent=\d+ )?profile="([^"]+)" (name="([^"]+)" )?pid=\d+ comm="([^"]+)"/ ) {
138147 # type=1400 audit(1369519203.141:259049): apparmor="ALLOWED" operation="exec" parent=3733 profile="/usr/sbin/dovecot//null-1c//null-1d" name="/usr/lib/dovecot/pop3-login" pid=24634 comm="dovecot" requested_mask="x" denied_mask="x" fsuid=0 ouid=0 target="/usr/sbin/dovecot//null-1c//null-1d//null-d12"
139148 # type=1400 audit(1369627891.522:447576): apparmor="ALLOWED" operation="capable" parent=1 profile="/usr/sbin/dovecot//null-1c//null-1d" pid=3733 comm="dovecot" capability=5 capname="kill"
148157 if ( $ThisLine =~ /avc:\s*denied\s*{\s*([^}]+).*scontext=(\S+)\s*tcontext=(\S+)\s*tclass=(\S+)/ ) {
149158 $denials{$2.' '.$3.' ('.$1.$4 . ')'}++;
150159 } elsif ( $ThisLine =~ /avc:\s*granted\s*{\s*([^}]+).*scontext=(\S+)\s*tcontext=(\S+)\s*tclass=(\S+)/ ) {
151 $grants{$2.' '.$3.' ('.$1.$4 . ')'}++;
160 $allowed{$2.' '.$3.' ('.$1.$4 . ')'}++;
152161 } elsif ($ThisLine =~ /security_compute_sid:\s*invalid context\s*(\S+)\s*for\s*scontext=(\S+)\s*tcontext=(\S+)\s*tclass=(\S+)/ ) {
153162 $InvalidContext{$4." running as ".$2." acting on ".$3." \nshould transit to invalid ".$1}++;
154163 } elsif ($ThisLine =~ /security_sid_mls_copy:\s*invalid context\s*(\S+)/) {
161170 if ( $ThisLine =~ /avc:\s*denied\s*{\s*[^}]+.*scontext=(\S+)\s*tcontext=(\S+)\s*tclass=(\S+)/ ) {
162171 $denials{$1.' '.$2.' ('.$3 . ')'}++;
163172 } elsif ( $ThisLine =~ /avc:\s*granted\s*{\s*[^}]+}.*scontext=(\S+)\s*tcontext=(\S+)\s*tclass=(\S+)/ ) {
164 $grants{$1.' '.$2.' ('.$3 . ')'}++;
173 $allowed{$1.' '.$2.' ('.$3 . ')'}++;
165174 } elsif ($ThisLine =~ /security_compute_sid:\s*invalid context\s*(\S+)\s*for\s*scontext=(\S+)\s*tcontext=\S+\s*tclass=(\S+)/ ) {
166175 $InvalidContext{$3." running as ".$2." should transit to invalid ".$1}++;
167176 } elsif ($ThisLine =~ /security_sid_mls_copy:\s*invalid context\s*(\S+)/) {
174183 if ( $ThisLine =~ /avc:\s*denied\s*{\s*[^}]+.*scontext=([^:]+):[^:]+:\S+\s*tcontext=([^:]+):[^:]+:\S+\s*tclass=(\S+)/ ) {
175184 $denials{$1.' '.$2.' ('.$3 . ')'}++;
176185 } elsif ( $ThisLine =~ /avc:\s*granted\s*{\s*[^}]+.*scontext=([^:]+):[^:]+:\S+\s*tcontext=([^:]+):[^:]+:\S+\s*tclass=(\S+)/ ) {
177 $grants{$1.' '.$2.' ('.$3 . ')'}++;
186 $allowed{$1.' '.$2.' ('.$3 . ')'}++;
178187 } elsif ($ThisLine =~ /security_compute_sid:\s*invalid context\s*(\S+)\s*for\s*scontext=(\S+)\s*tcontext=\S+\s*tclass=(\S+)/ ) {
179188 $InvalidContext{$3." running as ".$2." should transit to invalid ".$1}++;
180189 } elsif ($ThisLine =~ /security_sid_mls_copy:\s*invalid context\s*(\S+)/) {
199208 }
200209 }
201210
202 if ( keys %grants ) {
203 print "\n\n*** Grants ***\n";
204 foreach my $key (sort keys %grants) {
205 print " $key: ". $grants{$key} . " times\n";
211 if ( keys %allowed ) {
212 print "\n\n*** Allowed ***\n";
213 foreach my $key (sort keys %allowed) {
214 print " $key: ". $allowed{$key} . " times\n";
206215 }
207216 }
208217
219228 print " $key: ". $loads{$key} . " times\n";
220229 }
221230 }
222
223231
224232 if ($Detail and $NumberOfDStarts+$NumberOfDStartsPid) {
225233 print "\n Number of audit daemon starts: ",$NumberOfDStarts+$NumberOfDStartsPid," \n";
5757 ( $ThisLine =~ /^Unix socket file/ ) or
5858 ( $ThisLine =~ /^Protecting against \d+ viruses\./ ) or
5959 ( $ThisLine =~ /^Reading databases from/ ) or
60 ( $ThisLine =~ /^Activating the newly loaded database/ ) or
6061 ( $ThisLine =~ /file removed\./ ) or
6162 ( $ThisLine =~ / (?:dis|en)abled\.$/ ) or
6263 ( $ThisLine =~ /^Archive/ ) or
7878 ($line =~ /^Solicit message from/) or
7979 ($line =~ /^Sending Advertise to/) or
8080 ($line =~ /^pool [0-9a-f]+ /) or
81 ($line =~ /^[^ ]* file: /)
81 ($line =~ /^[^ ]* file: /) or
82 ($line =~ /^reuse_lease: lease age \d+ \(secs\) under \d+\% threshold, reply with unaltered, existing lease for/) or
83 0 # noop, but makes diffs easier when appending ignore statements
8284 ) {
8385 # Ignore these lines
8486 } elsif ($line =~ s/Listening on\s+//) {
118120 ($line =~ /^of the dhcpd.conf file\./)
119121 ) {
120122 # Do nothing
123 } elsif ($line =~ /lease age \d+ \(secs\) under \d+% threshold, reply with unaltered, existing lease/) {
124 # Do nothing
121125
122126 } elsif ($line =~ s/^exiting./DHCP server exiting./) {
123127 $data{'Generic error'}{$line}++;
7474 my %ProxyLoginIMAP;
7575 my %ProxyLoginPOP3;
7676 my %SieveLogin;
77 my %UnknownUsers;
7778 my %VacationDup;
7879 my %VacationResponse;
7980
114115 my $dovecottag = qr/dovecot(?:\[\d+\])?:(?:\s*\[[^]]+\])?/;
115116
116117 while (defined(my $ThisLine = <STDIN>)) {
117 # The *RemoveHeaders script is now invoked in the service configuration file
118 # so this next line is no longer needed
119 #$ThisLine =~ s/^\w{3} .\d \d\d:\d\d:\d\d (?:[^\s:]* |)//;
120118 if ( ($ThisLine =~ /(?:ssl-build-param|ssl-params): SSL parameters regeneration completed/) or
121119 ($ThisLine =~ /ssl-params: Generating SSL parameters/) or
122120 ($ThisLine =~ /auth-worker/) or
170168 $ConnectionSieve{$Host}++;
171169 $Connection{$Host}++;
172170 }
171 } elsif (my ($User) = ( $ThisLine =~ /auth: (?:pam|passwd-file)\((.*),.*\): unknown user/ ) ) {
172 $UnknownUsers{$User}++;
173173
174174 # 'lda' for dovecot 2.0, 'deliver' for earlier versions
175175 } elsif (my ($User, $Mailbox) = ( $ThisLine =~ /^$dovecottag (?:lda|deliver)\((.*)\)(?:<[^>]+><[^>]+>)?: msgid=.*: saved mail to (.*)/ ) ) {
656656 }
657657 }
658658
659 if (keys %UnknownUsers) {
660 my $UserCount = 0;
661 foreach my $User (keys %UnknownUsers) {
662 $UserCount += $UnknownUsers{$User};
663 }
664 print "\n\nUnknown users blocked: $UserCount Total\n";
665 if ($Detail >= 10) {
666 foreach my $User (sort keys %UnknownUsers) {
667 print " $UnknownUsers{$User} $User\n";
668 }
669 }
670 }
671
659672 if (keys %OtherList) {
660673 print "\n\n**Unmatched Entries**\n";
661674 foreach my $line (sort {$a cmp $b} keys %OtherList) {
9292 $KeepEnv++ if $MatchedDate;
9393 next;
9494 }
95 if ( $ThisLine =~ /^ Suggested action: either install a certificate or change tls_advertise_hosts option/ ) {
96 push @SelfSignedH, $ThisLine;
97 next;
98 }
9599 $BadFormat{$ThisLine}++;
96100 next;
97101 } unless ($year1,$month1,$day1,$h1,$m1,$s1) = ($ThisLine =~ /^(\d+)\-(\d+)\-(\d+)\s(\d+):(\d+):(\d+)\s.+/);
264268 elsif ( $ThisLine =~ /no IP address found for host/ ) {
265269 $Lookup++;
266270 push @LookupH, $ThisLine;
271 }
272 elsif ( $ThisLine =~ /No server certificate defined; will use a selfsigned one/ ) {
273 $SelfSigned++;
274 push @SelfSignedH, $ThisLine;
267275 }
268276 elsif ( $ThisLine =~ /DKIM: .* \[verification succeeded\]/ ) {
269277 # Ignore successful DKIM verification reports
317325 $StartQueue and print " Start queue run: $StartQueue Time(s)\n";
318326 # End Queue
319327 $EndQueue and print " End queue run: $EndQueue Time(s)\n";
328 }
329 }
330
331 if (@SelfSignedH) {
332 print "\n--- Self-Signed Certificate in use ($SelfSigned Time(s))\n";
333
334 if ($Detail >= $LvlMsgs) {
335 foreach $ThisOne (@SelfSignedH) {
336 print "$ThisOne\n";
337 }
320338 }
321339 }
322340
748766 }
749767 }
750768 }
769
751770 }
752771 }
753772
6565 ($ThisLine =~ /INFO\s+(Set |Socket|Exiting|Gamin|Created|Added|Using|Connected to |rollover performed)/) or # syntax of 0.7.? fail2ban
6666 ($ThisLine =~ /..,... WARNING: Verbose level is /) or
6767 ($ThisLine =~ /..,... WARNING: Restoring firewall rules/) or
68 ($ThisLine =~ /WARNING Determined IP using DNS Lookup: [^ ]+ = \['[^']+'\]/) or
68 ($ThisLine =~ /WARNING Determined IP using DNS Lookup/) or
6969 ($ThisLine =~ /INFO\s+(Stopping all jails|Exiting Fail2ban)/) or
7070 ($ThisLine =~ /INFO\s+Initiated '.*' backend/) or
7171 ($ThisLine =~ /INFO\s+(Added logfile = .*|Set maxRetry = \d+|Set findtime = \d+|Set banTime = \d+)/) or
3636 my %MonitoringOff;
3737 my %MonitoringSnapshot;
3838 my %MonitoringSnapshotOff;
39 my %Resize;
3940 my %OtherList;
4041
4142 while (defined(my $ThisLine = <STDIN>)) {
4647 or $ThisLine =~ /pvscan\[\d+\] VG .* run autoactivation/
4748 # This happens often at startup
4849 or $ThisLine =~ /^WARNING: lvmetad is being updated, retrying/
50 # This happens when dmeventd autostarted
51 or $ThisLine =~ /dmeventd ready for processing\.$/
52 or $ThisLine =~ /dmeventd shutting down\.$/
53 or $ThisLine =~ /dmeventd was idle for .*, exiting\.$/
54 # Misc cleanups
55 or $ThisLine =~ /Logical volume .* successfully resized/
4956 ) {
5057 # Ignore
5158 } elsif ($ThisLine =~ /^(?:WARNING: )?Thin (\S+) is now (\d+(\.\d+)?)% full/) {
6875 $MonitoringOff{$2}++;
6976 } elsif ($ThisLine =~ /^(\d+) logical volume\(s\) in volume group "(\S+)" now active/) {
7077 $Active{$2}=$1;
78 } elsif ($ThisLine =~ /^Size of logical volume (\S+) changed from (.*) to (.*)\.$/) {
79 $Resize{$1}="$3"
7180 } else {
7281 $OtherList{$ThisLine}++;
7382 }
93102 print "Snapshot Usage:\n";
94103 foreach my $Snapshot (sort {$a cmp $b} keys %SnapshotUsed) {
95104 print " $Snapshot: $SnapshotUsed{$Snapshot}% full\n";
105 }
106 print "\n";
107 }
108
109 if (keys %Resize) {
110 print "Resize snapshot:\n";
111 foreach my $Snapshot (sort {$a cmp $b} keys %Resize) {
112 print " $Snapshot: $Resize{$Snapshot}\n";
96113 }
97114 print "\n";
98115 }
7878 ($ThisLine =~ /recvfrom: No route to host/) or
7979 # Be sure to catch: transfer of 'zone' from IP#53: failed to connect: timed out
8080 # not exact just triggers a full transfer
81 ($ThisLine =~ /transfer of .*: (IXFR|AXFR(|-style IXFR) (started|ended)|connected using|failed while receiving responses: not exact)/) or
82 ($ThisLine =~ /Transfer status: success/) or
81 ($ThisLine =~ /transfer of .*: (:?IXFR|AXFR(:?|-style IXFR) (:?started|ended)|connected using|failed while receiving responses: not exact)/) or
82 # This will generate another error that we will catch
83 ($ThisLine =~ /transfer of .*: resetting/) or
84 ($ThisLine =~ /Transfer status: (:?success|up to date)/) or
8385 ($ThisLine =~ /using \d+ CPU/) or
8486 ($ThisLine =~ /loading configuration/) or
8587 ($ThisLine =~ /command channel listening/) or
160162 ($ThisLine =~ /using built-in keys instead/) or
161163 ($ThisLine =~ /set up managed keys zone/) or
162164 ($ThisLine =~ /managed-keys-zone.*key now trusted/) or
163 ($ThisLine =~ /dhcpupdate: forwarding update for zone/) or
165 ($ThisLine =~ /key .*: forwarding update for zone/) or
164166 ($ThisLine =~ /forwarded dynamic update: master [^ ]* returned: (NXRRSET|YXDOMAIN)/) or
165167 ($ThisLine =~ /using .* as GeoIP directory/) or
166168 ($ThisLine =~ /GEO-.* Build/) or
212214 $DeniedZoneTransfers{$Host}{$Zone}++;
213215 } elsif ( ($Zone) = ( $ThisLine =~ /zone (.+) zone transfer deferred due to quota/ ) ) {
214216 $DeferredZoneTransfers{$Zone}++;
215 } elsif ( ($Zone, $Host) = ( $ThisLine =~ /transfer of '(.+)' from ([^\#]+)#[^\:]+: (failed|(Transfer status|giving up): ((network|host) unreachable|timed out|connection refused))/ ) ) {
217 } elsif ( ($Zone, $Host) = ( $ThisLine =~ /transfer of '(.+)' from ([^\#]+)#[^\:]+: (failed|(Transfer status|giving up): ((network|host) unreachable|timed out|connection refused|REFUSED))/ ) ) {
216218 $FailedZoneTransfers{$Host}{$Zone}++;
217219 } elsif ( ($Zone) = ( $ThisLine =~ /cache zone \"(.*)\" loaded/ ) ) {
218220 $ZoneLoaded{"cache $Zone"}++;
6262 next if (($Message =~ /^Controller event log: Time established as/) and ($Detail < 10));
6363 next if (($Message =~ /^Controller event log: Unexpected sense: Encl PD .* CDB: 12 00 00 00 (:?04|20) 00, Sense: 5\/24\/00/) and ($IgnoreNonCertifiedDrives));
6464 next if (($Message =~ /^Controller event log: Unexpected sense: PD .* CDB: 12 01 dc 01 1d 00, Sense: (4\/cf|5\/24)\/00/) and ($IgnoreNonCertifiedDrives));
65 next if (($Message =~ /^Unexpected sense. SCSI sense data: Sense key: 5 Sense code: 24 Sense qualifier: 0:/) and ($IgnoreNonCertifiedDrives));
6566 next if (($Message =~ /^Disk found is not supplied by an authorized hardware provider/) and ($IgnoreNonCertifiedDrives));
6667 next if (($Message =~ /^The battery charge cycle is complete\./) and ($Detail < 5));
6768 next if (($Message =~ /^The controller battery Learn cycle will start in (?:\d+) days\./) and ($Detail < 5));
124124 ($ThisLine =~ /^TCP\/UDP: Dynamic remote address changed during TCP connection establishment/) or
125125 ($ThisLine =~ /^TCP\/UDP: Preserving recently used remote address: /) or
126126 ($ThisLine =~ /^TCP connection established with [\d.]+:\d+/) or
127 ($ThisLine =~ /^TCP connection established with \[AF_INET6?\]/) or
127128 ($ThisLine =~ /^TCPv\d_(CLIENT|SERVER) link (local|remote)/) or
128129 ($ThisLine =~ /^TLS-Auth MTU parms/) or
129130 ($ThisLine =~ /^TLS: Initial packet from/) or
22852285 #TDpg unrecognized request type: ''
22862286 #TDpg rm /var/spool/postfix/postgrey/log.0000000002
22872287 #TDpg 2007/01/25-14:48:00 Pid_file already exists for running process (4775)... aborting at line 232 in file /usr/lib/perl5/vendor_perl/5.8.7/Net/Server.pm
2288
2288 #TDpg Resolved [localhost]:10023 to [127.0.0.1]:10023, IPv4
22892289
22902290 $line =~ /^cleaning / or
22912291 $line =~ /^delayed / or
23002300 # unanchored last
23012301 $line =~ /Pid_file already exists/ or
23022302 $line =~ /postgrey .* starting!/ or
2303 $line =~ /Server closing!/
2303 $line =~ /Server closing!/ or
2304 $line =~ /Resolved .*localhost.*IPv4/
23042305 );
23052306
23062307 my ($action,$reason,$delay,$host,$ip,$sender,$recip);
26072608 sub postfix_error;
26082609 sub postfix_warning;
26092610 sub postfix_script;
2611 sub backwards_compatible;
26102612 sub postfix_postsuper;
26112613 sub process_delivery_attempt;
26122614 sub cleanhostreply;
28122814 if ($p1 =~ /^fatal: +(.*)$/) { postfix_fatal($1); next; }
28132815 if ($p1 =~ /^panic: +(.*)$/) { postfix_panic($1); next; }
28142816 if ($p1 =~ /^error: +(.*)$/) { postfix_error($1); next; }
2817
2818 # Backwards compatibility mode
2819 if ($p1 =~ /compati/i) { backwards_compatible($p1); next; } # backwards-compatible default settings
28152820
28162821 # output by all services that use table lookups - process before specific messages
28172822 if ($p1 =~ /(?:lookup )?table (?:[^ ]+ )?has changed -- (?:restarting|exiting)$/) {
35853590
35863591 ### smtpd_tls_loglevel >= 1
35873592 # Server TLS messages
3588 elsif (($status,$host,$hostip,$type) = ($p1 =~ /^(?:(Anonymous|Trusted|Untrusted) )?TLS connection established from ([^[]+)\[([^]]+)\](?::\d+)?: (.*)$/)) {
3593 elsif (($status,$host,$hostip,$type) = ($p1 =~ /^(?:(Anonymous|Trusted|Untrusted) )?TLS connection established from ([^[]+)\[([^]]+)\](?::\d+)?(?: to [^:]+)?: (.*)$/)) {
35893594 #TDsd TLS connection established from example.com[192.168.0.1]: TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)
35903595 # Postfix 2.5+: status: Untrusted or Trusted
35913596 #TDsd Untrusted TLS connection established from example.com[192.168.0.1]: TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)
48044809 }
48054810 }
48064811
4812 # Handles postfix backwards compatibility mode lines
4813 #
4814 sub backwards_compatible($) {
4815 my $line = shift;
4816
4817 if ($line =~ /^Postfix is running with backwards-compatible default settings/o) {
4818 $Totals{'backwardscompatible'}++;
4819 }
4820 elsif ($line =~ /^See http.*COMPATIBILITY_README.html for details/o) {
4821 $Totals{'backwardscompatible'}++;
4822 }
4823 elsif ($line =~ /^To disable backwards compatibility use.*/o) {
4824 $Totals{'backwardscompatible'}++;
4825 }
4826 }
4827
48074828 # Clean up a server's reply, to give some uniformity to reports
48084829 #
48094830 sub cleanhostreply($ $ $ $) {
52115232 add_section ($S, 'postfixwaiting', 0, 'd', 'Postfix waiting to terminate');
52125233 end_section_group ($S, 'postfixstate');
52135234
5235 begin_section_group ($S, 'backwardscompatible', "\n");
5236 add_section ($S, 'backwardscompatible', 1, 'd', 'Running in backwards compatibile mode');
5237 end_section_group ($S, 'backwardscompatible');
52145238
52155239 if ($Opts{'debug'} & Logreporters::D_SECT) {
52165240 print "\tSection table\n";
155155 ( $ThisLine =~ /sshguard\[\d+\]: (?:message repeated \d+ times: \[ )?\S+: not blocking /) or
156156 ( $ThisLine =~ /sshguard\[\d+\]: Received EOF from stdin/) or
157157 ( $ThisLine =~ /sshguard\[\d+\]: .*has already been blocked/) or
158 ( $ThisLine =~ /gnome-keyring-daemon\[\d+\]: asked to register item.*already registered/) or
158159 0 # This line prevents blame shifting as lines are added above
159160 ) {
160161 # Ignore these entries
353354 $pwd_file_too_short++;
354355 } elsif ( ($User,$Su) = ($ThisLine =~ /^su: ([^ ]+) to ([^ ]+) on \/dev\/ttyp([0-9a-z]+)/) ) {
355356 $Su_User{$User}{$Su}++;
356 } elsif ( ($Su,$User) = ($ThisLine =~ /^su: \(to ([^ ]+)\) ([^ ]+) on (?:none|\/dev\/(pts\/|ttyp)([0-9]+))/) ) {
357 } elsif ( ($Su,$User) = ($ThisLine =~ /^su: \(to ([^ ]+)\) ([^ ]+) on (?:none|(\/dev\/)?(pts\/|ttyp)([0-9]+))/) ) {
357358 $Su_User{$User}{$Su}++;
358359 } elsif ( ($Su,$User) = ($ThisLine =~ /^su\[\d+\]: Successful su for (\S+) by (\S+)/) ) {
359360 $Su_User{$User}{$Su}++;
391392 $DeniedAccess{"$User,$Reason"}++;
392393 } elsif ($ThisLine =~ /^request-key: Cannot find command to construct key/) {
393394 $RequestKeyFailures++;
394 } elsif (my ($type,$from,$response,$client,$service,$e) = ($ThisLine =~ /krb5kdc\[[0-9]*\]: (AS_REQ|TGS_REQ) \([0-9]+ etypes \{[ 0-9]+}\) ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+): (ISSUE|UNKNOWN_SERVER): authtime [0-9]+, (?:etypes \{rep=[0-9]+ tkt=[0-9]+ ses=[0-9]+},)? ([^ ]+) for ([^ ,]+)(?:, )?(.*)$/)) {
395 } elsif (my ($type,$from,$response,$client,$service,$e) = ($ThisLine =~ /krb5kdc\[[0-9]*\]: (AS_REQ|TGS_REQ) \([0-9]+ etypes \{[ 0-9a-z\-\(\),]+}\) ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+): (ISSUE|UNKNOWN_SERVER): authtime [0-9]+, (?:etypes \{rep=[0-9a-z\-\(\)]+, tkt=[0-9a-z\-\(\)]+, ses=[0-9a-z\-\(\)]+},)? ([^ ]+) for ([^ ,]+)(?:, )?(.*)$/)) {
395396 if($service=~/^krbtgt\/([^@]+)@\1/) {
396397 $service='Login';
397398 }
400401 $e='';
401402 }
402403 $KerbList{$response}{$type}{$from}{$service}{$client}{$e}++;
403 } elsif (my ($type,$from,$response,$client,$service,$e) = ($ThisLine =~ /krb5kdc\[[0-9]*\]: (AS_REQ|TGS_REQ) \([0-9]+ etypes \{[ 0-9]+}\) ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+): (NEEDED_PREAUTH|PREAUTH_FAILED|CLIENT_NOT_FOUND): ([^ ]+) for ([^ ,]+)(?:, )?(.*)$/)) {
404 } elsif (my ($type,$from,$response,$client,$service,$e) = ($ThisLine =~ /krb5kdc\[[0-9]*\]: (AS_REQ|TGS_REQ) \([0-9]+ etypes \{[ 0-9a-z\-\(\),]+}\) ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+): (NEEDED_PREAUTH|PREAUTH_FAILED|CLIENT_NOT_FOUND): ([^ ]+) for ([^ ,]+)(?:, )?(.*)$/)) {
404405 if($service=~/^krbtgt\/([^@]+)@\1/) {
405406 $service='Login';
406407 }
131131 $Address, $Arg, $Attack,
132132 $Auth,
133133 $BlSite, $Bytes, $CommonName,
134 $DeliverStat, $Dest, $Domain,
135 $Error, $ErrorCount,
134 $DeliverStat, $Dest, $DetailReason,
135 $Domain, $Error, $ErrorCount,
136136 $ETRN, $File, $Forward,
137137 $FromUser, $Header, $HeaderMod,
138138 $Host, $IP,
161161
162162 my (
163163 %Abuse, %AddressError, %AttackAttempt,
164 %AUTHfailure, %AuthWarns, %BadAuth,
165 %BadRcptThrottle, %BlackHoled,
164 %AUTHfailure, %AUTHnouser, %AuthWarns,
165 %BadAuth, %BadRcptThrottle, %BlackHoled,
166166 %BlackHoles, %CheckMailReject, %CheckRcptReject,
167167 %CollectError, %CommandUnrecognized, %DisabledMailbox,
168168 %DNSMap,
807807 } elsif ( ($StatFile, $StatError) = ($ThisLine=~ /^poststats: (.*?): (.*)/) ) {
808808 $StatFileError{$StatFile}{$StatError}++;
809809 # file=srvrsmtp.c, LogLevel>9, LOG_WARNING
810 } elsif ( ($Auth, $Reason, $RelayHost) = ($ThisLine =~ /^AUTH failure \((.*)?\): ([^\)]*)\(.* relay=(.*)/) ) {
811 $AUTHfailure{$RelayHost}{$Reason}++;
810 } elsif ( ($Auth, $Reason, $DetailReason, $RelayHost) = ($ThisLine =~ /^AUTH failure \((.*)?\): ([^\(]*)(\(.*) relay=(.*)/) ) {
811 if ( $Reason =~ /^user not found / ) {
812 (($User) = ($DetailReason =~ /\(-20\) SASL\(-13\): user not found: .*user(?:=|: )([^ ,]*)/));
813 $AUTHnouser{$User}++;
814 } else {
815 $AUTHfailure{$RelayHost}{$Reason}++;
816 }
812817 # file=tls.c, LogLevel>7, LOG_INFO
813818 } elsif ($ThisLine=~ /STARTTLS=.* field=cn_issuer, status=failed to extract CN/ ) {
814819 $NoCommonName++;
832837 $TLSConnectFailed{"no reason given"}++;
833838 # file=tls.c, LogLevel>-1, LOG_INFO
834839 } elsif (($CommonName,$StarttlsReason) = ($ThisLine =~ /^STARTTLS: (?:x509|TLS) cert verify: depth=[0-9]+ .*\/CN=([^\/,]*).* state=[0-9]+, reason=(.*)$/ )) {
835 $StarttlsCert{$StarttlsReason}{$CommonName}++;
840 # "reason=ok" now printing in sendmail 8.16.1; not an error
841 if ($StarttlsReason !~ /^ok$/) {
842 $StarttlsCert{$StarttlsReason}{$CommonName}++;
843 }
836844 # do the same if, incorrectly, Common Name is not defined
837845 } elsif (($StarttlsReason) = ($ThisLine =~ /^STARTTLS: (?:x509|TLS) cert verify: depth=[0-9]+ .* state=[0-9]+, reason=(.*)$/ )) {
838 $StarttlsCert{$StarttlsReason}{"(undefined CommonName)"}++;
846 # "reason=ok" now printing in sendmail 8.16.1; not an error
847 if ($StarttlsReason !~ /^ok$/) {
848 $StarttlsCert{$StarttlsReason}{"(undefined CommonName)"}++;
849 }
839850 # file=tls.c, LogLevel>8, LOG_INFO
840851 } elsif ( ($StarttlsMode, $StarttlsVerify, $StarttlsCipherType, $StarttlsNumBits) =
841852 ($ThisLine =~ /^STARTTLS=(server|client), relay=.*, version=.*, verify=(\w*), cipher=(.*), bits=(\w*\/\w*)/) ) {
887898 } elsif ( ($User,$Reason) = ($ThisLine =~ /SYSERR\((.*)\): (.*)/) ) {
888899 $SysErr{$User}{$Reason}++;
889900 # file=milter.c, LogLevel>8, LOG_INFO
890 } elsif ( ($HeaderMod) = ($ThisLine =~ /Milter (?:add|insert|change|delete).*: header: (.*)/) ) {
901 } elsif ( ($HeaderMod) = ($ThisLine =~ /Milter (?:\(\w*\) )?(?:add|insert|change|delete).*: header: (.*)/) ) {
891902 foreach $Header (@MilterHeadersToCount) {
892903 if ($HeaderMod =~ /$Header/) {
893904 $MilterHeaderCount{$Header}++;
922933 $KnownSpammer{$1}++;
923934 } elsif (
924935 # file=milter.c, LogLevel>8, LOG_INFO
925 ( $ThisLine =~ /Milter (add|change|insert|delete): /)
936 ( $ThisLine =~ /Milter (?:\(\w*\) )?(add|change|insert|delete): /)
926937 ) {
927938 # We don't care about these statements above
928939
939950 $SPFResults{$SPFStatus}++;
940951
941952 # This is for the Sendmail Sender-ID milter
942 } elsif ( (my $SenderIDStatus, $SPFStatus) = ($ThisLine =~ /^Milter insert \(1\): header: Authentication-Results:.*; sender-id=(fail.*|softfail|neutral|none|error|unknown|pass); spf=(fail.*|softfail|neutral|none|error|unknown|pass)/) ) {
953 } elsif ( (my $SenderIDStatus, $SPFStatus) = ($ThisLine =~ /^Milter (?:\(\w*\) )?insert \(1\): header: Authentication-Results:.*; sender-id=(fail.*|softfail|neutral|none|error|unknown|pass); spf=(fail.*|softfail|neutral|none|error|unknown|pass)/) ) {
943954 # Example string
944955 # Milter insert (1): header: Authentication-Results: my.host.name
945956 # sender=list-users-bounces+list-users=host.name@another.org;
14891500 }
14901501 $TotalError[++$ErrorIndex] = 0;
14911502
1503 if (keys %AUTHnouser) {
1504 eval "$PrintCond" if ($Detail >= 3);
1505 print "\n\nFailed AUTH requests because of No User" if ($Detail >= 3);
1506 my $UserCount = CountOrder(%AUTHnouser);
1507 foreach $User (sort $UserCount keys %AUTHnouser) {
1508 PrettyTimes(" $User", $AUTHnouser{$User}) if ($Detail >=5);
1509 $TotalError[$ErrorIndex] += $AUTHnouser{$User};
1510 }
1511 print "\n\tTotal: $TotalError[$ErrorIndex]" if ($Detail >= 3);
1512 }
1513 $TotalError[++$ErrorIndex] = 0;
1514
14921515 if($RemoteProtocolError > 0) {
14931516 eval "$PrintCond" if ($Detail >= 3);
14941517 print "\n\n" . $RemoteProtocolError . " Remote Protocol Errors" if ($Detail >= 3);
169169 $DriveTest{$Device}{$TestType}++;
170170 } elsif ( my ($Device,$AttribType,$Code,$Name) = ($ThisLine =~ /^Device: ([^,]+), Failed SMART ([A-Za-z]+) Attribute: ([0-9]+) ([A-Za-z_]+)/)) {
171171 $Failed{$Device}{"$AttribType attribute: $Name ($Code)"}++;
172 } elsif ( my ($Device, $Text) = ($ThisLine =~ /^Device: ([^,]+), failed (.*)$/) ) {
172 } elsif ( my ($Device, $Text) = ($ThisLine =~ /^Device: ([^,]+), (?:failed|SMART Failure:) (.*)$/) ) {
173173 $Failed{$Device}{"$Text"}++;
174174 } elsif ( ( $ThisLine =~ /warning/i ) ) {
175175 $Warnings{$ThisLine}++;
3030 my $IgnoreHost = $ENV{'sshd_ignore_host'} || "";
3131 my $RefusedConnectionsThreshold = $ENV{'refused_connections_threshold'} || 0;
3232 my $IllegalUsersThreshold = $ENV{'illegal_users_threshold'} || 0;
33 $main::DoLookup = $ENV{'sshd_ip_lookup'};
3334 my $DebugCounter = 0;
3435
3536 # No sense in running if 'sshd' doesn't even exist on this system...
8080 $EnumerationRequested++ unless $IgnoreEnumerationRequested;
8181 } elsif ($Service eq "Daemon" && $ThisLine =~ /Keytab successfully retrieved and stored in:/) {
8282 # Ignore
83 } elsif ($Service eq "krb5_child" && $ThisLine =~ /Preauthentication failed/) {
84 # Ignore - this will generate a pam auth failed message
8385 } elsif ($Service eq "p11_child" && $ThisLine =~ /Certificate .* not valid .*Certificate key usage inadequate for attempted operation/) {
8486 # sssd ssh does not ignore certificates of different types - ignore the errors generated by it
8587 $ignore_p11_child_error = 1;
7676 $ThisLine =~ /^Inserted module / or
7777 $ThisLine =~ /^Listening on / or
7878 $ThisLine =~ /^Mounted / or
79 $ThisLine =~ /^Queued start job for default target / or
7980 $ThisLine =~ /^Relabelled / or
8081 $ThisLine =~ /^Reloading\.$/ or # Happens on each boot at switch root
8182 $ThisLine =~ /^RTC configured in / or
105106 $ThisLine =~ /: Start(-pre)? operation timed out\. Terminating\./ or
106107 $ThisLine =~ /hold-?off time over, scheduling restart\./ or
107108 $ThisLine =~ /Service has no hold-off time.*, scheduling restart\./ or
109 $ThisLine =~ /Service Restart.* expired, scheduling restart\./ or
108110 $ThisLine =~ /Scheduled restart job, restart counter is at .*\./ or
109111 $ThisLine =~ /Stopping timed out\. Killing\./ or
110112 $ThisLine =~ /^Timed out waiting for/ or
136138 $ThisLine =~ /^Removed slice / or
137139 $ThisLine =~ /^pam_unix\(systemd-user:session\): session (?:opened|closed) for user/ or
138140 $ThisLine =~ /Adding .* random time\.$/ or
141 # https://bugzilla.redhat.com/show_bug.cgi?id=1890632
142 $ThisLine =~ /Not generating service for XDG autostart .*,/ or
143 $ThisLine =~ /gnome-systemd-autostart-condition not found/ or
144 $ThisLine =~ /kde-systemd-start-condition not found/ or
145 $ThisLine =~ /Unknown key name .* in section 'Desktop Entry'/ or
139146 # These happen on every shutdown - downgraded to debug message in systemd v235
140147 # https://github.com/systemd/systemd/issues/6777
141148 $ThisLine =~ /^Failed to propagate agent release message: (?:Connection reset by peer|Transport endpoint is not connected)/ or
3333 #Exit early if the report is not for the current host.
3434 use POSIX qw(uname);
3535 my $logwatch_hostname = $ENV{'LOGWATCH_ONLY_HOSTNAME'};
36 my $Detail = $ENV{'LOGWATCH_DETAIL_LEVEL'} || 0;
3637 my ($OSname, $hostname, $release, $version, $machine) = POSIX::uname();
3738 $hostname =~ s/\..*//;
3839 exit (0) if ($ENV{'LOGWATCH_ONLY_HOSTNAME'} and ($logwatch_hostname ne $hostname));
88
99 #######################################################
1010 ## Copyright (c) 2008 Laurent Dufour
11 ## Francis Borras
1112 ## Covered under the included MIT/X-Consortium License:
1213 ## http://www.opensource.org/licenses/mit-license.php
1314 ## All modifications and contributions by other persons to
7778 }
7879 }
7980
80 sub routingCapabilities ()
81 {
82 print "\n\n------------- Routing capabilities----------\n\n";
83 chkcfg('routed');
84 chkcfg('gated');
85 chkcfg('zebra');
86 chkcfg('ripd');
87 chkcfg('ripngd');
88 chkcfg('isisd');
89 chkcfg('ospfd');
90 chkcfg('ospf6d');
91 chkcfg('bgpd');
92 if ( -f $pathto_vtysh )
93 {
94 print "\n";
95 system("$pathto_vtysh -e 'sh ver'");
96 }
97
98 if ($OSname eq "SunOS") {
99 if ( ($release eq "5.10") || ($release eq "5.11") ) {
100
101 if ( -f $pathto_routeadm)
102 {
103 open(FILE1, "$pathto_routeadm -p |") || die "can't open $!";
104 while (<FILE1>)
105 {
106 print $_;
107 }
108 close(FILE1) || die "can't close $!";
109 }
110
111 }
112 }
113 print "\n\n------------- Routing capabilities----------\n\n";
114 print "\n";
115 }
116
117 sub routingState ()
118 {
119 print "\n\n------------- Routing states ---------------\n\n";
120 if ($OSname eq "Linux") {
121 if ( -f $pathto_sysctl_conf) {
122 open(SYSCTL, "< $pathto_sysctl_conf") || die "can't open $!";
123 while (<SYSCTL>)
124 {
125 if ($_ =~ /ip_forward/ ) {
126 print $_;
127 }
128 }
129 }
130 else
131 {
132 open(SYSCTL,"< /proc/sys/net/ipv4/ip_forward") || die "can't open $!";
133 while (<SYSCTL>)
134 {
135 print "/proc/sys/net/ipv4/ip_forward set to $_";
136 }
137 close(SYSCTL) || die "can't close $!";
138 }
139 }
140
141 elsif ($OSname eq "SunOS") {
142 if ( ($release eq "5.10") || ($release eq "5.11") ) {
143
144 if ( -f $pathto_routeadm)
145 {
146 open(FILE1, "$pathto_routeadm -p |") || die "can't open $!";
147 while (<FILE1>)
148 {
149 if (/ipv(\d+)-forwarding .*default=(\S+) current=(\S+)/) {
150 print "IPv$1 forwarding is $3 (normal state is $2)\n";
151 }
152 }
153 close(FILE1) || die "can't close $!";
154 }
155
156 }
157 }
158
159 else
160 {
161 print "Unable to find routing information in your system.\n";
162 }
163 print "\n\n------------- Routing states ---------------\n\n";
164 print "\n";
165 }
166
167
168
169
170
171 sub routingReport ()
172 {
173 print "\n\n------------- Network routes ---------------\n\n";
174 if ($OSname eq "Linux") {
175
176 open(NET, "netstat -r -n |") || die "can't run netstat: $!";
177 while (<NET>)
178 {
179 print $_;
180 }
181 close(NET) || die "can't close netstat: $!";
182 }
183 else
184 {
185 open(NET, "netstat -r -n |") || die "can't run netstat: $!";
186 while (<NET>)
187 {
188 print $_;
189 }
190 close(NET) || die "can't close netstat: $!";
191 }
192 print "\n\n------------- Network routes ---------------\n\n";
193 print "\n";
194 }
195
196
197
198
199
200
201 sub ListeningSockets ()
202 {
203 print "\n\n------------- Listening sockets ---------------\n\n";
204 if ($OSname eq "Linux") {
205 open(NET, "netstat -l |") || die "can't run netstat: $!";
206 while (<NET>)
207 {
208 if ($_ =~ /LISTEN/ ) { # grep LISTEN
209 if (($_ =~ /LISTENING/ ) == 0 ) { #grep -v LISTENING
210 print $_;
211 }
212 }
213
214 }
215 close(NET) || die "can't run netstat: $!";
216 }
217 else
218 {
219
220 open(NET, "netstat -a -n |") || die "can't run netstat: $!";
221 while (<NET>)
222 {
223 if ($_ =~ /LISTEN/ ) {# grep LISTEN
224 if (($_ =~ /LISTENING/ ) == 0 ) { # grep -v LISTENING
225 print $_;
226 }
227 }
228
229 }
230 close(NET) || die "can't run netstat: $!";
231
232 }
233 print "\n\n------------- Listening sockets ---------------\n\n";
234 print "\n";
235 }
236
237
238
239
240 sub NetworkStats()
241 {
242 my $awkprog='{printf("%s \t%6s %6s %6s \n", $1, $2, $5, $9 ); }';
243 print "\n\n------------- Network statistics ---------------\n\n";
244 if ($OSname eq "Linux") {
245
246 my $cmd_to_show_int="";
247
248 if ( -f $pathto_ip) {
249 $cmd_to_show_int=$pathto_ip." a";
250 }
251 else
252 {
253 $cmd_to_show_int="$pathto_ifconfig -a";
254 }
255
256 open(NET, "$cmd_to_show_int |") || die "can't run $cmd_to_show_int: $!";
257 while (<NET>)
258 {
259 print $_;
260 }
261 close(NET) || die "can't close $cmd_to_show_int: $!";
262
263 print "\n";
264 system("netstat -i | grep -v Kernel | awk '$awkprog' ");
265 }
266 else {
267 my $netstat_cmd = "netstat -i";
268 if ($OSname eq "SunOS") {
269 $netstat_cmd .= " -a";
270 }
271 open(NET, "$netstat_cmd |") || die "can't run netstat: $!";
272 while (<NET>)
273 {
274 print $_;
275 }
276 close(NET) || die "can't close netstat: $!";
277
278 }
279 print "\n\n------------- Network statistics ---------------\n\n";
280 print "\n";
281 }
282
283
284
285
286
287
288
289
290 sub IfconfigIface {
291
292 my ($iface) = $_[0];
293 open(NET, "$pathto_ifconfig $iface |") || die "can't run ifconfig: $!";
294 while (<NET>)
295 {
296 print $_;
297 }
298 close(NET) || die "can't close ifconfig: $!";
299 print "\n";
300 }
301
302
303
304
305
306
307
308
309 sub InterfacesReport ()
310 {
311
312 print "\n\n------------- Network Interfaces ---------------\n\n";
313 print "Ethernet : $total_ethernet_iface\n";
314 print "Other : $total_other_iface\n";
315 print "Total : $total_iface\n";
316 print "\n\n------------- Ethernet -------------------------\n\n";
317
318 if ($OSname eq "Linux") {
319 foreach $element (@ethernet_iface_list) { print "$element"; }
320 }
321 else
322 {
323 foreach $element (@short_ethernet_iface_list) { IfconfigIface ($element);}
324 }
325
326
327
328
329 print "\n\n------------- Other ----------------------------\n\n";
330 if ($OSname eq "Linux") {
331
332 foreach $element (@other_iface_list) { print "$element"; }
333
334 }
335 else
336 {
337 foreach $element (@short_other_iface_list) { IfconfigIface ($element); }
338 }
339
340
341
342 print "\n\n------------- Network Interfaces ---------------\n\n";
343 print "\n";
344 }
345
346 sub InterfacesCheck
347 {
348 if ($OSname eq "Linux") {
349
350 my $cmd_to_show_int="";
351
352 $cmd_to_show_int="$pathto_ifconfig -a";
353
354 open(NET, "$cmd_to_show_int |") || die "can't use $cmd_to_show_int: $!";
355 while (<NET>)
356 {
357 if ($_ =~ /Link/ ){# grep Link
358 if ($_ =~ /Ether/ ){# grep Ether
359 ($if_name,$msg)=split(/ +/, $_ , 2);
360 if ($if_name =~ /(\S+)/ ) {
361 push (@ethernet_iface_list, $_);
362 push (@short_ethernet_iface_list, $if_name);
363 $total_ethernet_iface++;
364 $total_iface++;
365 }
366 }
367 else
368 {
369 ($if_name,$msg)=split(/ +/, $_ , 2);
370 if ($if_name =~ /(\S+)/ ) {
371 push (@other_iface_list, $_);
372 push (@short_other_iface_list, $if_name);
373 $total_other_iface++;
374 $total_iface++;
375 }
376 }
377 }
378 }
379 close(NET) || die "can't use $cmd_to_show_int: $!";
380
381 }
382
383 elsif ($OSname eq "SunOS") {
384
385 # Representative 'ifconfig -a' output from a local zone
386 # (global zone is similar, but has the top-level lo0, in0, etc)
387 # as well.
388 #lo0:1: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
389 # inet 127.0.0.1 netmask ff000000
390 #in0:1: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
391 # inet 192.168.1.31 netmask ffffff00 broadcast 192.168.1.255
392 #local1:1: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 9000 index 4
393 # inet 172.16.0.3 netmask fffffff8 broadcast 172.16.0.7
394 #out0:1: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 6
395 # inet 184.105.220.67 netmask fffffff8 broadcast 184.105.220.71
396 #lo0:1: flags=2002000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv6,VIRTUAL> mtu 8252 index 1
397 # inet6 ::1/128
398
399 # Run through twice; a single interface plumbed with both IPv4 and IPv6
400 # can be listed separately, but shouldn't count as two interfaces
401 foreach my $ip (qw( 4 6 )) {
402 open(NET, "$pathto_ifconfig -a$ip |") || die "can't run '$pathto_ifconfig -a$ip': $!";
403 while (<NET>)
404 {
405 if ($_ =~ /^(\w+\d+(?::\d+)?): flags=\d+<[^>]+> mtu (\d+)/) {
406 ($if_name, $mtu) = ($1, $2);
407 if (! grep { $_ eq $if_name } (@ethernet_iface_list, @other_iface_list)) {
408 # Not seen before; process it
409 $total_iface++;
410 if ($mtu == 1500) {
411 # Guess that it's ethernet
412 push @ethernet_iface_list, $if_name;
413 push @short_ethernet_iface_list, $if_name;
414 $total_ethernet_iface++;
415 } else {
416 push @other_iface_list, $if_name;
417 push @short_other_iface_list, $if_name;
418 $total_other_iface++;
419 }
420 }
421 }
422 }
423 close(NET) || die "can't use '$pathto_ifconfig -a$ip': $!";
424 }
425
426 }
427 else
428 {
429
430
431 open(NET, "netstat -i |") || die "can't run netstat: $!";
432 while (<NET>)
433 {
434 if (($_ =~ /Name/ ) == 0 ) {# grep -v Name
435 if ($_ =~ /1500/ ){# grep Ether
436 ($if_name,$msg)=split(/ +/, $_ , 2);
437 if ($if_name =~ /(\S+)/ ) {
438 push (@ethernet_iface_list, $_);
439 push (@short_ethernet_iface_list, $if_name);
440 $total_ethernet_iface++;
441 $total_iface++;
442 }
443 }
444 else
445 {
446 ($if_name,$msg)=split(/ +/, $_ , 2);
447 if ($if_name =~ /(\S+)/ ) {
448 push (@other_iface_list, $_);
449 push (@short_other_iface_list, $if_name);
450 $total_other_iface++;
451 $total_iface++;
452 }
453 }
454 }
455 }
456 close(NET) || die "can't run fconfig: $!";
457
458 }
459
460
461 }
462
463 InterfacesCheck();
464 InterfacesReport();
465 if ($Detail > 10) {
466 ListeningSockets();
467 }
468 NetworkStats();
469 if ($Detail > 5) {
470 routingState();
471 routingCapabilities();
472 routingReport();
473 }
81 sub routingCapabilities () {
82 print "\n\n------------- Routing capabilities----------\n\n";
83 chkcfg('routed');
84 chkcfg('gated');
85 chkcfg('zebra');
86 chkcfg('ripd');
87 chkcfg('ripngd');
88 chkcfg('isisd');
89 chkcfg('ospfd');
90 chkcfg('ospf6d');
91 chkcfg('bgpd');
92 if ( -f $pathto_vtysh ) {
93 print "\n";
94 system("$pathto_vtysh -e 'sh ver'");
95 }
96
97 if ($OSname eq "SunOS") {
98 if ( ($release eq "5.10") || ($release eq "5.11") ) {
99 if ( -f $pathto_routeadm) {
100 open(FILE1, "$pathto_routeadm -p |") || die "can't open $!";
101 while (<FILE1>) {
102 print $_;
103 }
104 close(FILE1) || die "can't close $!";
105 }
106 }
107 }
108 print "\n\n------------- Routing capabilities----------\n\n";
109 print "\n";
110 }
111
112 sub routingState () {
113 print "\n\n------------- Routing states ---------------\n\n";
114 if ($OSname eq "Linux") {
115 if ( -f $pathto_sysctl_conf) {
116 open(SYSCTL, "< $pathto_sysctl_conf") || die "can't open $!";
117 while (<SYSCTL>) {
118 if ($_ =~ /ip_forward/ ) {
119 print "IP Forwarding enabled";
120 }
121 }
122 }
123 else {
124 open(SYSCTL,"< /proc/sys/net/ipv4/ip_forward") || die "can't open $!";
125 while (<SYSCTL>) {
126 print "/proc/sys/net/ipv4/ip_forward set to $_";
127 }
128 close(SYSCTL) || die "can't close $!";
129 }
130 }
131 elsif ($OSname eq "SunOS") {
132 if ( ($release eq "5.10") || ($release eq "5.11") ) {
133 if ( -f $pathto_routeadm) {
134 open(FILE1, "$pathto_routeadm -p |") || die "can't open $!";
135 while (<FILE1>) {
136 if (/ipv(\d+)-forwarding .*default=(\S+) current=(\S+)/) {
137 print "IPv$1 forwarding is $3 (normal state is $2)\n";
138 }
139 }
140 close(FILE1) || die "can't close $!";
141 }
142 }
143 }
144
145 else {
146 print "Unable to find routing information in your system.\n";
147 }
148 print "\n\n------------- Routing states ---------------\n\n";
149 print "\n";
150 }
151
152 sub routingReport () {
153 print "\n\n------------- Network routes ---------------\n\n";
154 if ($OSname eq "Linux") {
155 open(NET, "netstat -r -n |") || die "can't run netstat: $!";
156 while (<NET>) {
157 print $_;
158 }
159 close(NET) || die "can't close netstat: $!";
160 }
161 else {
162 open(NET, "netstat -r -n |") || die "can't run netstat: $!";
163 while (<NET>) {
164 print $_;
165 }
166 close(NET) || die "can't close netstat: $!";
167 }
168 print "\n\n------------- Network routes ---------------\n\n";
169 print "\n";
170 }
171
172 sub ListeningSockets () {
173 print "\n\n------------- Listening sockets ---------------\n\n";
174 if ($OSname eq "Linux") {
175 open(NET, "netstat -lnptu |") || die "can't run netstat: $!";
176 while (<NET>) {
177 print $_;
178 }
179 close(NET) || die "can't run netstat: $!";
180 }
181 else {
182 open(NET, "netstat -a -n |") || die "can't run netstat: $!";
183 while (<NET>) {
184 if ($_ =~ /LISTEN/ ) {# grep LISTEN
185 if (($_ =~ /LISTENING/ ) == 0 ) { # grep -v LISTENING
186 print $_;
187 }
188 }
189 }
190 close(NET) || die "can't run netstat: $!";
191 }
192 print "\n\n------------- Listening sockets ---------------\n\n";
193 print "\n";
194 }
195
196 sub NetworkStats() {
197 print "\n\n------------- Network statistics ---------------\n\n";
198 if ($OSname eq "Linux") {
199 my $cmd_to_show_int="";
200 if ( -f $pathto_ip) {
201 $cmd_to_show_int=$pathto_ip." -s -h a";
202 }
203 else {
204 $cmd_to_show_int="$pathto_ifconfig -s -a";
205 }
206 open(NET, "$cmd_to_show_int |") || die "can't run $cmd_to_show_int: $!";
207 while (<NET>) {
208 print $_;
209 }
210 close(NET) || die "can't close $cmd_to_show_int: $!";
211 }
212 else {
213 my $netstat_cmd = "netstat -i";
214 if ($OSname eq "SunOS") {
215 $netstat_cmd .= " -a";
216 }
217 open(NET, "$netstat_cmd |") || die "can't run netstat: $!";
218 while (<NET>) {
219 print $_;
220 }
221 close(NET) || die "can't close netstat: $!";
222 }
223 print "\n\n------------- Network statistics ---------------\n\n";
224 print "\n";
225 }
226
227 NetworkStats();
228 ListeningSockets();
229 if ($Detail > 5) {
230 routingState();
231 routingCapabilities();
232 routingReport();
233 }
474234
475235 # vi: shiftwidth=3 tabstop=3 syntax=perl et
476236 # Local Variables:
2424 # customize the Timefilter by appending a string:
2525 # *ApplyStdDate = "%H:%M %d/%m/%Y"
2626 $SearchDate = TimeFilter($ARGV[0] || '%b %e %H:%M:%S ');
27 $SearchDateRsyslog = TimeFilter('%Y-%m-%dT%H:%M:%S(:?\.[0-9]+)?(:?[+-][0-9]{2}:[0-9]{2}|Z) ');
27 $SearchDateRsyslog = TimeFilter('%Y-%m-%dT%H:%M:%S(:?\.[0-9]+)?(:?[+-][0-9]{2}:?[0-9]{2}|Z) ');
2828
2929 # The date might be "Dec 09", but it needs to be "Dec 9"...
3030 #$SearchDate =~ s/ 0/ /;
3939 if ($ThisLine =~ m/^$SearchDate/o) {
4040 print $ThisLine;
4141 } elsif ($ThisLine =~ /^$SearchDateRsyslog/o) {
42 $ThisLine =~ s/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(:?\.[0-9]+)?(:?[+-][0-9]{2}:[0-9]{2}|Z) //o;
42 $ThisLine =~ s/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(:?\.[0-9]+)?(:?[+-][0-9]{2}:?[0-9]{2}|Z) //o;
4343 print POSIX::strftime("%b %e %H:%M:%S", $6, $5, $4, $3, $2-1, $1 - 1900) . " " . $ThisLine;
4444 } elsif ($ThisLine =~ m/(Mon|Tue|Wed|Thu|Fri|Sat|Sun) $SearchDate\d{4}/o) {
4545 print $ThisLine;