diff -ruN nagiosplug-save/contrib/check_remote_nagios_status.pl nagiosplug/contrib/check_remote_nagios_status.pl
--- nagiosplug-save/contrib/check_remote_nagios_status.pl	2003-02-09 14:16:28.000000000 +0000
+++ nagiosplug/contrib/check_remote_nagios_status.pl	2004-03-27 23:02:13.000000000 +0000
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl -wT
 
 # check_status.pl Nagios Plugin - Version 1.3
 # Last Updated: 1/9/2003
@@ -45,36 +45,118 @@
 #
 #############################################################
 
-use Getopt::Long;
+require 5.004;
+use strict;
+use lib utils.pm ;
+use Plugin;
+use Plugin::Parameter qw(:DEFAULT :standard :thresholds);
+
+use vars qw($PROGNAME $verbose $warning $critical $unknown $pattern
+	    $service $status $dir $details $host $freshness $servhost $ack
+	    $dt $hdown $ok);
+
+use utils qw(%ERRORS &usage);
+
 use File::stat;
 
-Getopt::Long::Configure('bundling');
+my $s_opt = new Plugin::Parameter(-name => "status", -flags => [ 's', 'status' ],
+				  -optional => "yes", -valueoptional => "no", -type => "FILENAME",
+				  -binding => \$status,
+				  -description => "Location and name of status log (e.g. /usr/local/nagios/var/status.log)");
+my $d_opt = new Plugin::Parameter(-name => "directory", -flags => [ 'd', 'dir' ],
+				  -optional => "yes", -valueoptional => "no", -type => "DIRECTORY",
+				  -binding => \$dir,
+				  -description => "Directory that contains the nagios logs (e.g. /usr/local/nagios/var/)");
+$w_opt->binding(\$warning);
+$w_opt->description("#: Number of warnings to result in a WARNING state\n\tOR\n\t#,#: Warning,Criticals to result in a WARNING state\n\tOR\n\t#,#,#: Warning,Critical,Unknown to result in a WARNING state");
+$w_opt->default(1);
+$w_opt->optional("yes");
+$c_opt->binding(\$critical);
+$c_opt->description("#: Number of criticals to result in a CRITICAL state\n\tOR\n\t#,#: Warning,Criticals to result in a CRITICAL state\n\tOR\n\t#,#,#: Warning,Critical,Unknown to result in a CRITICAL state");
+$c_opt->default(1);
+$c_opt->optional("yes");
+my $u_opt = new Plugin::Parameter(-name => "unknown", -flags => [ 'u', 'unknown' ],
+				  -optional => "yes", -valueoptional => "no", -type => "STRING",
+				  -binding => \$unknown,
+				  -description => "#: Number of unknowns to result in a UNKNOWN state\n\tOR\n\t#,#: Warning,Criticals to result in a UNKNOWN state\n\tOR\n\t#,#,#: Warning,Critical,Unknown to result in a UNKNOWN state");
+my $S_opt = new Plugin::Parameter(-name => "service", -flags => [ 'S', 'service' ],
+				  -optional => "yes", -valueoptional => "no", -type => "REGEX",
+				  -binding => \$service,
+				  -description => "Only match services [that match the RegEx] (--service is default setting if no other matching arguments provided)");
+my $servhost_opt = new Plugin::Parameter(-name => "servhost", -flags => [ 'servhost' ],
+					 -optional => "yes", -valueoptional => "no", -type => "REGEX",
+					 -binding => \$servhost,
+					 -description => "Only match services whose host match the RegEx");
+my $p_opt = new Plugin::Parameter(-name => "pattern", -flags => [ 'p', 'pattern' ],
+				  -optional => "yes", -valueoptional => "no", -type => "REGEX",
+				  -binding => \$pattern,
+				  -description => "Only parse for this regular expression (services only, not hosts)");
+my $H_opt = new Plugin::Parameter(-name => "host", -flags => [ 'H', 'host' ],
+				  -optional => "yes", -valueoptional => "yes", -type => "REGEX",
+				  -binding => \$host,
+				  -description => "Report on the state of hosts (whose name matches the RegEx if provided");
+my $a_opt = new Plugin::Parameter(-name => "ack", -flags => [ 'a', 'ack' ],
+				  -optional => "yes", -valueoptional => "yes", -type => "ok|warning|critical|unknown|down|unreachable",
+				  -binding => \$ack, -default => "ok",
+				  -checker => sub { my ($opt, $parameter, $plugin) = @_;
+						    if ($$opt !~ m/ok|critical|warning|unknown|down|unreachable/i) {
+						      $plugin->usage();
+						      usage ("$PROGNAME UNKNOWN: --ack must be one of ok|critical|warning|unknown|down|unreachable\n");
+						    }
+						  },
+				  -description => "Handle Acknowledged problems");
+my $dt_opt = new Plugin::Parameter(-name => "downtime", -flags => [ 'dt', 'downtime' ],
+				   -optional => "yes", -valueoptional => "yes", -type => "ok|warning|critical|unknown|down|unreachable",
+				   -binding => \$dt, -default => "ok",
+				  -checker => sub { my ($opt, $parameter, $plugin) = @_;
+						    if ($$opt !~ m/ok|critical|warning|unknown|down|unreachable/i) {
+						      $plugin->usage();
+						      usage ("$PROGNAME UNKNOWN: --downtime must be one of ok|critical|warning|unknown|down|unreachable\n");
+						    }
+						  },
+				  -description => "Handle problems in scheduled downtime");
+my $hd_opt = new Plugin::Parameter(-name => "hostdown", -flags => [ 'hd', 'hostdown' ],
+				   -optional => "yes", -valueoptional => "yes", -type => "ok|warning|critical|unknown|down|unreachable",
+				   -binding => \$hdown, -default => "ok",
+				  -checker => sub { my ($opt, $parameter, $plugin) = @_;
+						    if ($$opt !~ m/ok|critical|warning|unknown|down|unreachable/i) {
+						      $plugin->usage();
+						      usage ("$PROGNAME UNKNOWN: --hostdown must be one of ok|critical|warning|unknown|down|unreachable\n");
+						    }
+						  },
+				  -description => "Handle services whose Host is down");
+my $D_opt = new Plugin::Parameter(-name => "details", -flags => [ 'D', 'details' ],
+				  -optional => "yes", -valueoptional => "no", -type => "INTEGER[,INTEGER]",
+				  -binding => \$details,
+				  -description => "Amount of verbosity to output.\n\tIf # problems:\n\t\t<= 1st integer, return full details (each plugin's output)\n\t\t<= 2nd integer, return some details (list each service host pair)\n\t\t>  2nd integer, return the # of problems");
+my $f_opt = new Plugin::Parameter(-name => "freshness", -flags => [ 'f', 'freshness' ],
+				  -optional => "yes", -valueoptional => "no", -type => "INTEGER",
+				  -binding => \$freshness, -default => 30,
+				  -description => "Number of minutes old the log can be to make sure Nagios is running");
+my $ok_opt =new Plugin::Parameter(-name => "ok", -flags => [ 'ok' ],
+				  -optional => "yes", -valueoptional => "yes", -type => "NONE",
+				  -binding => \$ok,
+				  -description => "Return an OK exit code, regardless of number of problems found");
+my $plugin = new Plugin(-revision => '$Revision: 1.1 $',
+			-copyright => "2003 Russell Scibetti <russell\@quadrix.com>, 2004 Howard Wilkinson <howard\@cohtech.com>",
+			-shortcomment => "This plugin parses through the Nagios status log and will return a Critical, Warning, or Unknown state depending on the number of Critical, Warning, and/or Unknown services found in the log (or Down/Unreachable hosts when matching against hosts)",
+			-longcomment => "For service checking (use --service and/or --servhost):\n1.  The values of warning, critical, and unknown default to 1, i.e. $0 will return CRITICAL if there is at least 1 critical service, WARNING if there is at least 1 warning service, and UNKNOWN if there is at least one unknown service.\n\n2.  If a service's host is DOWN or UNREACHABLE, $PROGNAME will use the value of --hostdown to determine how to treat the service.  Without that argument, $0 will count the service as OK.\n\n3.  If a service's host is OK, but the last host-state change occurred more recently than the last service check, $0 will ignore that service (want to wait until the service has been checked after a host has recovered or you may get service alert for services that still need to be checked)\n\n4.  If the --dt, --ack, or --hd tags are used, $0 will use the value of the arguments to determine how to handle services in downtime, acknowledged, or with down hosts (default=OK). For service checks, --dt will also check if the service's host is in a downtime.\n\nFor host checking (use --host):\n1.  Using the --host argument, $0 will look for DOWN and UNREACHABLE hosts.  If any are found, $0 will return a CRITICAL.  You can provide an REGEX for --host to only check hosts with matching host names.\n\n2.  If the --dt or --ack tags are used, $0 will use the value of the --dt/--ack arguments to determine the state of the host (default is OK)",
+			-checker => sub { my ($plugin) = @_;
+					  if (!$status && !$dir) {
+					    $plugin->usage();
+					    usage ("$PROGNAME UNKNOWN: must specify either --status or --dir\n");
+					  }
+					},
+			-parameterlists => [ [ $s_opt, $d_opt, $w_opt, $c_opt, $u_opt, $S_opt, $servhost_opt, $p_opt, $H_opt, $a_opt, $dt_opt, $hd_opt, $D_opt, $f_opt, $ok_opt, $t_opt ], $h_opts, $V_opts ]);
+
 
