X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins-scripts%2Fcheck_ntp.pl;h=5c87e0a66e66ba003b9d3b6597c0d0fd086a9993;hb=c326b4dc1dd42a50875578f0e7580125a1ddc03c;hp=d6584aea7316a4512883e7fb4b444c417600fa8c;hpb=703a4bf74de4786b352b8582eb6c018cff353164;p=nagiosplug.git diff --git a/plugins-scripts/check_ntp.pl b/plugins-scripts/check_ntp.pl index d6584ae..5c87e0a 100755 --- a/plugins-scripts/check_ntp.pl +++ b/plugins-scripts/check_ntp.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -w - +# # (c)1999 Ian Cass, Knowledge Matters Ltd. # Read the GNU copyright stuff for all the legalese # @@ -7,7 +7,6 @@ # be installed on the system, however since it's part of the ntp suite, you # should already have it installed. # -# $Id$ # # Nothing clever done in this program - its a very simple bare basics hack to # get the job done. @@ -97,7 +96,7 @@ GetOptions "H=s" => \$opt_H, "hostname=s" => \$opt_H); if ($opt_V) { - print_revision($PROGNAME,'$Revision$ '); + print_revision($PROGNAME,'@NP_VERSION@'); exit $ERRORS{'OK'}; } @@ -200,13 +199,15 @@ elsif ($ipv6) { ### if (!open (NTPDATE, $ntpdate . " -q $host 2>&1 |")) { - print "Could not open ntpdate\n"; + print "Could not open $ntpdate: $!\n"; exit $ERRORS{"UNKNOWN"}; } +my $out; while () { #print if ($verbose); # noop $msg = $_ unless ($msg); + $out .= "$_ "; if (/stratum\s(\d+)/) { $stratum = $1; @@ -241,8 +242,11 @@ while () { } } +$out =~ s/\n//g; +close (NTPDATE) || + die $! ? "$out - Error closing $ntpdate pipe: $!" + : "$out - Exit status: $? from $ntpdate\n"; -close (NTPDATE); # declare an error if we also get a non-zero return code from ntpdate # unless already set to critical if ( $? && !$ignoreret ) { @@ -293,7 +297,7 @@ if ($have_ntpq) { } # match sys.peer or pps.peer - if (/^(\*|o)([-0-9.\s]+)\s+([-0-9A-Za-z_().]+)\s+([-0-9.]+)\s+([lumb-]+)\s+([-0-9hm.]+)\s+([-0-9.mh]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)/) { + if (/^(\*|o)(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)/) { $syspeer = $2; $stratum = $4; $jitter = $11; @@ -313,7 +317,9 @@ if ($have_ntpq) { } } - close NTPQ; + close NTPQ || + die $! ? "Error closing $ntpq pipe: $!" + : "Exit status: $? from $ntpq\n"; # if we did not match sys.peer or pps.peer but matched # candidates only # generate a warning @@ -436,7 +442,7 @@ sub print_usage () { } sub print_help () { - print_revision($PROGNAME,'$Revision$'); + print_revision($PROGNAME,'@NP_VERSION@'); print "Copyright (c) 2003 Bo Kersey/Karl DeBisschop\n"; print "\n"; print_usage();