diff options
Diffstat (limited to 'web/attachments/163636-check_ntp.pl.patch')
| -rw-r--r-- | web/attachments/163636-check_ntp.pl.patch | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/web/attachments/163636-check_ntp.pl.patch b/web/attachments/163636-check_ntp.pl.patch new file mode 100644 index 0000000..3ce6b2a --- /dev/null +++ b/web/attachments/163636-check_ntp.pl.patch | |||
| @@ -0,0 +1,75 @@ | |||
| 1 | --- check_ntp.pl.dist 2006-01-16 17:56:25.835790000 +0100 | ||
| 2 | +++ check_ntp.pl 2006-01-16 20:17:39.345787000 +0100 | ||
| 3 | @@ -56,6 +56,12 @@ | ||
| 4 | # changed ntpdc to ntpq - jitter/dispersion is in milliseconds | ||
| 5 | # | ||
| 6 | # Patch for for regex for stratum1 refid. | ||
| 7 | +# | ||
| 8 | +# Modified by Joachim Schrod <jschrod@acm.org>, 16 Jan 06: | ||
| 9 | +# Support multiple peers, don't overwrite jitter value if one was found. | ||
| 10 | +# ntpdate and ntpq may exit with non-zero status, then close() returns false. | ||
| 11 | +# Support FQDN hostnames with one-letter components. | ||
| 12 | +# Support unknown hosts. | ||
| 13 | |||
| 14 | require 5.004; | ||
| 15 | use POSIX; | ||
| 16 | @@ -112,7 +118,7 @@ | ||
| 17 | } | ||
| 18 | |||
| 19 | $opt_H = shift unless ($opt_H); | ||
| 20 | -my $host = $1 if ($opt_H && $opt_H =~ m/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|[a-zA-Z][-a-zA-Z0-9]+(\.[a-zA-Z][-a-zA-Z0-9]+)*)$/); | ||
| 21 | +my $host = $1 if ($opt_H && $opt_H =~ m/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|[a-zA-Z][-a-zA-Z0-9]*(\.[a-zA-Z][-a-zA-Z0-9]*)*)$/); | ||
| 22 | unless ($host) { | ||
| 23 | print "No target host specified\n"; | ||
| 24 | print_usage(); | ||
| 25 | @@ -242,11 +248,15 @@ | ||
| 26 | } | ||
| 27 | } | ||
| 28 | |||
| 29 | + if (/can\'t find host/) { | ||
| 30 | + $ntpdate_error = $ERRORS{"CRITICAL"}; | ||
| 31 | + $msg = "Host not found - "; | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | } | ||
| 35 | $out =~ s/\n//g; | ||
| 36 | -close (NTPDATE) || | ||
| 37 | - die $! ? "$out - Error closing $ntpdate pipe: $!" | ||
| 38 | - : "$out - Exit status: $? from $ntpdate\n"; | ||
| 39 | +close (NTPDATE) or | ||
| 40 | + $! and die "$out - Error closing $ntpdate pipe: $!\n"; | ||
| 41 | |||
| 42 | # declare an error if we also get a non-zero return code from ntpdate | ||
| 43 | # unless already set to critical | ||
| 44 | @@ -314,13 +324,11 @@ | ||
| 45 | } | ||
| 46 | } else { | ||
| 47 | print "No match!\n" if $verbose; | ||
| 48 | - $jitter = '(not parsed)'; | ||
| 49 | } | ||
| 50 | |||
| 51 | } | ||
| 52 | - close NTPQ || | ||
| 53 | - die $! ? "Error closing $ntpq pipe: $!" | ||
| 54 | - : "Exit status: $? from $ntpq\n"; | ||
| 55 | + close NTPQ or | ||
| 56 | + $! and die "Error closing $ntpq pipe: $!\n"; | ||
| 57 | |||
| 58 | # if we did not match sys.peer or pps.peer but matched # candidates only | ||
| 59 | # generate a warning | ||
| 60 | @@ -428,7 +436,14 @@ | ||
| 61 | foreach my $key (keys %ERRORS) { | ||
| 62 | if ($state==$ERRORS{$key}) { | ||
| 63 | # print ("NTP $key: $answer"); | ||
| 64 | - print ("NTP $key: $answer|offset=$offset, jitter=" . $jitter/1000 . ",peer_stratum=$stratum\n"); | ||
| 65 | + defined($offset) or $offset = '-'; | ||
| 66 | + defined($stratum) or $stratum = '-'; | ||
| 67 | + if (defined($jitter)) { | ||
| 68 | + $jitter /= 1000; | ||
| 69 | + } else { | ||
| 70 | + $jitter = '-'; | ||
| 71 | + } | ||
| 72 | + print ("NTP $key: $answer|offset=$offset, jitter=$jitter, peer_stratum=$stratum\n"); | ||
| 73 | last; | ||
| 74 | } | ||
| 75 | } | ||
