diff -ruN nagiosplug-save/contrib/check_sockets.pl nagiosplug/contrib/check_sockets.pl
--- nagiosplug-save/contrib/check_sockets.pl	2002-02-28 06:42:54.000000000 +0000
+++ nagiosplug/contrib/check_sockets.pl	2004-03-27 23:15:56.000000000 +0000
@@ -1,4 +1,4 @@
-#! /usr/bin/perl
+#! /usr/bin/perl -wT
 # ------------------------------------------------------------------------------
 # File Name:		check_sockets.pl
 # Author:		Richard Mayhew - South Africa
@@ -29,18 +29,34 @@
 # -----------------------------------------------------------------[ Require ]--
 require 5.004;
 # --------------------------------------------------------------------[ Uses ]--
-use Socket;
 use strict;
+use lib utils.pm ;
+use Plugin;
+use Plugin::Parameter qw(:DEFAULT :thresholds);
+
+use Socket;
+
+use vars qw($PROGNAME $type $warn $crit $opt_t);
+
+use utils qw(%ERRORS);
 # --------------------------------------------------------------[ Enviroment ]--
 $ENV{'PATH'}='/bin:/sbin:/usr/bin:/usr/sbin';
 $ENV{BASH_ENV} = "";
 # ------------------------------------------------------------------[ Global ]--
-my $TIMEOUT = 20;
-my %ERRORS = (
-	'UNKNOWN', '-1',
-	'OK', '0',
-	'WARNING', '1',
-	'CRITICAL', '2');
+my $type_opt = new Plugin::Parameter(-name => "type", -flags => [ 'T', 'type' ],
+				     -optional => "no", -valueoptional => "no", -type => "SOCKETTYPE",
+				     -binding => \$type,
+				     -description => "Type of sockets to check - TOTAL, TCP, UDP, RAW, ...");
+$w_opt->default(256);
+$w_opt->optional("yes");
+$w_opt->binding(\$warn);
+$c_opt->default(512);
+$c_opt->optional("yes");
+$c_opt->binding(\$crit);
+my $plugin = new Plugin(-revision => '$Revision: 1.1.1.1 $',
+			-copyright => "2000 Richard Mayhew, Howard Wilkinson <howard\@cohtech.com>",
+			-shortcomment => "Check open sockets on a server",
+			-parameterlists => [ [ $type_opt, $w_opt, $c_opt, $t_opt ] , $h_opts, $V_opts ]);
 # --------------------------------------------------------------[ connection ]--
 sub connection
 {
@@ -51,56 +67,31 @@
 	$in_total =~ s/\ //g;
 	if ($in_total >= 0) {
 
-		if ($in_total > $in_crit) {
+	        if ($in_total > $in_crit) {
 			$state = "CRITICAL";
-			$answer = "Critical Number Of Sockets Connected : $in_total (Limit = $in_crit)\n";
-
+			$answer = "Critical Number Of Sockets Connected : $in_total (Limit = $in_crit)";
 		} elsif ($in_total > $in_warn) {
 			$state = "WARNING";
-			$answer = "Warning Number Of Sockets Connected : $in_total (Limit = $in_warn)\n";
-
+			$answer = "Warning Number Of Sockets Connected : $in_total (Limit = $in_warn)";
 		} else {
-			if ($in_high ne "") {
-			$answer = "Sockets OK - Current Sockets: $in_total : $in_high\n";
-			}
-			if ($in_high eq "") {
-			$answer = "Sockets OK - Current Sockets: $in_total\n";
+		        $answer = "Sockets OK - Current Sockets: $in_total";
+		        if (defined $in_high && $in_high ne "") {
+			        $answer .= " : $in_high";
 			}
 			$state = "OK";
-			}
-
+		}
 	} else {
 		$state = "UNKNOWN";
-		$answer = "Something is Really WRONG! Sockets Is A Negative Figure!\n";
+		$answer = "Something is Really WRONG! Sockets Is A Negative Figure!";
 	}
 	
-	print $answer;
+	print "$PROGNAME $state: $answer\n";
 	exit $ERRORS{$state};
 }
 
-# -------------------------------------------------------------------[ usage ]--
-sub usage
-{
-	print "Minimum arguments not supplied!\n";
-	print "\n";
-	print "Perl Check Sockets plugin for Nagios\n";
-	print "Copyright (c) 2000 Richard Mayhew\n";
-	print "\n";
-	print "Usage: check_sockets.pl <type> <warn> <crit>\n";
-	print "\n";
-	print "<type> = TOTAL, TCP, UDP, RAW.\n";
-	print "<warn> = Number of sockets connected at which a warning message will be generated.[Default = 256]\n";
-	print "<crit> = Number of sockets connected at which a critical message will be generated.[Default = 512]\n";
-	exit $ERRORS{"UNKNOWN"};
-
-}
-
 # ====================================================================[ MAIN ]==
 MAIN:
 {
-	my $type = shift || &usage;
-	my $warn = shift || 256;
-	my $crit = shift || 512;
 	my $data;	
 	my @data;
 	my $line;
@@ -110,36 +101,36 @@
 	my $junk;
 	my $total1;
 	my $total2;
+
+	$plugin->init();
+
 	$type = uc $type;
 	if ($type eq "TOTAL") {
-	$type = "sockets";
+	        $type = "sockets";
 	}
 
-	# Just in case of problems, let's not hang Nagios
-	$SIG{'ALRM'} = sub {
-		print "Somthing is Taking a Long Time, Increase Your TIMEOUT (Currently Set At $TIMEOUT Seconds)\n";
-		exit $ERRORS{"UNKNOWN"};
-	};
+	$plugin->start_timeout($opt_t, "Somthing is Taking a Long Time, Increase Your TIMEOUT (Currently Set At $opt_t Seconds)");
 
 	$data = `/bin/cat /proc/net/sockstat`;
 	@data = split("\n",$data);
-	alarm($TIMEOUT);
+
 	my $output = "";
 	my $high;
 
-
 	foreach $line (@data) {
-		if ($line =~ /$type/) {
-		($data1,$data2,$data3) = split(" ",$line,3);	
-
-			if ($data3 =~ /highest/){
-			($total1,$junk,$total2) = split(" ",$data3,3);	
-			$output = $total1;
-			$high = $total2;
+		if ($line =~ m/^($type):\s+(\w+)\s+(\d+)/i) {
+		        ($data1,$data2,$data3) = ($1,$2,$3);
+			if ($data3 =~ /highest/) { # Not on our linux!!
+			        ($total1,$junk,$total2) = split(" ",$data3,3);	
+				$output = $total1;
+				$high = $total2;
+			} else {
+			        $output = $data3;
 			}
-			else {$output = $data3;}
-	alarm(0);
-	connection($output,$warn,$crit,$high);
+			connection($output,$warn,$crit,$high);
+			# NOT REACHED
 		}
 	}
+# NOT REACHED except in error
+	exit $ERRORS{'UNKNOWN'};
 }
