diff options
author | Subhendu Ghosh <sghosh@users.sourceforge.net> | 2002-06-06 04:13:44 +0000 |
---|---|---|
committer | Subhendu Ghosh <sghosh@users.sourceforge.net> | 2002-06-06 04:13:44 +0000 |
commit | 5499b8915e168a97a3f867749bb25a1374c4f06a (patch) | |
tree | c84674233fd98a1604f90f6472ba2069163b8c66 /plugins-scripts/check_ntp.pl | |
parent | 14cd75419d0dd71dcbe6f69abe4ec0f37d2d50e2 (diff) | |
download | monitoring-plugins-5499b8915e168a97a3f867749bb25a1374c4f06a.tar.gz |
conditional on ntpdc
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@43 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins-scripts/check_ntp.pl')
-rwxr-xr-x | plugins-scripts/check_ntp.pl | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/plugins-scripts/check_ntp.pl b/plugins-scripts/check_ntp.pl index f8648345..68acdf65 100755 --- a/plugins-scripts/check_ntp.pl +++ b/plugins-scripts/check_ntp.pl @@ -119,6 +119,12 @@ my $ntpdate_error = $ERRORS{'UNKNOWN'}; 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 { @@ -176,22 +182,25 @@ if ( $? ) { ### 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; } @@ -205,7 +214,7 @@ if ($ntpdate_error != $ERRORS{'OK'}) { $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) { |