-GetOptions
-        ("V"   => \$version, 	"version"       => \$version,
-         "h"   => \$help, 	"help"          => \$help,
-	 "v"   => \$verbose,	"verbose"	=> \$verbose,
-         "w=s" => \$warning, 	"warning=s"     => \$warning,
-         "c=s" => \$critical, 	"critical=s"    => \$critical,
-	 "u=s" => \$unknown, 	"unknown=s"	=> \$unknown,
-	 "p=s" => \$pattern, 	"pattern=s"	=> \$pattern,
-	 "S:s" => \$service,	"service:s"	=> \$service,
-	 "s=s" => \$status,	"status=s"	=> \$status,
-	 "d=s" => \$dir,	"dir=s"		=> \$dir,
-	 "D=s" => \$details,	"details=s"	=> \$details,
-	 "H:s" => \$host,	"host:s" 	=> \$host,
-         "f=s" => \$freshness,  "freshness=s"   => \$freshness,
-	 			"servhost=s" 	=> \$servhost,
-	 "a:s" => \$ack,	"ack:s"		=> \$ack,
-	 "dt:s"=> \$dt,		"downtime:s"	=> \$dt,
-	 "hd:s"=> \$hdown,	"hostdown:s"	=> \$hdown,
-	 			"ok"  		=> \$ok);
+$plugin->init();
 
 #Constants:
