diff -ruN nagiosplug-save/contrib/check_nwstat.pl nagiosplug/contrib/check_nwstat.pl
--- nagiosplug-save/contrib/check_nwstat.pl	2002-02-28 06:42:54.000000000 +0000
+++ nagiosplug/contrib/check_nwstat.pl	2004-03-27 22:45:52.000000000 +0000
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/perl -wT
 #
 #  check_nwstat.pl: Nagios plugin that uses Jim Drews' nwstat.pl for
 #     MRTG instead of emulating it.  For use particularly with Cliff
@@ -13,18 +13,34 @@
 #  Configuration
 ######################################################################
 
-$nwstatcmd = "/apps/mrtg/helpers/nwstat.pl";
+require 5.004;
+use strict;
+use lib utils.pm ;
+use Plugin;
+use Plugin::Parameter qw(:DEFAULT :thresholds);
+
+use vars qw($opt_H $opt_v $opt_w $opt_c $opt_t $opt_url $PROGNAME);
+
+use utils qw(%ERRORS);
+
+my $var_opt = new Plugin::Parameter(-name => "variable", -flags => [ 'v', 'variable' ],
+				    -optional => "no", -valueoptional => "no", -type => "VARIABLE",
+				    -description => "Variable to check. Valid variables include: LOAD1 = 1 minute average CPU load, LOAD5 = 5 minute average CPU load, LOAD15 = 15 minutes average CPU load, CONNS = number of currently licensed connections, VPF<vol> = percent free space on volume <vol>, VKF<vol> = KB of free space on volume <vol>, LTCH = percent long term cache hits, CBUFF = current number of cache buffers, CDBUFF = current number of dirty cache buffers, LRUM = LRU sitting time in minutes");
+$w_opt->description("Threshold for value necessary to result in a warning status");
+$c_opt->description("Threshold for value necessary to resul tin a critical status");
+$t_opt->flags([ 't', 'to', 'timeout' ]);
+my $url_opt = new Plugin::Parameter(-name => "url", -flags => [ 'url' ],
+				    -optional => "yes", -valueoptional => "no", -type => "URL",
+				    -description => "URL to use in output as a hyperlink. Useful to link to a page with more details or history for this variable (e.g. a MRTG page)");
+my $plugin = new Plugin(-revision => '$Revision: 1.1.1.1 $',
+			-copyright => "2000 Cliff Woolley, 2004 Howard Wilkinson <howard\@cohtech.com>",
+			-shortcomment => "This plugin attempts to contact the MRTGEXT NLM running on a Novell server to gather the requested system information.",
+			-longcomment => "Notes: This plugin requres that the MRTGEXT.NLM file distributed with James Drews' MRTG extension for NetWare (available from http://www.engr.wisc.edu/~drews/mrtg/) be loaded on the Novell servers you wish to check. Critical thresholds should be lower than warning thresholds when the following variables are checked: VPF, VKF, LTCH, CBUFF, and LRUM.",
+			-parameterlists => [ [ $H_opt, $var_opt, $w_opt, $c_opt, $t_opt, $url_opt ], $h_opts, $V_opts ]);
 
-use Getopt::Long;
+my $nwstatcmd = "/apps/mrtg/helpers/nwstat.pl";
 
-$::host      = shift || &usage(%ERROR);
-$::opt_v     = undef;
-$::opt_wv    = undef;
-$::opt_cv    = undef;
-$::opt_to    = 10;
-$::opt_url   = undef;
-
-GetOptions (qw(v=s wv=i cv=i to=i url=s)) || &usage(%ERROR);
+$plugin->init();
 
 my $cmd1     = "";
 my $cmd2     = "ZERO";
@@ -34,25 +50,17 @@
 my $probstr  = "Problem";
 my $result   = "";
 my @CMD;
-my %ERROR    = ("UNKNOWN"   => -1,
-                "OK"        =>  0,
-                "WARNING"   =>  1,
-                "CRITICAL"  =>  2);
-my $status   = $ERROR{"OK"};
+
+my $status   = 'OK';
 
 
 ######################################################################
 #  Main program
 ######################################################################
 
-$SIG{'ALRM'} = sub { 
-    print "Connection timed out\n";
-    exit $ERROR{"CRITICAL"};
-};
-
 # translate table for compatability with
 # check_nwstat (C version)
