diff -ruN nagiosplug-save/plugins-scripts/check_ntp.pl nagiosplug/plugins-scripts/check_ntp.pl
--- nagiosplug-save/plugins-scripts/check_ntp.pl	2003-10-14 03:40:31.000000000 +0100
+++ nagiosplug/plugins-scripts/check_ntp.pl	2004-03-27 22:49:01.000000000 +0000
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl -wT
 
 # (c)1999 Ian Cass, Knowledge Matters Ltd.
 # Read the GNU copyright stuff for all the legalese
@@ -60,94 +60,55 @@
 require 5.004;
 use POSIX;
 use strict;
-use Getopt::Long;
-use vars qw($opt_V $opt_h $opt_H $opt_t $opt_w $opt_c $opt_j $opt_k $verbose $PROGNAME $def_jitter);
-use lib utils.pm; 
-use utils qw($TIMEOUT %ERRORS &print_revision &support);
-
-$PROGNAME="check_ntp";
-
-sub print_help ();
-sub print_usage ();
-
+use lib utils.pm ;
+use Plugin;
+use Plugin::Parameter qw(:DEFAULT :standard :thresholds);
+
+use vars qw($opt_H $opt_t $opt_w $opt_c $opt_j $opt_k $opt_v $PROGNAME $def_jitter);
+
+use utils qw(%ERRORS);
+
+$w_opt->default(60);
+$w_opt->description("Clock offset in seconds at which a warning message will be generated");
+$c_opt->default(120);
+$c_opt->description("Clock offset in seconds at which a critical message will be generated");
+my $j_opt = new Plugin::Parameter(-name => "jwarn", -flags => [ 'j', 'jwarn' ],
+				  -optional => "yes", -valueoptional => "no", -type => "INTEGER",
+				  -default => 5000,
+				  -description => "Clock jitter in milliseconds at which a warning message will be generated");
+my $k_opt = new Plugin::Parameter(-name => "jcrit", -flags => [ 'k', 'jcrit' ],
+				  -optional => "yes", -valueoptional => "no", -type => "INTEGER",
+				  -default => 10000,
+				  -description => "Clock jitter in milliseconds at which a critical message will be generated");
+my $plugin = new Plugin(-revision => '$Revision: 1.19 $',
+			-copyright => "2003 Bo Kersey/Karl DeBisschop, 2004 Howard Wilkinson <howard\@cohtech.com>",
+			-shortcomment => "Checks the local timestamp offset versus <host> with ntpdate. Check the jitter/dispersion of clock signal between <host> and its sys.peer with ntpq",
+			-longcomment => "If jitter/dispersion is specified with -j or -k and ntpq times out, then a warning is returned",
+			-parameterlists => [ [ $H_opt, $w_opt, $c_opt, $j_opt, $k_opt, $t_opt, $v_opt ], $h_opts, $V_opts ]);
 $ENV{'PATH'}='';
 $ENV{'BASH_ENV'}='';
 $ENV{'ENV'}='';
 
-# defaults in sec
-my $DEFAULT_OFFSET_WARN =  60;  # 1 minute
-my $DEFAULT_OFFSET_CRIT = 120;  # 2 minutes
-# default in millisec
-my $DEFAULT_JITTER_WARN =   5000; # 5 sec
-my $DEFAULT_JITTER_CRIT =  10000; # 10 sec
-
-Getopt::Long::Configure('bundling');
-GetOptions
-	("V"   => \$opt_V, "version"    => \$opt_V,
-	 "h"   => \$opt_h, "help"       => \$opt_h,
-	 "v" => \$verbose, "verbose"  	=> \$verbose,
-	 "w=f" => \$opt_w, "warning=f"  => \$opt_w,   # offset|adjust warning if above this number
-	 "c=f" => \$opt_c, "critical=f" => \$opt_c,   # offset|adjust critical if above this number
-	 "j=s" => \$opt_j, "jwarn=i"    => \$opt_j,   # jitter warning if above this number
-	 "k=s" => \$opt_k, "jcrit=i"    => \$opt_k,   # jitter critical if above this number
-	 "t=s" => \$opt_t, "timeout=i"  => \$opt_t,
-	 "H=s" => \$opt_H, "hostname=s" => \$opt_H);
-
-if ($opt_V) {
-	print_revision($PROGNAME,'$Revision: 1.19 $ ');
-	exit $ERRORS{'OK'};
-}
-
-if ($opt_h) {
-	print_help();
-	exit $ERRORS{'OK'};
-}
+$plugin->init();
 
 # jitter test params specified
 if (defined $opt_j || defined $opt_k ) {
 	$def_jitter = 1;
 }
 