-my $OK       = 0;
-my $WARNING  = 1;
-my $CRITICAL = 2;
-my $UNKNOWN  = 3;
+my $OK       = $ERRORS{'OK'};
+my $WARNING  = $ERRORS{'WARNING'};
+my $CRITICAL = $ERRORS{'CRITICAL'};
+my $UNKNOWN  = $ERRORS{'UNKNOWN'};
 
 my $crit="CRITICAL";
 my $warn="WARNING";
@@ -82,30 +164,10 @@
 my $down="DOWN";
 my $unreach="UNREACHABLE";
 
-# Print out Help information
-if ($help) {
-  printVersion();
-  printHelp();
-  exitcheck($UNKNOWN);
-}
-
-# Print out version information
-if ($version) {
-  printVersion();
-  exitcheck($UNKNOWN);
-}
-
-# Check for status log or directory argument or print usage
 if (!$status) {
-  if (!$dir) {
-    print "Usage: $0 -s <status file> | -d <Nagios log dir>\n";
-    print "Use the --help option for full list of arguments\n";
-    exitcheck($UNKNOWN);
-  }
-  elsif ($dir =~ m#[^/]/$#) {
+  if ($dir =~ m#[^/]/$#) {
     $status = $dir . "status.log";
-  }
-  else {
+  } else {
     $status = $dir . "/status.log";
   }
 }
@@ -124,36 +186,6 @@
   $service="[^\\s]*";
 }
 
