diff -ruN nagiosplug-save/contrib/check_qmailq.pl nagiosplug/contrib/check_qmailq.pl
--- nagiosplug-save/contrib/check_qmailq.pl	2002-02-28 06:42:53.000000000 +0000
+++ nagiosplug/contrib/check_qmailq.pl	2004-03-27 22:58:07.000000000 +0000
@@ -1,4 +1,4 @@
-#!/usr/bin/perl 
+#!/usr/bin/perl -wT
 #
 # check_qmailq.pl - nagios plugin 
 # This plugin allows you to check the number of Mails in a qmail-
@@ -24,74 +24,60 @@
 # Emergency E-Mail :) blueshift@gmx.net
 #
 
-### CONFIGURATION SECTION ####################
-
-my $statcommand  = "/var/qmail/bin/qmail-qstat";
-my $queuewarn = 5;      # Warning, if more than x mail in Queue
-my $queuecrit = 10;     # Critical if "--"
-my $prewarn = 1;        # Warning, if more than x unhandled mails 
-			# (not in Queue
-my $precrit = 5;        # Critical, if  "--"
-
-### CONFIURATION SECTION END ################
-
+require 5.004;
 use strict;
-use Carp;
-
-#use Getopt::Long;
-#&Getopt::Long::config('auto_abbrev');
+use lib utils.pm ;
+use Plugin;
+use Plugin::Parameter qw(:DEFAULT :standard :thresholds);
+
+use vars qw($opt_t $PROGNAME $queuewarn $queuecrit $prewarn $precrit $statcommand);
+
+use utils qw(%ERRORS);
+
+$w_opt->binding(\$queuewarn);
+$w_opt->default(5);
+$w_opt->description("Warning generated if more than this number of messages are in the queue");
+$c_opt->binding(\$queuecrit);
+$c_opt->default(10);
+$c_opt->description("Critical generated if more than this number of messages are in the queue");
+my $W_opt = new Plugin::Parameter(-name => "prewarn", -flags => [ 'W', 'preq-warning' ],
+				  -optional => "yes", -valueoptional => "no", -type => "INTEGER",
+				  -binding => \$prewarn, -default => 1,
+				  -description => "Warning generated if more than this number of messages are awaiting pre-processing");
+my $C_opt = new Plugin::Parameter(-name => "precrit", -flags => [ 'C', 'preq-critical' ],
+				  -optional => "yes", -valueoptional => "no", -type => "INTEGER",
+				  -binding => \$precrit, -default => 5,
+				  -description => "Critical generated if more than this number of messages are awaiting pre-processing");
+my $comm_opt = new Plugin::Parameter(-name => "statcommand", -flags => [ 'command', 'stat-command' ],
+				     -optional => "yes", -valueoptional => "no", -type => "PROGRAM",
+				     -binding => \$statcommand, -default => "/var/qmail/bin/qmail-stat",
+				     -description => "Command to run to get the queue statistics");
+my $plugin = new Plugin(-revision => '$Revision: 1.1.1.1 $',
+			-copyright => "2000 Benjamin Schmid, 2004 Howard Wilkinson <howard\@cohtech.com>",
+			-shortcomment => "Mail Queue monitor for Qmail",
+			-parameterlists => [ [ $w_opt, $c_opt, $W_opt, $C_opt, $comm_opt, $t_opt ], $h_opts, $V_opts ]);
 
+use Carp;
 
-
-my $TIMEOUT = 15;
-
-my %ERRORS = ('UNKNOWN' , '-1',
-              'OK' , '0',
-              'WARNING', '1',
-              'CRITICAL', '2');
+$plugin->init();
 
 my $state = "UNKNOWN";
 my $answer = "";
 
-#sub usage {
-#  printf "\nMissing arguments!\n";
-#  printf "\n";
-#  printf "Printer Server Queue Nagios Plugin\n";
-#  printf "monitors jobs in lpr queues\n";
-#  printf "usage: \n";
-#  printf "check_lpq.pl \n";
-#  printf "Copyright (C) 2000 Benjamin Schmid\n";
-#  printf "check_lpq.pl comes with ABSOLUTELY NO WARRANTY\n";
-#  printf "This programm is licensed under the terms of the ";
-#  printf "GNU General Public License\n(check source code for details)\n";
-#  printf "\n\n";
-#  exit $ERRORS{"UNKNOWN"};
-#}
-
-# Just in case of problems, let's not hang Nagios
-$SIG{'ALRM'} = sub {
-     print ("ERROR: check_lpq.pl Time-Out $TIMEOUT s \n");
-     exit $ERRORS{"UNKNOWN"};
-};
-alarm($TIMEOUT);
-
-
-#$status = GetOptions("community=s",\$community,
-#                     "port=i",\$port);
-#if ($status == 0)
-#{
-#        &usage;
-#}
-  
-#   $hostname  = shift || &usage;
+$ENV{PATH} = "";
+$ENV{BASH_ENV} = "";
+
+$plugin->start_timeout($opt_t, "Time-out $opt_t s");
 
 if (! open STAT, "$statcommand|") {
-  print ("$state: $statcommand returns no result!");
+  print ("$PROGNAME $state: $statcommand returns no result!");
   exit $ERRORS{$state};
 }
 my @lines = <STAT>;
 close STAT;
 
+$plugin->stop_timeout();
+
 # Mails in Queues
 if ($lines[0]=~/^messages in queue: (\d+)/) {
   my $anzq = $1;
@@ -116,6 +102,6 @@
 
 $state = 'OK' if ($state eq 'UNKNOWN');
 
-print ("$state: $answer\n");
+print ("$PROGNAME $state: $answer\n");
 exit $ERRORS{$state};
 
