1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-10-21 20:38:45 +00:00
freebsd-ports/net/netsaint-plugins/files/patch-check_ntp.pl
Jun Kuriyama dc1f97b45e Bump PORTREVISION.
check_snmp calls snmpget without '-c' parameter, which is mandatory
with NetSNMP 5.x. Add '-c' to the command line to make it work with
both NetSNMP 4.x and 5.x.

check_by_ssh dumps core with called without -C, also usage help output
does not document -C and -v.

check_ssh plugin incorrectly parses the SSH banner.

check_ntp does not work with NTP v2. Add -n option to be able to
select NTP version.

Submitted by:	David Douthitt <n9ubh@callsign.net>,
		Jens Trzaska <jt@barfoos.de> (check_snmp) via maintainer
2002-06-24 01:59:54 +00:00

77 lines
2.3 KiB
Perl

--- plugins-scripts/check_ntp.pl.orig Sun Jun 23 14:28:03 2002
+++ plugins-scripts/check_ntp.pl Sun Jun 23 14:28:27 2002
@@ -44,6 +44,10 @@
# o Server has correct time but isn't suitable synchronization
# source. This happens while starting up and if contact
# with master has been lost.
+#
+# (c) 2001 David Douthitt <n9ubh@callsign.net>
+#
+# Script modified to handle NTP v2 with new -n parameter
BEGIN {
if ($0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/) {
@@ -56,7 +60,7 @@
use POSIX;
use strict;
use Getopt::Long;
-use vars qw($opt_H $opt_w $opt_c $verbose $PROGNAME);
+use vars qw($opt_n $opt_H $opt_w $opt_c $verbose $PROGNAME);
use lib $main::runtimedir;
use utils qw($TIMEOUT %ERRORS &print_revision &usage &support &is_error);
@@ -69,6 +73,7 @@
sub version ();
delete @ENV{'PATH', 'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
+$ENV{'PATH'} = "/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin";
Getopt::Long::Configure('bundling', 'no_ignore_case');
GetOptions
@@ -77,6 +82,7 @@
"v|verbose" => \$verbose,
"w|warning=s" => \$opt_w,
"c|critical=s" => \$opt_c,
+ "n|ntpversion" => \$opt_n,
"H|hostname=s" => \$opt_H);
($opt_H) || ($opt_H = shift) || usage("Host name/address not specified\n");
@@ -93,6 +99,9 @@
($opt_c) || ($opt_c = shift) || ($opt_c = 120);
my $critical = $1 if ($opt_c =~ /([0-9]+)/);
+($opt_n) || ($opt_n = shift) || ($opt_n = 3);
+my $ntp_version = $1 if ($opt_n =~ /([0-9])/);
+
my $answer = undef;
my $offset = undef;
my $msg; # first line of output to print if format is invalid
@@ -117,7 +126,7 @@
###
###
-if (!open (NTPDATE, "/usr/local/sbin/ntpdate -q $host 2>&1 |")) {
+if (!open (NTPDATE, "ntpdate -o$ntp_version -q $host 2>&1 |")) {
print "Could not open ntpdate\n";
exit $ERRORS{"UNKNOWN"};
}
@@ -154,8 +163,7 @@
###
###
-if (open(NTPDC,"/usr/sbin/xntpdc -c peers $host 2>&1 |") ||
- open(NTPDC,"/usr/sbin/ntpdc -c peers $host 2>&1 |")) {
+if (open(NTPDC,"/usr/sbin/ntpdc -c peers $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.]+)/) {
@@ -224,7 +232,7 @@
exit $state;
sub print_usage () {
- print "Usage: $PROGNAME -H <host> [-w <warn>] [-c <crit>]\n";
+ print "Usage: $PROGNAME -H <host> [ -n <ntp_version> ] [-w <warn>] [-c <crit>]\n";
}
sub print_help () {