-if (defined $ack) {
-  if (!$ack) {
-    $ack="ok";
-  }
-  elsif (!($ack =~ "ok|critical|warning|unknown|down|unreachable")) {
-    print "Invalid value for ack\n";
-    exitcheck($UNKNOWN);
-  }
-}
-
-if (defined $dt) {
-  if (!$dt) {
-    $dt="ok";
-  }
-  elsif (!($dt =~ "ok|critical|warning|unknown|down|unreachable")) {
-    print "Invalid value for dt\n";
-    exitcheck($UNKNOWN);
-  }
-}
-
-if (defined $hdown) {
-  if (!$hdown) {
-    $hdown="ok";
-  }
-  elsif (!($hdown =~ "ok|critical|warning|unknown|down|unreachable")) {
-    print "Invalid value for hostdown\n";
-    exitcheck($UNKNOWN);
-  }
-}
-
 my $much_details = 0;
 
 my $ServiceNotOK = "CRITICAL|WARNING|UNKNOWN";
@@ -262,8 +294,8 @@
 
 open("sta","$status") || die "Cannot open status file $status!";
 
-$curr_time = time;
-$file_time = stat($status)->mtime;
+my $curr_time = time;
+my $file_time = stat($status)->mtime;
 
 if ($curr_time - $file_time > $freshness) {
   printf "State CRITICAL - Status file is stale!!!\n";
@@ -273,7 +305,7 @@
 while(<sta>) {
   chomp;
   if (/^[^\s]+[\s]+HOST;/) {
-    @hdata = split /;/,$_;
+    my @hdata = split /;/,$_;
     
 # If you care about matching hosts (not services):
     if ($host && $hdata[1] =~ /$host/) {
@@ -299,7 +331,7 @@
     }
   }
   elsif (!$host && /^[^\s]+[\s]+SERVICE;/) {
-    @servdata = split /;/,$_;
+    my @servdata = split /;/,$_;
     if ( ( $pattern                     && ($_ =~ /$pattern/)) ||
 	 (($servdata[1] =~ /$servhost/) && ($servdata[2] =~ /$service/)) ){
       $nummatch++;
@@ -318,12 +350,7 @@
 }
 
 # Count the number of problems (for reference):
-if ($host) {
-  $total = $numprob{"DOWN"} + $numprob{"UNREACHABLE"};
-} 
-else {
-  $total = $numprob{"WARNING"} + $numprob{"CRITICAL"} +  $numprob{"UNKNOWN"};
-}
+my $total = ($host)?($numprob{"DOWN"} + $numprob{"UNREACHABLE"}):($numprob{"WARNING"} + $numprob{"CRITICAL"} +  $numprob{"UNKNOWN"});
 
 my $numok = $nummatch - $total;
 
@@ -402,7 +429,7 @@
 # Return the proper exit code for Critical, Warning, Unknown, or OK
 sub exitcheck {
   if ($ok) {
-    exit 0;
+    exit $ERRORS{'OK'};
   }
   else {
     exit $_[0];
@@ -453,8 +480,8 @@
 # Add-in the problem found in the status log
 sub addproblem {
 
-  $test = 1;
-  $type = $_[1];
+  my $test = 1;
+  my $type = $_[1];
   my $diffout = "";
 
   my @values = split /;/,$_[0];
@@ -543,124 +570,3 @@
     $numprob{$type}++;
   }
 }
-
-################################
-#
-# Version and Help Information
-#
-################################
-
-sub printVersion {
-  printf <<EndVersion;
-$0 (nagios-plugins) 1.3
-The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute
-copies of the plugins under the terms of the GNU General Public License.
-For more information about these matters, see the file named COPYING.
-EndVersion
-}
-
-sub printHelp {
-  printf <<EOF;
-
-This plugin parses through the Nagios status log and will return a 
-Critical, Warning, or Unknown state depending on the number of 
-Critical, Warning, and/or Unknown services found in the log
-(or Down/Unreachable hosts when matching against hosts)  
-
-Usage: $0 -s <Status File> | -d <Nagios Log Directory> 
-	[-w #[,#][,#]] [-c #[,#][,#]] [-u #[,#][,#]]
-        [--service=<RegEx> | --servhost=<RegEx> | --pattern=<RegEx> |
-	 --host            | --host=<RegEx>]
-        [--ack[=string]]  [--dt[=string]]  [--hostdown[=string]]
-        [-D #[,#]]  [--ok]  [-f <Log freshness in # minutes>]
-       $0 --help
-       $0 --version
-NOTE: One of -s and -d must be specified
-
-Options:
- -s, --status=FILE_NAME
-   Location and name of status log (e.g. /usr/local/nagios/var/status.log)
- -d, --dir=DIRECTORY_NAME
-   Directory that contains the nagios logs (e.g. /usr/local/nagios/var/)
- -w, --warning=INTEGER[,INTEGER][,INTEGER]
-   #:     Number of warnings to result in a WARNING state
-          OR
-   #,#:   Warning,Criticals to result in a WARNING state
-	  OR
-   #,#,#: Warning,Critical,Unknown to result in a WARNING state 
-   Default: -w=1
- -c, --critical=INTEGER[,INTEGER][,INTEGER]
-   #:     Number of criticals to result in a CRITICAL state
-          OR
-   #,#:   Warning,Criticals to result in a CRITICAL state
-          OR
-   #,#,#: Warning,Critical,Unknown to result in a CRITICAL state
-   Default: -c=1
- -u, --unknown=INTEGER[,INTEGER][,INTEGER]
-   #:     Number of unknowns to result in a UNKNOWN state
-          OR
-   #,#:   Warning,Criticals to result in a UNKNOWN state
-          OR
-   #,#,#: Warning,Critical,Unknown to result in a UNKNOWN state
-   Default: -u=1
- -r, --service[=REGEX]
-   Only match services [that match the RegEx]
-   (--service is default setting if no other matching arguments provided)
- --servhost=REGEX
-   Only match services whose host match the RegEx
- -p, --pattern=REGEX
-   Only parse for this regular expression (services only, not hosts)
- --host[=REGEX]
-   Report on the state of hosts (whose name matches the RegEx if provided)
- -a, --ack[=ok|warning|critical|unknown|down|unreachable]
-   Handle Acknowledged problems [--ack defaults to ok]
- --dt, --downtime[=ok|warning|critical|unknown|down|unreachable]
-   Handle problems in scheduled downtime [--dt defaults to ok]
- --hd, --hostdown[=ok|warning|critical|unknown|down|unreachable]
-   Handle services whose Host is down [--hd defaults to ok]
- -D, --details=INTEGER[,INTEGER]
-   Amount of verbosity to output
-   If # problems: 
-    <= 1st integer, return full details (each plugin's output) 
-    <= 2nd integer, return some details (list each service host pair)
-    >  2nd integer, return the # of problems
- -f, --freshness=INTEGER
-   Number of minutes old the log can be to make sure Nagios is running
-   (Default = 30 minutes)
- --ok
-   Return an OK exit code, regardless of number of problems found
- -h, --help
-   Print detailed help screen
- -V, --version
-   Print version information 
-
-For service checking (use --service and/or --servhost): 
-1.  The values of warning, critical, and unknown default to 1, i.e.
-$0 will return CRITICAL if there is at least 1 critical service, 
-WARNING if there is at least 1 warning service, and UNKNOWN if there is
-at least one unknown service.
-
-2.  If a service's host is DOWN or UNREACHABLE, $0 will use the 
-value of --hostdown to determine how to treat the service.  Without that
-argument, $0 will count the service as OK.
-
-3.  If a service's host is OK, but the last host-state change occurred more 
-recently than the last service check, $0 will ignore that service
-(want to wait until the service has been checked after a host has recovered
-or you may get service alert for services that still need to be checked)
-
-4.  If the --dt, --ack, or --hd tags are used, $0 will use the value
-of the arguments to determine how to handle services in downtime, acknowledged,
-or with down hosts (default=OK). For service checks, --dt will also check
-if the service's host is in a downtime.
-
-For host checking (use --host):
-1.  Using the --host argument, $0 will look for DOWN and UNREACHABLE
-hosts.  If any are found, $0 will return a CRITICAL.  You can provide
-an REGEX for --host to only check hosts with matching host names. 
-
-2.  If the --dt or --ack tags are used, $0 will use the value of the
---dt/--ack arguments to determine the state of the host (default is OK)
-
-EOF
-}
