|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
##########################################################################
|
|
Packit Bot |
ea69bd |
# $Id$
|
|
Packit Bot |
ea69bd |
##########################################################################
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
########################################################
|
|
Packit Bot |
ea69bd |
# This was written and is maintained by:
|
|
Packit Bot |
ea69bd |
# David Baldwin <david.baldwin@anu.edu.au>
|
|
Packit Bot |
ea69bd |
#
|
|
Packit Bot |
ea69bd |
# Heavily based on sshd script
|
|
Packit Bot |
ea69bd |
#
|
|
Packit Bot |
ea69bd |
# Please send all comments, suggestions, bug reports,
|
|
Packit Bot |
ea69bd |
# etc, to david.baldwin@anu.edu.au.
|
|
Packit Bot |
ea69bd |
########################################################
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
#######################################################
|
|
Packit Bot |
ea69bd |
## Copyright (c) 2008 David Baldwin
|
|
Packit Bot |
ea69bd |
## Covered under the included MIT/X-Consortium License:
|
|
Packit Bot |
ea69bd |
## http://www.opensource.org/licenses/mit-license.php
|
|
Packit Bot |
ea69bd |
## All modifications and contributions by other persons to
|
|
Packit Bot |
ea69bd |
## this script are assumed to have been donated to the
|
|
Packit Bot |
ea69bd |
## Logwatch project and thus assume the above copyright
|
|
Packit Bot |
ea69bd |
## and licensing terms. If you want to make contributions
|
|
Packit Bot |
ea69bd |
## under your own copyright or a different license this
|
|
Packit Bot |
ea69bd |
## must be explicitly stated in the contribution an the
|
|
Packit Bot |
ea69bd |
## Logwatch project reserves the right to not accept such
|
|
Packit Bot |
ea69bd |
## contributions. If you have made significant
|
|
Packit Bot |
ea69bd |
## contributions to this script and want to claim
|
|
Packit Bot |
ea69bd |
## copyright please contact logwatch-devel@lists.sourceforge.net.
|
|
Packit Bot |
ea69bd |
#########################################################
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
use strict;
|
|
Packit Bot |
ea69bd |
use Logwatch ':all';
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
my $Debug = $ENV{'LOGWATCH_DEBUG'} || 0;
|
|
Packit Bot |
ea69bd |
my $Detail = $ENV{'LOGWATCH_DETAIL_LEVEL'} || 0;
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
my $DebugCounter = 0;
|
|
Packit Bot |
ea69bd |
my $Starts = 0;
|
|
Packit Bot |
ea69bd |
my $Kills = 0;
|
|
Packit Bot |
ea69bd |
my $SyncLost = 0;
|
|
Packit Bot |
ea69bd |
my (@TimeReset,%Interfaces,%Syncs,%TwoInst,%Errors,%OtherList);
|
|
Packit Bot |
ea69bd |
my %ConfErrs;
|
|
Packit Bot |
ea69bd |
my %Operations;
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
# No sense in running if 'xntpd' doesn't even exist on this system...
|
|
Packit Bot |
ea69bd |
unless (( -f "/usr/sbin/ntpd" ) or ( -f "/usr/local/sbin/ntpd") or ( -f "/usr/lib/inet/xntpd") or ( -f "/usr/lib/inet/ntpd" ) ) {
|
|
Packit Bot |
ea69bd |
if ( $Debug >= 5 ) {
|
|
Packit Bot |
ea69bd |
print STDERR "\n\nDEBUG: Exiting XNTPD Filter - no ntpd binary on system\n\n";
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
exit (0);
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
if ( $Debug >= 5 ) {
|
|
Packit Bot |
ea69bd |
print STDERR "\n\nDEBUG: Inside XNTPD Filter \n\n";
|
|
Packit Bot |
ea69bd |
$DebugCounter = 1;
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
while (defined(my $ThisLine = <STDIN>)) {
|
|
Packit Bot |
ea69bd |
if ( $Debug >= 5 ) {
|
|
Packit Bot |
ea69bd |
print STDERR "DEBUG($DebugCounter): $ThisLine";
|
|
Packit Bot |
ea69bd |
$DebugCounter++;
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
chomp($ThisLine);
|
|
Packit Bot |
ea69bd |
if (
|
|
Packit Bot |
ea69bd |
($ThisLine =~ m/tickadj = /) or # startup
|
|
Packit Bot |
ea69bd |
($ThisLine =~ m/precision = /) or # startup
|
|
Packit Bot |
ea69bd |
($ThisLine =~ m/ (succeeded|failed)/) or # startup
|
|
Packit Bot |
ea69bd |
($ThisLine =~ m/sendto\(\S+\): Success/) or # startup
|
|
Packit Bot |
ea69bd |
($ThisLine =~ m/kernel time (discipline|sync) status/) or # startup
|
|
Packit Bot |
ea69bd |
($ThisLine =~ m/kernel time sync (dis|en)abled /) or # startup
|
|
Packit Bot |
ea69bd |
($ThisLine =~ m/frequency initialized/) or # startup
|
|
Packit Bot |
ea69bd |
($ThisLine =~ m/using kernel phase-lock loop/) or # startup
|
|
Packit Bot |
ea69bd |
($ThisLine =~ m/0\.0\.0\.0 [[:xdigit:]]{4} [[:xdigit:]]{2} /) or # startup
|
|
Packit Bot |
ea69bd |
($ThisLine =~ m/select([^\)]) error: Interrupted system call/) or
|
|
Packit Bot |
ea69bd |
($ThisLine =~ m/signal_no_reset: signal \d+ had flags \d+/) or
|
|
Packit Bot |
ea69bd |
($ThisLine =~ /Deleting interface \#[0-9]+ [^,]*, [^,]*, interface stats: received=.*, sent=.*, dropped=.*, active_time=.* secs/) or
|
|
Packit Bot |
ea69bd |
($ThisLine =~ /Invalid argument/) or
|
|
Packit Bot |
ea69bd |
($ThisLine =~ /Listening on interface .* Disabled/) or
|
|
Packit Bot |
ea69bd |
($ThisLine =~ /Listen and drop on /) or
|
|
Packit Bot |
ea69bd |
($ThisLine =~ /Listening on routing socket on/) or
|
|
Packit Bot |
ea69bd |
($ThisLine =~ /.* interface .* -> \(null\)/) or
|
|
Packit Bot |
ea69bd |
($ThisLine =~ /Deferring DNS for/) or
|
|
Packit Bot |
ea69bd |
($ThisLine =~ /ntp_io: estimated max descriptors: \d*, initial socket boundary: \d*/) or
|
|
Packit Bot |
ea69bd |
($ThisLine =~ /peers refreshed$/) or
|
|
Packit Bot |
ea69bd |
($ThisLine =~ /restrict: error in address/) or
|
|
Packit Bot |
ea69bd |
($ThisLine =~ /syntax error in .+ line \d+, column \d+$/)
|
|
Packit Bot |
ea69bd |
) {
|
|
Packit Bot |
ea69bd |
# Ignore these
|
|
Packit Bot |
ea69bd |
} elsif ($ThisLine =~ m/ntpd [\d\-\.\w@]+ ... ... .. ..:..:.. /) {
|
|
Packit Bot |
ea69bd |
$Starts++;
|
|
Packit Bot |
ea69bd |
} elsif ($ThisLine =~ m/ntpd exiting on signal/) {
|
|
Packit Bot |
ea69bd |
$Kills++;
|
|
Packit Bot |
ea69bd |
} elsif ($ThisLine =~ m/synchronisation lost/) {
|
|
Packit Bot |
ea69bd |
$SyncLost++;
|
|
Packit Bot |
ea69bd |
} elsif ( my (undef,$TimeStep) = ($ThisLine =~ /time reset(| \(step\)) ([^ ]+) s$/ )) {
|
|
Packit Bot |
ea69bd |
push @TimeReset, $TimeStep;
|
|
Packit Bot |
ea69bd |
} elsif ( my (undef,$TimeStep) = ($ThisLine =~ /(step|adjust) time server [^ ]+ offset ([^ ]+) sec$/ )) {
|
|
Packit Bot |
ea69bd |
push @TimeReset, $TimeStep;
|
|
Packit Bot |
ea69bd |
} elsif ( my ($TimeStep) = ($ThisLine =~ /adjusting local clock by ([^ ]+)s$/ )) {
|
|
Packit Bot |
ea69bd |
# Jacob Joseph (12/8/06)
|
|
Packit Bot |
ea69bd |
push @TimeReset, $TimeStep;
|
|
Packit Bot |
ea69bd |
# MEv start no leadin to line
|
|
Packit Bot |
ea69bd |
} elsif ( my (undef,$TimeStep) = ($ThisLine =~ /(offset) ([^ ]+) sec/ )) {
|
|
Packit Bot |
ea69bd |
push @TimeReset, $TimeStep;
|
|
Packit Bot |
ea69bd |
# MEv end no leadin to line
|
|
Packit Bot |
ea69bd |
} elsif ( my ($ListenOn) = ($ThisLine =~ /Listening on interface(?: #\d+)? (.*)(?: Enabled)?/ )) {
|
|
Packit Bot |
ea69bd |
$Interfaces{$ListenOn}++;
|
|
Packit Bot |
ea69bd |
} elsif ( my ($ListenOn) = ($ThisLine =~ /Listen normally on \d+ (.*)/ )) {
|
|
Packit Bot |
ea69bd |
$Interfaces{$ListenOn}++;
|
|
Packit Bot |
ea69bd |
} elsif ( my ($SyncTo,$Stratum) = ($ThisLine =~ /synchronized to ([^ ]+), stratum[ =]([^ ]+)/ )) {
|
|
Packit Bot |
ea69bd |
my $name = $SyncTo;
|
|
Packit Bot |
ea69bd |
if ($Detail > 5 && $SyncTo =~ m/^[\d.]+$/) {
|
|
Packit Bot |
ea69bd |
$name = LookupIP($SyncTo);
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
$name .= " stratum " . $Stratum;
|
|
Packit Bot |
ea69bd |
$Syncs{$name}++;
|
|
Packit Bot |
ea69bd |
} elsif ( my ($Host) = ($ThisLine =~ /two instances of default interface for ([^ ]+) in hash table$/ )) {
|
|
Packit Bot |
ea69bd |
if ($Debug >= 5) {
|
|
Packit Bot |
ea69bd |
print STDERR "DEBUG: Found -$1 two instances of default interface\n";
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
my $name = LookupIP($Host);
|
|
Packit Bot |
ea69bd |
$TwoInst{$name}++;
|
|
Packit Bot |
ea69bd |
} elsif ( my ($Error) = ($ThisLine =~ /(no server(s reachable| suitable for synchronization found))/ )) {
|
|
Packit Bot |
ea69bd |
$Errors{$Error}++;
|
|
Packit Bot |
ea69bd |
} elsif ( my ($Error) = ($ThisLine =~ /([Cc]an't find host \S+|no servers can be used, exiting)/ )) {
|
|
Packit Bot |
ea69bd |
$Errors{$Error}++;
|
|
Packit Bot |
ea69bd |
} elsif ( my ($Error) = ($ThisLine =~ /(sendto\(\S+\): Network is unreachable)/ )) {
|
|
Packit Bot |
ea69bd |
$Errors{$Error}++;
|
|
Packit Bot |
ea69bd |
} elsif ( my ($Error) = ($ThisLine =~ /(getaddrinfo: "\S+" invalid host address, ignored)/ )) {
|
|
Packit Bot |
ea69bd |
$Errors{$Error}++;
|
|
Packit Bot |
ea69bd |
} elsif ( my ($Error) = ($ThisLine =~ /(frequency error \d+ PPM exceeds tolerance \d+ PPM)/ )) {
|
|
Packit Bot |
ea69bd |
$Errors{$Error}++;
|
|
Packit Bot |
ea69bd |
} elsif ( my ($ConfErr) = ($ThisLine =~ /configure: (keyword "[^"]*" unknown, line ignored)/ )) {
|
|
Packit Bot |
ea69bd |
$ConfErrs{$ConfErr}++;
|
|
Packit Bot |
ea69bd |
} elsif ( my ($ConfErr) = ($ThisLine =~ /line \d+ column \d+ syntax error, (.+)$/ )) {
|
|
Packit Bot |
ea69bd |
$ConfErrs{$ConfErr}++;
|
|
Packit Bot |
ea69bd |
} elsif ( my ($StepTime) = ($ThisLine =~ /(.*:) Operation not permitted/) ) {
|
|
Packit Bot |
ea69bd |
$Operations{$StepTime}++
|
|
Packit Bot |
ea69bd |
} else {
|
|
Packit Bot |
ea69bd |
# Report any unmatched entries...
|
|
Packit Bot |
ea69bd |
$OtherList{$ThisLine} += 1;
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
###########################################################
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
if ($Kills) {
|
|
Packit Bot |
ea69bd |
print "\nXNTPD Killed: " . $Kills . " Time(s)\n";
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
if ($Starts) {
|
|
Packit Bot |
ea69bd |
print "\nXNTPD Started: " . $Starts . " Time(s)\n";
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
if ($SyncLost) {
|
|
Packit Bot |
ea69bd |
print "\nSync lost: " . $SyncLost . " Time(s)\n";
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
if (@TimeReset > 0) {
|
|
Packit Bot |
ea69bd |
if ($Detail > 5) {
|
|
Packit Bot |
ea69bd |
print "\nTime Reset\n";
|
|
Packit Bot |
ea69bd |
print map " time stepped $_\n",@TimeReset;
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
my $t = 0;
|
|
Packit Bot |
ea69bd |
$t += $_ foreach @TimeReset;
|
|
Packit Bot |
ea69bd |
printf "\nTime Reset ".(@TimeReset)." times (total: %.6f s average: %.6f s)\n", $t, $t/(@TimeReset);
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
if (keys %Interfaces) {
|
|
Packit Bot |
ea69bd |
my $t = 0;
|
|
Packit Bot |
ea69bd |
my $lt = 0;
|
|
Packit Bot |
ea69bd |
print "\nListening on interfaces:\n" if ($Detail > 5);
|
|
Packit Bot |
ea69bd |
foreach my $i (keys %Interfaces) {
|
|
Packit Bot |
ea69bd |
print " $i - $Interfaces{$i} times\n" if ($Detail > 5);
|
|
Packit Bot |
ea69bd |
unless ($i =~ m/^(wildcard|v[46]wildcard|lo)/) {
|
|
Packit Bot |
ea69bd |
$lt++;
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
$t++;
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
print "\nTotal interfaces: $t (non-local: $lt)\n";
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
if (keys %Syncs) {
|
|
Packit Bot |
ea69bd |
my $t = 0;
|
|
Packit Bot |
ea69bd |
my $ht = 0;
|
|
Packit Bot |
ea69bd |
print "\nSynchronized to:\n" if ($Detail > 5);
|
|
Packit Bot |
ea69bd |
foreach my $h (keys %Syncs) {
|
|
Packit Bot |
ea69bd |
$ht++;
|
|
Packit Bot |
ea69bd |
$t += $Syncs{$h};
|
|
Packit Bot |
ea69bd |
print " $h - $Syncs{$h} times\n" if ($Detail > 5);
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
print "\nTotal synchronizations $t (hosts: $ht)\n";
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
if (keys %TwoInst) {
|
|
Packit Bot |
ea69bd |
print "\nTwo instances error\n";
|
|
Packit Bot |
ea69bd |
foreach my $h (keys %TwoInst) {
|
|
Packit Bot |
ea69bd |
print " $h - $TwoInst{$h} times\n";
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
if (keys %Errors) {
|
|
Packit Bot |
ea69bd |
print "\nErrors\n";
|
|
Packit Bot |
ea69bd |
print " $_: $Errors{$_} time(s)\n" foreach sort keys %Errors;
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
if (keys %ConfErrs) {
|
|
Packit Bot |
ea69bd |
print "\nErrors in configuration file:\n";
|
|
Packit Bot |
ea69bd |
foreach my $k (keys %ConfErrs) {
|
|
Packit Bot |
ea69bd |
print " $k ". $ConfErrs{$k} . " time(s)\n";
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
if (keys %Operations) {
|
|
Packit Bot |
ea69bd |
print "\nOperations not permitted\n";
|
|
Packit Bot |
ea69bd |
foreach my $o (keys %Operations) {
|
|
Packit Bot |
ea69bd |
print " $o ". $Operations{$o} . " time(s)\n";
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
print "\n The clock on a VPS is inherited from the clock on the\n";
|
|
Packit Bot |
ea69bd |
print " hardware node, therefore the ntp-service must be run on\n";
|
|
Packit Bot |
ea69bd |
print " the hardware node, and not the VPS.\n";
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
if (keys %OtherList) {
|
|
Packit Bot |
ea69bd |
print "\n**Unmatched Entries**\n";
|
|
Packit Bot |
ea69bd |
print " $_: $OtherList{$_} time(s)\n" foreach keys %OtherList;
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
exit(0);
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
# vi: shiftwidth=3 tabstop=3 syntax=perl et
|
|
Packit Bot |
ea69bd |
# Local Variables:
|
|
Packit Bot |
ea69bd |
# mode: perl
|
|
Packit Bot |
ea69bd |
# perl-indent-level: 3
|
|
Packit Bot |
ea69bd |
# indent-tabs-mode: nil
|
|
Packit Bot |
ea69bd |
# End:
|