index d6584aea7316a4512883e7fb4b444c417600fa8c..5c87e0a66e66ba003b9d3b6597c0d0fd086a9993 100755 (executable)
#!/usr/bin/perl -w
#!/usr/bin/perl -w
-
+#
# (c)1999 Ian Cass, Knowledge Matters Ltd.
# Read the GNU copyright stuff for all the legalese
#
# (c)1999 Ian Cass, Knowledge Matters Ltd.
# Read the GNU copyright stuff for all the legalese
#
# be installed on the system, however since it's part of the ntp suite, you
# should already have it installed.
#
# 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.
#
# Nothing clever done in this program - its a very simple bare basics hack to
# get the job done.
"H=s" => \$opt_H, "hostname=s" => \$opt_H);
if ($opt_V) {
"H=s" => \$opt_H, "hostname=s" => \$opt_H);
if ($opt_V) {
- print_revision($PROGNAME,'$Revision$ ');
+ print_revision($PROGNAME,'@NP_VERSION@');
exit $ERRORS{'OK'};
}
exit $ERRORS{'OK'};
}
###
if (!open (NTPDATE, $ntpdate . " -q $host 2>&1 |")) {
###
if (!open (NTPDATE, $ntpdate . " -q $host 2>&1 |")) {
- print "Could not open ntpdate\n";
+ print "Could not open $ntpdate: $!\n";
exit $ERRORS{"UNKNOWN"};
}
exit $ERRORS{"UNKNOWN"};
}
+my $out;
while (<NTPDATE>) {
#print if ($verbose); # noop
$msg = $_ unless ($msg);
while (<NTPDATE>) {
#print if ($verbose); # noop
$msg = $_ unless ($msg);
+ $out .= "$_ ";
if (/stratum\s(\d+)/) {
$stratum = $1;
if (/stratum\s(\d+)/) {
$stratum = $1;
}
}
}
}
+$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 ) {
# declare an error if we also get a non-zero return code from ntpdate
# unless already set to critical
if ( $? && !$ignoreret ) {
}
# match sys.peer or pps.peer
}
# 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;
$syspeer = $2;
$stratum = $4;
$jitter = $11;
}
}
}
}
- 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
# if we did not match sys.peer or pps.peer but matched # candidates only
# generate a warning
}
sub print_help () {
}
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();
print "Copyright (c) 2003 Bo Kersey/Karl DeBisschop\n";
print "\n";
print_usage();