-$opt_H = shift unless ($opt_H);
-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]+)*)$/);
-unless ($host) {
-	print "No target host specified\n";
-	print_usage();
-	exit $ERRORS{'UNKNOWN'};
-}
-
-my ($timeout, $owarn, $ocrit, $jwarn, $jcrit);
-
-$timeout = $TIMEOUT;
-($opt_t) && ($opt_t =~ /^([0-9]+)$/) && ($timeout = $1);
-
-$owarn = $DEFAULT_OFFSET_WARN;
-($opt_w) && ($opt_w =~ /^([0-9.]+)$/) && ($owarn = $1);
-
-$ocrit = $DEFAULT_OFFSET_CRIT;
-($opt_c) && ($opt_c =~ /^([0-9.]+)$/) && ($ocrit = $1);
 
-$jwarn = $DEFAULT_JITTER_WARN;
-($opt_j) && ($opt_j =~ /^([0-9]+)$/) && ($jwarn = $1);
-
-$jcrit = $DEFAULT_JITTER_CRIT;
-($opt_k) && ($opt_k =~ /^([0-9]+)$/) && ($jcrit = $1);
-
-if ($ocrit < $owarn ) {
-	print "Critical offset should be larger than warning offset\n";
-	print_usage();
-	exit $ERRORS{"UNKNOWN"};
+if ($opt_c < $opt_w ) {
+	$plugin->usage();
+	usage("$PROGNAME UNKNOWN: Critical offset should be larger than warning offset\n");
 }
 
 if ($def_jitter) {
 	if ($opt_k < $opt_j) {
-		print "Critical jitter should be larger than warning jitter\n";
-		print_usage();
-		exit $ERRORS{'UNKNOWN'};
+		$plugin->usage();
+		usage("$PROGNAME UNKNOWN: Critical jitter should be larger than warning jitter\n");
 	}
 }
 
-
 my $stratum = -1;
 my $ignoreret = 0;
 my $answer = undef;
@@ -170,13 +131,7 @@
 	$have_ntpq = 0;
 }
 
-# Just in case of problems, let's not hang Nagios
-$SIG{'ALRM'} = sub {
-	print ("ERROR: No response from ntp server (alarm)\n");
-	exit $ERRORS{"UNKNOWN"};
-};
-alarm($timeout);
-
+$plugin->start_timeout($opt_t, "No response from ntp server (alarm)");
 
 ###
 ###
@@ -184,13 +139,13 @@
 ###
 ###
 
