diff -ruN nagiosplug-save/contrib/check_log2.pl nagiosplug/contrib/check_log2.pl
--- nagiosplug-save/contrib/check_log2.pl	2002-05-23 17:39:59.000000000 +0100
+++ nagiosplug/contrib/check_log2.pl	2004-03-27 22:24:15.000000000 +0000
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/perl -wT
 #
 # Log file regular expression detector for Nagios.
 # Written by Aaron Bostick (abostick@mydoconline.com)
@@ -48,138 +48,98 @@
 #   check_log2 -l /var/log/messages -s ./check_log2.messages.seek -p 'err'
 #
 
-
-BEGIN {
-    if ($0 =~ s/^(.*?)[\/\\]([^\/\\]+)$//) {
-        $prog_dir = $1;
-        $prog_name = $2;
-    }
-}
-
 require 5.004;
+use strict;
+use lib utils.pm ;
+use Plugin;
+use Plugin::Parameter qw(:DEFAULT);
+
+use vars qw($opt_l $opt_s $opt_p $opt_n $opt_t $PROGNAME);
+
+use utils qw(%ERRORS &usage);
+
+my $l_opt = new Plugin::Parameter(-name => "logfile", -flags => [ 'l', 'logfile' ],
+				  -optional => "no", -valueoptional => "no", -type => "FILENAME",
+				  -description => "The log file to be scanned");
+my $s_opt = new Plugin::Parameter(-name => "seekfile", -flags => [ 's', 'seekfile' ],
+				  -optional => "no", -valueoptional => "no", -type => "FILENAME",
+				  -checker => sub { my ($opt, $parameter, $plugin) = @_;
+						    $$opt =~ m/(.*)/;
+						    $$opt = $1; },
+				  -description => "The temporary file to store the seek position of the last scan");
+my $p_opt = new Plugin::Parameter(-name => "pattern", -flags => [ 'p', 'pattern' ],
+				  -optional => "no", -valueoptional => "no", -type => "REGEX",
+				  -description => "The regular expression to scan for in the log file");
+my $n_opt = new Plugin::Parameter(-name => "negpattern", -flags => [ 'n', 'negpattern' ],
+				  -optional => "yes", -valueoptional => "no", -type => "REGEX",
+				  -description => "The regular expression to skip in the log file");
+my $plugin = new Plugin(-revision => '$Revision: 1.1 $',
+			-copyright => "2002 Aaron Bostick <abostick\@mydoconline.com>, 2004 Howard Wilkinson <howard\@cohtech.com>",
+			-shortcomment => "Scan arbitary log giles for regular expression matches",
+			-parameterlists => [ [ $l_opt, $s_opt, $p_opt, $n_opt, $t_opt ], $h_opts, $V_opts ]);
+
+my $pattern_count = 0;
+my $pattern_line = '';
+
+
+$plugin->init();
+
+$plugin->start_timeout($opt_t, "Timed out while scanning log file");
+
+# Open log file
+open LOG_FILE, $opt_l || die "Unable to open log file $opt_l: $!";
+
+# Try to open log seek file.  If open fails, we seek from beginning of
+# file by default.
+if (open(SEEK_FILE, $opt_s)) {
+  my @seek_pos = ();
+  chomp(@seek_pos = <SEEK_FILE>);
+  close(SEEK_FILE);
+  #  If file is empty, no need to seek...
+  if ($seek_pos[0] && $seek_pos[0] != 0) {
+    # Compare seek position to actual file size.  If file size is smaller
+    # then we just start from beginning i.e. file was rotated, etc.
+    my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat(LOG_FILE);
 
-use lib $main::prog_dir;
-use utils qw($TIMEOUT %ERRORS &print_revision &support &usage);
-use Getopt::Long;
-
-sub print_usage ();
-sub print_version ();
-sub print_help ();
-
-    # Initialize strings
-    $log_file = '';
-    $seek_file = '';
-    $re_pattern = '';
-    $neg_re_pattern = '';
-    $pattern_count = 0;
-    $pattern_line = '';
-    $plugin_revision = '$Revision: 1.1 $ ';
-
-    # Grab options from command line
-    GetOptions
-    ("l|logfile=s"      => \$log_file,
-     "s|seekfile=s"     => \$seek_file,
-     "p|pattern=s"      => \$re_pattern,
-     "n|negpattern:s"   => \$neg_re_pattern,
-     "v|version"        => \$version,
-     "h|help"           => \$help);
-
-    !($version) || print_version ();
-    !($help) || print_help ();
-
-    # Make sure log file is specified
-    ($log_file) || usage("Log file not specified.\n");
-    # Make sure seek file is specified
-    ($seek_file) || usage("Seek file not specified.\n");
-    # Make sure re pattern is specified
-    ($re_pattern) || usage("Regular expression not specified.\n");
-
-    # Open log file
-    open LOG_FILE, $log_file || die "Unable to open log file $log_file: $!";
-
-    # Try to open log seek file.  If open fails, we seek from beginning of
-    # file by default.
-    if (open(SEEK_FILE, $seek_file)) {
-        chomp(@seek_pos = <SEEK_FILE>);
-        close(SEEK_FILE);
-
-        #  If file is empty, no need to seek...
-        if ($seek_pos[0] != 0) {
-            
-            # Compare seek position to actual file size.  If file size is smaller
-            # then we just start from beginning i.e. file was rotated, etc.
-            ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat(LOG_FILE);
-
-            if ($seek_pos[0] <= $size) {
-                seek(LOG_FILE, $seek_pos[0], 0);
-            }
-        }
-    }
-
-    # Loop through every line of log file and check for pattern matches.
-    # Count the number of pattern matches and remember the full line of 
-    # the most recent match.
-    while (<LOG_FILE>) {
-        if ($neg_re_pattern) {
-            if ((/$re_pattern/) && !(/$neg_re_pattern/)) {
-                $pattern_count += 1;
-                $pattern_line = $_;
-            }
-        } elsif (/$re_pattern/) {
-                $pattern_count += 1;
-                $pattern_line = $_;
-        }
+    if ($seek_pos[0] <= $size) {
+      seek(LOG_FILE, $seek_pos[0], 0);
     }
+  }
+}
 
-    # Overwrite log seek file and print the byte position we have seeked to.
-    open(SEEK_FILE, "> $seek_file") || die "Unable to open seek count file $seek_file: $!";
-    print SEEK_FILE tell(LOG_FILE);
-
-    # Close seek file.
-    close(SEEK_FILE);
-    # Close the log file.
-    close(LOG_FILE);
-
-    # Print result and return exit code.
-    if ($pattern_count) {
-        print "($pattern_count): $pattern_line";
-        exit $ERRORS{'WARNING'};
-    } else {
-        print "OK - No matches found.\n";
-        exit $ERRORS{'OK'};
+# Loop through every line of log file and check for pattern matches.
+# Count the number of pattern matches and remember the full line of 
+# the most recent match.
+while (<LOG_FILE>) {
+  if ($opt_n) {
+    if ((/$opt_p/) && !(/$opt_n/)) {
+      $pattern_count += 1;
+      $pattern_line = $_;
     }
-
-#
-# Subroutines
-#
-
-sub print_usage () {
-    print "Usage: $prog_name -l <log_file> -s <log_seek_file> -p <pattern> [-n <negpattern>]\n";
-    print "Usage: $prog_name [ -v | --version ]\n";
-    print "Usage: $prog_name [ -h | --help ]\n";
+  } elsif (/$opt_p/) {
+    $pattern_count += 1;
+    $pattern_line = $_;
+  }
 }
 
-sub print_version () {
-    print_revision($prog_name, $plugin_revision);
-    exit $ERRORS{'OK'};
+# Overwrite log seek file and print the byte position we have seeked to.
+# Allow this to fail silently
+if (open(SEEK_FILE, "> $opt_s")) {
+  print SEEK_FILE tell(LOG_FILE);
+  # Close seek file.
+  close(SEEK_FILE);
 }
 
-sub print_help () {
-    print_revision($prog_name, $plugin_revision);
-    print "\n";
-    print "Scan arbitrary log files for regular expression matches.\n";
-    print "\n";
-    print_usage();
-    print "\n";
-    print "-l, --logfile=<logfile>\n";
-    print "    The log file to be scanned\n";
-    print "-s, --seekfile=<seekfile>\n";
-    print "    The temporary file to store the seek position of the last scan\n";
-    print "-p, --pattern=<pattern>\n";
-    print "    The regular expression to scan for in the log file\n";
-    print "-n, --negpattern=<negpattern>\n";
-    print "    The regular expression to skip in the log file\n";
-    print "\n";
-    support();
-    exit $ERRORS{'OK'};
+# Close the log file.
+close(LOG_FILE);
+
+$plugin->stop_timeout();
+
+# Print result and return exit code.
+if ($pattern_count) {
+  print "$PROGNAME WARNING: ($pattern_count): $pattern_line";
+  exit $ERRORS{'WARNING'};
+} else {
+  print "$PROGNAME OK: No matches found.\n";
+  exit $ERRORS{'OK'};
 }
