summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 14cd754)
raw | patch | inline | side by side (parent: 14cd754)
author | Subhendu Ghosh <sghosh@users.sourceforge.net> | |
Thu, 6 Jun 2002 04:13:44 +0000 (04:13 +0000) | ||
committer | Subhendu Ghosh <sghosh@users.sourceforge.net> | |
Thu, 6 Jun 2002 04:13:44 +0000 (04:13 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@43 f882894a-f735-0410-b71e-b25c423dba1c
plugins-scripts/check_ntp.pl | patch | blob | history |
index f8648345c54151ae6a8bc061862442663e7e9a87..68acdf65e34c7f3f85f649fdc43b66e03aeebb63 100755 (executable)
my $dispersion_error = $ERRORS{'UNKNOWN'};
my $key = undef;
+# some systems don't have a proper ntpdc/xntpdc
+if ($utils::PATH_TO_NTPDC && -x $utils::PATH_TO_NTPDC ) {
+ my $have_ntpdc = 1;
+}else{
+ my $have_ntpdc = 0;
+}
# Just in case of problems, let's not hang Nagios
$SIG{'ALRM'} = sub {
### and look in the 8th column for dispersion (ntpd v4) or jitter (ntpd v3)
###
-if ( open(NTPDC,"$utils::PATH_TO_NTPDC -s $host 2>&1 |") ) {
- while (<NTPDC>) {
- print $_ if ($verbose);
- if (/([^\s]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)/) {
- if ($8>15) {
- print "Dispersion = $8 \n" if ($verbose);
- $dispersion_error = $ERRORS{'CRITICAL'};
- } elsif ($8>5 && $dispersion_error<$ERRORS{'CRITICAL'}) {
- print "Dispersion = $8 \n" if ($verbose);
- $dispersion_error = $ERRORS{'WARNING'};
- } else {
- $dispersion_error = $ERRORS{'OK'};
+if ($have_ntpdc) {
+
+ if ( open(NTPDC,"$utils::PATH_TO_NTPDC -s $host 2>&1 |") ) {
+ while (<NTPDC>) {
+ print $_ if ($verbose);
+ if (/([^\s]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)/) {
+ if ($8>15) {
+ print "Dispersion = $8 \n" if ($verbose);
+ $dispersion_error = $ERRORS{'CRITICAL'};
+ } elsif ($8>5 && $dispersion_error<$ERRORS{'CRITICAL'}) {
+ print "Dispersion = $8 \n" if ($verbose);
+ $dispersion_error = $ERRORS{'WARNING'};
+ } else {
+ $dispersion_error = $ERRORS{'OK'};
+ }
}
}
+ close NTPDC;
}
- close NTPDC;
}
$answer = "Server error and time difference $offset seconds greater than +/- $warning sec\n";
}
-} elsif ($dispersion_error != $ERRORS{'OK'}) {
+} elsif ($have_ntpdc && $dispersion_error != $ERRORS{'OK'}) {
$state = $dispersion_error;
$answer = "Dispersion too high\n";
if (defined($offset) && abs($offset) > $critical) {