-if (!open (NTPDATE, "$utils::PATH_TO_NTPDATE -q $host 2>&1 |")) {
-	print "Could not open ntpdate\n";
-	exit $ERRORS{"UNKNOWN"};
+if (!open (NTPDATE, "$utils::PATH_TO_NTPDATE -q $opt_H 2>&1 |")) {
+        $plugin->usage();
+	usage("$PROGNAME UNKNOWN: Could not open ntpdate\n");
 }
 
 while (<NTPDATE>) {
-	print if ($verbose);
+	print if ($opt_v);
 	$msg = $_ unless ($msg);
 	
 	if (/stratum\s(\d+)/) {
@@ -205,7 +160,7 @@
 		if ($offset == 0) { undef $offset;}
 
 		$ntpdate_error = defined ($offset) ? $ERRORS{"OK"} : $ERRORS{"CRITICAL"};
-		print "ntperr = $ntpdate_error \n" if $verbose;
+		print "ntperr = $ntpdate_error \n" if $opt_v;
 	
 	}
 
@@ -227,9 +182,9 @@
 # declare an error if we also get a non-zero return code from ntpdate
 # unless already set to critical
 if ( $? && !$ignoreret ) {
-	print "stderr = $? : $! \n" if $verbose;
+	print "stderr = $? : $! \n" if $opt_v;
 	$ntpdate_error = $ntpdate_error == $ERRORS{"CRITICAL"} ? $ERRORS{"CRITICAL"} : $ERRORS{"UNKNOWN"}  ;
-	print "ntperr = $ntpdate_error : $!\n" if $verbose;
+	print "ntperr = $ntpdate_error : $!\n" if $opt_v;
 }
 
 ###
@@ -259,9 +214,9 @@
 
 if ($have_ntpq) {
 
-	if ( open(NTPQ,"$utils::PATH_TO_NTPQ -np $host 2>&1 |") ) {
+	if ( open(NTPQ,"$utils::PATH_TO_NTPQ -np $opt_H 2>&1 |") ) {
 		while (<NTPQ>) {
-			print $_ if ($verbose);
+			print $_ if ($opt_v);
 			if ( /timed out/ ){
 				$have_ntpq = 0 ;
 				last ;
@@ -270,7 +225,7 @@
 			if (/^(\*|\+|\#|o])/) {
 				++$candidate;
 				push (@candidates, $_);
-				print "Candiate count= $candidate\n" if ($verbose);
+				print "Candiate count= $candidate\n" if ($opt_v);
 			}
 			
 			# match sys.peer or pps.peer
@@ -278,12 +233,12 @@
 				$syspeer = $2;
 				$stratum = $4;
 				$jitter = $11;
-				print "match $_ \n" if $verbose;
-				if ($jitter > $jcrit) {
-					print "Jitter_crit = $11 :$jcrit\n" if ($verbose);
+				print "match $_ \n" if $opt_v;
+				if ($jitter > $opt_k) {
+					print "Jitter_crit = $11 :$opt_k\n" if ($opt_v);
 					$jitter_error = $ERRORS{'CRITICAL'};
-				} elsif ($jitter > $jwarn ) {
-					print "Jitter_warn = $11 :$jwarn \n" if ($verbose);
+				} elsif ($jitter > $opt_j ) {
+					print "Jitter_warn = $11 :$opt_j \n" if ($opt_v);
 					$jitter_error = $ERRORS{'WARNING'};
 				} else {
 					$jitter_error = $ERRORS{'OK'};
@@ -303,12 +258,12 @@
 					$syspeer = $2;
 					$stratum = $4;
 					$jitter = $11;
-					print "candidate match $c \n" if $verbose;
-					if ($jitter > $jcrit) {
-						print "Candidate match - Jitter_crit = $11 :$jcrit\n" if ($verbose);
+					print "candidate match $c \n" if $opt_v;
+					if ($jitter > $opt_k) {
+						print "Candidate match - Jitter_crit = $11 :$opt_k\n" if ($opt_v);
 						$jitter_error = $ERRORS{'CRITICAL'};
-					}elsif ($jitter > $jwarn ) {
-						print "Candidate match - Jitter_warn = $11 :$jwarn \n" if ($verbose);
+					}elsif ($jitter > $opt_j ) {
+						print "Candidate match - Jitter_warn = $11 :$opt_j \n" if ($opt_v);
 						$jitter_error = $ERRORS{'WARNING'};
 					} else {
 						$jitter_error = $ERRORS{'WARNING'};
@@ -330,41 +285,41 @@
 		$answer = $msg . "Server for ntp probably down\n";
 	}
 
-	if (defined($offset) && abs($offset) > $ocrit) {
+	if (defined($offset) && abs($offset) > $opt_c) {
 		$state = $ERRORS{'CRITICAL'};
-		$answer = "Server Error and offset $offset sec > +/- $ocrit sec\n";
-	} elsif (defined($offset) && abs($offset) > $owarn) {
-		$answer = "Server error and offset $offset sec > +/- $owarn sec\n";
-	} elsif (defined($jitter) && abs($jitter) > $jcrit) {
-		$answer = "Server error and jitter $jitter msec > +/- $jcrit msec\n";
-	} elsif (defined($jitter) && abs($jitter) > $jwarn) {
-		$answer = "Server error and jitter $jitter msec > +/- $jwarn msec\n";
+		$answer = "Server Error and offset $offset sec > +/- $opt_c sec\n";
+	} elsif (defined($offset) && abs($offset) > $opt_w) {
+		$answer = "Server error and offset $offset sec > +/- $opt_w sec\n";
+	} elsif (defined($jitter) && abs($jitter) > $opt_k) {
+		$answer = "Server error and jitter $jitter msec > +/- $opt_k msec\n";
+	} elsif (defined($jitter) && abs($jitter) > $opt_j) {
+		$answer = "Server error and jitter $jitter msec > +/- $opt_j msec\n";
 	}
 
 } elsif ($have_ntpq && $jitter_error != $ERRORS{'OK'}) {
 	$state = $jitter_error;
 	$answer = "Jitter $jitter too high\n";
-	if (defined($offset) && abs($offset) > $ocrit) {
+	if (defined($offset) && abs($offset) > $opt_c) {
 		$state = $ERRORS{'CRITICAL'};
-		$answer = "Jitter error and offset $offset sec > +/- $ocrit sec\n";
-	} elsif (defined($offset) && abs($offset) > $owarn) {
-		$answer = "Jitter error and offset $offset sec > +/- $owarn sec\n";
-	} elsif (defined($jitter) && abs($jitter) > $jcrit) {
-		$answer = "Jitter error and jitter $jitter msec > +/- $jcrit msec\n";
-	} elsif (defined($jitter) && abs($jitter) > $jwarn) {
-		$answer = "Jitter error and jitter $jitter msec > +/- $jwarn msec\n";
+		$answer = "Jitter error and offset $offset sec > +/- $opt_c sec\n";
+	} elsif (defined($offset) && abs($offset) > $opt_w) {
+		$answer = "Jitter error and offset $offset sec > +/- $opt_w sec\n";
+	} elsif (defined($jitter) && abs($jitter) > $opt_k) {
+		$answer = "Jitter error and jitter $jitter msec > +/- $opt_k msec\n";
+	} elsif (defined($jitter) && abs($jitter) > $opt_j) {
+		$answer = "Jitter error and jitter $jitter msec > +/- $opt_j msec\n";
 	}
 
 } elsif( !$have_ntpq ) { # no errors from ntpdate and no ntpq or ntpq timed out
-	if (abs($offset) > $ocrit) {
+	if (abs($offset) > $opt_c) {
 		$state = $ERRORS{'CRITICAL'};
-		$answer = "Offset $offset msec > +/- $ocrit sec\n";
-	} elsif (abs($offset) > $owarn) {
+		$answer = "Offset $offset msec > +/- $opt_c sec\n";
+	} elsif (abs($offset) > $opt_w) {
 		$state = $ERRORS{'WARNING'};
-		$answer = "Offset $offset msec > +/- $owarn sec\n";
-	} elsif (( abs($offset) > $owarn) && $def_jitter ) {
+		$answer = "Offset $offset msec > +/- $opt_w sec\n";
+	} elsif (( abs($offset) > $opt_w) && $def_jitter ) {
 		$state = $ERRORS{'WARNING'};
-		$answer = "Offset $offset msec > +/- $owarn sec, ntpq timed out\n";
+		$answer = "Offset $offset msec > +/- $opt_w sec, ntpq timed out\n";
 	} elsif ( $def_jitter ) {
 		$state = $ERRORS{'WARNING'};
 		$answer = "Offset $offset secs, ntpq timed out\n";
@@ -376,18 +331,18 @@
 
 
 } else { # no errors from ntpdate or ntpq
-	if (abs($offset) > $ocrit) {
+	if (abs($offset) > $opt_c) {
 		$state = $ERRORS{'CRITICAL'};
-		$answer = "Offset $offset msec > +/- $ocrit sec, jitter $jitter msec\n";
-	} elsif (abs($jitter) > $jcrit ) {
+		$answer = "Offset $offset msec > +/- $opt_c sec, jitter $jitter msec\n";
+	} elsif (abs($jitter) > $opt_k ) {
 		$state = $ERRORS{'CRITICAL'};
-		$answer = "Jitter $jitter msec> +/- $jcrit msec, offset $offset sec \n";
-	} elsif (abs($offset) > $owarn) {
+		$answer = "Jitter $jitter msec> +/- $opt_k msec, offset $offset sec \n";
+	} elsif (abs($offset) > $opt_w) {
 		$state = $ERRORS{'WARNING'};
-		$answer = "Offset $offset msec > +/- $owarn sec, jitter $jitter msec\n";
-	} elsif (abs($jitter) > $jwarn ) {
+		$answer = "Offset $offset msec > +/- $opt_w sec, jitter $jitter msec\n";
+	} elsif (abs($jitter) > $opt_j ) {
 		$state = $ERRORS{'WARNING'};
-		$answer = "Jitter $jitter msec> +/- $jwarn msec, offset $offset sec \n";
+		$answer = "Jitter $jitter msec> +/- $opt_j msec, offset $offset sec \n";
 
 	} else {
 		$state = $ERRORS{'OK'};
@@ -398,39 +353,8 @@
 
 foreach my $key (keys %ERRORS) {
 	if ($state==$ERRORS{$key}) {
-		print ("NTP $key: $answer");
+		print ("$PROGNAME $key: $answer");
 		last;
 	}
 }
 exit $state;
-
-
-####
-#### subs
-
-sub print_usage () {
-	print "Usage: $PROGNAME -H <host> [-w <warn>] [-c <crit>] [-j <warn>] [-k <crit>] [-v verbose]\n";
-}
-
-sub print_help () {
-	print_revision($PROGNAME,'$Revision: 1.19 $');
-	print "Copyright (c) 2003 Bo Kersey/Karl DeBisschop\n";
-	print "\n";
-	print_usage();
-	print "
-Checks the local timestamp offset versus <host> with ntpdate
-Checks the jitter/dispersion of clock signal between <host> and its sys.peer with ntpq\n
--w ( --warning)
-     Clock offset in seconds at which a warning message will be generated.\n	Defaults to $DEFAULT_OFFSET_WARN.
--c (--critical) 
-     Clock offset in seconds at which a critical message will be generated.\n	Defaults to $DEFAULT_OFFSET_CRIT.
--j (--jwarn)
-     Clock jitter in milliseconds at which a warning message will be generated.\n	Defaults to $DEFAULT_JITTER_WARN.
--k (--jcrit)
-    Clock jitter in milliseconds at which a warning message will be generated.\n	Defaults to $DEFAULT_JITTER_CRIT.\n
-    
-    If jitter/dispersion is specified with -j or -k and ntpq times out, then a
-    warning is returned.
-";	
-support();
-}