-SWITCH: for ($::opt_v) {
+SWITCH: for ($opt_v) {
            /^LOAD(1|5|15)$/
                        && do { $desc = "Load <status> - Up <cmd2>, ".
                                        "$1-min load average = <cmd0>%";
@@ -88,101 +96,56 @@
 
 
 # begin timeout period, run the check
-alarm($::opt_to);
-open  ( CMD, "$nwstatcmd $host $cmd1 $cmd2|" ) || die "Couldn't execute nwstat";
+$plugin->start_timeout($opt_t, "Connection timed out");
+
+$ENV{PATH} = "";
+$ENV{BASH_ENV} = "";
+
+open  ( CMD, "$nwstatcmd $opt_H $cmd1 $cmd2|" ) || die "Couldn't execute nwstat";
 @CMD = <CMD>;
 close ( CMD );
-alarm(0);
+
+$plugin->stop_timeout();
 
 for (@CMD) { chomp; }
 
 # for any variables that manipulate the results instead of
 # just using <cmd0> directly, do that manipulation here into <result>
-SWITCH: for ($::opt_v) {
+SWITCH: for ($opt_v) {
            /^VPF/       && do { $result=int(("$CMD[0]"/"$CMD[1]")*100); last; };
            $result = "$CMD[0]";
         }
 
 if ("$result" == -1) {
-   $status = $ERROR{"UNKNOWN"};
+   $status = "UNKNOWN";
    $desc = "Server returned \"variable unknown\"";
 } elsif ("$result" == -2) {
-   $status = $ERROR{"CRITICAL"};
+   $status = "CRITICAL";
    $desc = "Connection failed";
 }
 
-if (defined($::opt_cv) && $status == $ERROR{"OK"}) {
+if (defined($opt_c) && $status == 'OK') {
    if ($backward) {
-      ("$result" <= "$::opt_cv") && ( $status = $ERROR{"CRITICAL"} );
+      ("$result" <= "$opt_c") && ( $status = "CRITICAL" );
    } else {
-      ("$result" >= "$::opt_cv") && ( $status = $ERROR{"CRITICAL"} );
+      ("$result" >= "$opt_c") && ( $status = "CRITICAL" );
    }
 }
-if (defined($::opt_wv) && $status == $ERROR{"OK"}) {
+if (defined($opt_w) && $status == 'OK') {
    if ($backward) {
-      ("$result" <= "$::opt_wv") && ( $status = $ERROR{"WARNING"} );
+      ("$result" <= "$opt_w") && ( $status = "WARNING" );
    } else {
-      ("$result" >= "$::opt_wv") && ( $status = $ERROR{"WARNING"} );
+      ("$result" >= "$opt_w") && ( $status = "WARNING" );
    }
 }
 
-$desc =~ s/<status>/($status == $ERROR{"OK"})?"$okstr":"$probstr"/eg;
+$desc =~ s/<status>/($status == 'OK')?"$okstr":"$probstr"/eg;
 $desc =~ s/<([^>]*)cmd([0-3])([^>]*)>/eval("$1\"$CMD[$2]\"$3")/eg;
 $desc =~ s/<result>/"$result"/eg;
 
-if (defined($::opt_url)) {
-   print "<A HREF=\"$::opt_url\">$desc</A>\n";
+if (defined($opt_url)) {
+   print "$PROGNAME $status: <A HREF=\"$opt_url\">$desc</A>\n";
 } else {
-   print "$desc\n";
-}
-exit $status;
-
-
-######################################################################
-#  Subroutines
-######################################################################
-
-sub usage {
-
-    %ERROR = shift;
-
-    print <<EOF
-check_nwstat.pl plugin for Nagios
-by Cliff Woolley, (c) 2000
-
-Usage: ./check_nwstat.pl <host_address> [-v variable] [-wv warn_value] [-cv crit_value] [-to to_sec] [-url url_value]
-
-Options:
- [variable]   = Variable to check.  Valid variables include:
-                  LOAD1    = 1 minute average CPU load
-		  LOAD5	   = 5 minute average CPU load
-		  LOAD15   = 15 minute average CPU load
-                  CONNS    = number of currently licensed connections
-                  VPF<vol> = percent free space on volume <vol>
-	          VKF<vol> = KB of free space on volume <vol>
-                  LTCH     = percent long term cache hits
-                  CBUFF    = current number of cache buffers
-		  CDBUFF   = current number of dirty cache buffers
-		  LRUM     = LRU sitting time in minutes
- [warn_value] = Threshold for value necessary to result in a warning status
- [crit_value] = Threshold for value necessary to result in a critical status
- [to_sec]     = Number of secs before connection times out - default is 10 sec
- [url_value]  = URL to use in output as a hyperlink.  Useful to link to a page
-                with more details or history for this variable (ie an MRTG page)
-
-This plugin attempts to contact the MRTGEXT NLM running on a Novell server
-to gather the requested system information.
-
-Notes:
- - This plugin requres that the MRTGEXT.NLM file distributed with
-   James Drews' MRTG extension for NetWare (available from
-   http://www.engr.wisc.edu/~drews/mrtg/) be loaded on the Novell
-   servers you wish to check.
- - Critical thresholds should be lower than warning thresholds when
-   the following variables are checked: VPF, VKF, LTCH, CBUFF, and LRUM.
-EOF
-;
-
-    exit $ERROR{"UNKNOWN"};
+   print "$PROGNAME $status: $desc\n";
 }
-
+exit $ERRORS{status};
