diff -ruN nagiosplug-save/contrib/check_dlswcircuit.pl nagiosplug/contrib/check_dlswcircuit.pl
--- nagiosplug-save/contrib/check_dlswcircuit.pl	2002-02-28 06:42:53.000000000 +0000
+++ nagiosplug/contrib/check_dlswcircuit.pl	2004-03-27 21:57:31.000000000 +0000
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl -wT
 #
 # check_dlswcircuit.pl - nagios plugin 
 # 
@@ -39,183 +39,151 @@
 #
 # 11.03.2000 Version 1.0
 
+require 5.004;
 use strict;
+use lib utils.pm ;
+use Plugin;
+use Plugin::Parameter qw($helpparameterlist $versionparameterlist $hostnameparameter
+			 $communityparameter $portparameter $timeoutparameter
+			 $verboseparameter);
 
 use Net::SNMP;
-use Getopt::Long;
-&Getopt::Long::config('auto_abbrev');
 
+use vars qw($opt_H $opt_C $opt_p $opt_t $opt_v $opt_s $opt_d $PROGNAME);
+use utils qw(%ERRORS);
+
+my $checkmac = sub { my ($opt, $parameter, $plugin) = @_;
+		     if (!defined $$opt) {
+		       $plugin->usage();
+		       &utils::usage("$main::PROGNAME UNKNOWN: Option (--" . $parameter->name() .") required but not set\n");
+		     }
+		     my @macs = ("$$opt" =~ m/:/)?(split /:/, "$$opt"):(split /\./, "$$opt");
+		     if (@macs == 6) {
+		     NOTVALID: {
+			 foreach my $mac (@macs) {
+			   if ("$mac" !~ m/^[[:xdigit:]]{1,2}$/) { last NOTVALID; }
+			 }
+			 # All OK
+			 return;
+		       }
+		     }
+		     $plugin->usage();
+		     &utils::usage("$PROGNAME UNKNOWN: Option (--" . $parameter->name() . ") invalid mac address $$opt\n");
+		   };
+my $sourcemacparameter = new Plugin::Parameter(-name => "sourcemac", -flags => [ 's', 'sourcemac' ],
+					       -optional => "no", -valueoptional => "no", -type => "MACADDRESS",
+					       -checker => $checkmac,
+					       -description => "The source mac/sap address of the DLSW circuit");
+my $destmacparameter = new Plugin::Parameter(-name => "sourcemac", -flags => [ 'd', 'destmac' ],
+					     -optional => "no", -valueoptional => "no", -type => "MACADDRESS",
+					     -checker => $checkmac,
+					     -description => "The destination mac/sap address of the DLSW circuit");
+$portparameter->default("snmp");
+my @commandparameterlist = ( $hostnameparameter,
+			     $communityparameter,
+			     $sourcemacparameter,
+			     $destmacparameter,
+			     $portparameter,
+			     $timeoutparameter,
+			     $verboseparameter );
+
+my $plugin = new Plugin(-revision => '$Revision: 1.1.1.1 $',
+			-copyright => " 2000 Carsten Foss,2004 Howard Wilkinson <howard\@cohtech.com>",
+			-shortcomment => "Perl Check Cisco Dlsw Circuit State plugin for Nagios. Checks operational status of specified DLSW Circuit.",
+			-longcomment => "Source and Destination Mac/Sap arguments must be given in Hex as in this example: 40::01:37:45:01:ss (Where ss is the sap). A '.' can be used as a separator rather than a ':' if required.",
+			-parameterlists => [ \@commandparameterlist, $helpparameterlist, $versionparameterlist ]);
 
 my $status;
 my $TIMEOUT = 15;
 
-my %ERRORS = ('UNKNOWN' , '-1',
-              'OK' , '0',
-              'WARNING', '1',
-              'CRITICAL', '2');
-
-my %dlswCircuitStatus = (
-	  '1','disconnected',
-        '2','circuitStart',
-        '3','resolvePending',
-        '4','circuitPending',
-        '5','circuitEstablished',
-        '6','connectPending',
-        '7','contactPending',
-        '8','connected',
-        '9','disconnectPending',
-        '10','haltPending',
-        '11','haltPendingNoack',
-        '13','circuitRestart',
-        '14','restartPending');
+my %dlswCircuitStatus = ('1','disconnected',
+			 '2','circuitStart',
+			 '3','resolvePending',
+			 '4','circuitPending',
+			 '5','circuitEstablished',
+			 '6','connectPending',
+			 '7','contactPending',
+			 '8','connected',
+			 '9','disconnectPending',
+			 '10','haltPending',
+			 '11','haltPendingNoack',
+			 '13','circuitRestart',
+			 '14','restartPending');
 
-my $state = "UNKNOWN";
-my $answer = "";
-my $smac = "";
-my $dmac = "";
-my $community = "public";
-my $port = 161;
 #Dlsw Circuit Oid enterprises.9.10.9.1.5.2.1.17.6.0.96.148.47.230.166.4.6.64.0.1.55.69.2.4 = 8
 my $enterpriseOid = "1.3.6.1.4.1";
 my $ciscoDlswCircuitOid = ".9.10.9.1.5.2.1.17.";
 my $unknownOid = "6.";
+
+$plugin->init();
+
+#
+#Convert Source Mac & Sap
+#
 my $smacOid = "";
+my $prefix = "";
+my @tmparg = ("$opt_s" =~ m/:/)?(split /:/, "$opt_s"):(split /\./, "$opt_s");
+foreach my $p (@tmparg) {
+  my $q = hex($p);
+  $smacOid = $smacOid . $prefix . $q;
+  $prefix = ".";
+}
+
+#
+#Convert Dest Mac & Sap
+#
 my $dmacOid = "";
-my $tmpOid = "";
-my @tmparg;
-my $snmpoid;
-my @snmpoids;
-my $hostname;
-my $session;
-my $error;
-my $response;
-my $p = "";
-my $q = "";
-
-sub usage {
-  printf "\nMissing arguments!\n";
-  printf "\n";
-  printf "Perl Check Cisco Dlsw Circuit State plugin for Nagios\n";
-  printf  "checks operational status of specified DLSW Circuit\n";
-  printf "usage: \n";
-  printf "check_dlswcircuit.pl -s <SourceMac> -d <DestMac> -c <READCOMMUNITY> -p <PORT> <HOSTNAME>";
-  printf "\nCopyright (C) 2000 Carsten Foss\n";
-  printf "check_dlswcircuit.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"};
+$prefix = "";
+@tmparg = ("$opt_d" =~ m/:/)?(split /:/, "$opt_d"):(split /\./, "$opt_d");
+foreach my $p (@tmparg) {
+  my $q = hex($p);
+  $dmacOid = $dmacOid . $prefix . $q;
+  $prefix = ".";
 }
 
-# Just in case of problems, let's not hang Nagios
-$SIG{'ALRM'} = sub {
-     print ("ERROR: No snmp response from $hostname (alarm)\n");
-     exit $ERRORS{"UNKNOWN"};
-};
-alarm($TIMEOUT);
+my $snmpoid = $enterpriseOid.$ciscoDlswCircuitOid.$unknownOid.$smacOid.$unknownOid.$dmacOid ;
+
+my ($session, $error) = Net::SNMP->session(-hostname  => $opt_H,
+					   -community => $opt_C,
+					   -port      => $opt_p,
+					   -timeout   => $opt_t,
+					   -version   => "snmpv1");
 
+my $state = "UNKNOWN";
+my $answer = "";
 
-$status = GetOptions("sourcemac=s",\$smac,"destmac=s",\$dmac,
-                     "community=s",\$community,
-                     "port=i",\$port);
-if ($status == 0)
-{
-        &usage;
+if (!defined($session)) {
+  $answer=$error;
+  print ("$PROGNAME $state: $answer");
+  exit $ERRORS{$state};
 }
 
-#
-#Convert Source Mac & Sap
-#  
-   @tmparg = split(/\./,$smac);
-   #print "-$smac-\n";
-   #print "@tmparg\n";
-   #print "$#tmparg\n";
-   if($#tmparg != 6)
-   {
-     print "SourceMac/Sap format $smac not valid\n";
-     &usage;
-   }
-   while($p = shift @tmparg)
-   {
-     $q = hex($p); 
-     $smacOid = $smacOid.$q;
-     $smacOid = $smacOid.'.';
-   }
+my @snmpoids = ( $snmpoid );
+#push(@snmpoids,$snmpLocIfDescr);
 
-   #print "@tmparg1\n";
-   #print "$smacOid\n";
+my $response = $session->get_request(@snmpoids);
 
-#
-#Convert Dest Mac & Sap
-#  
-   @tmparg = split(/\./,$dmac);
-   #print "-$dmac-\n";
-   #print "@tmparg\n";
-   #print "$#tmparg\n";
-   if($#tmparg != 6)
-   {
-     print "DestMac/Sap format $dmac not valid\n";
-     &usage;
-   }
-
-   while($p = shift @tmparg)
-   {
-     $q = hex($p); 
-     $dmacOid = $dmacOid.$q;
-     $dmacOid = $dmacOid.'.';
-   }
-#  Remove Trailing Dot
-   $dmacOid = substr($dmacOid,0,length($dmacOid)-1);
-   
-
-   #print "@tmparg1\n";
-   #print "$dmacOid\n";
-#Build the Dlsw Oic to use
-   $snmpoid = $enterpriseOid.$ciscoDlswCircuitOid.$unknownOid.$smacOid.$unknownOid.$dmacOid ;
-   #print "$snmpoid\n";
-
-   #shift;
-   $hostname  = shift || &usage;
-
-   ($session, $error) = Net::SNMP->session(
-      -hostname  => $hostname,
-      -community => $community,
-      -port      => $port
-   );
-
-   if (!defined($session)) {
-      $state='UNKNOWN';
-      $answer=$error;
-      print ("$state: $answer");
-      exit $ERRORS{$state};
-   }
-
-   push(@snmpoids,$snmpoid);
-   #push(@snmpoids,$snmpLocIfDescr);
-
-   if (!defined($response = $session->get_request(@snmpoids))) {
-      $answer=$session->error;
-      $session->close;
-      $state = 'CRITICAL';
-      print ("$state: $answer,$community,$smac - $dmac");
-      exit $ERRORS{$state};
-   }
-
-   $answer = sprintf("dlsw circuit %s - %s at host '%s',is %s\n", 
-      $smac,
-	$dmac,
-      $hostname, 
-      $dlswCircuitStatus{$response->{$snmpoid}}
-   );
-
-   $session->close;
-
-   if ( $response->{$snmpoid} == 8 ) {
-      $state = 'OK';
-   }
-   else {
-	$state = 'CRITICAL';
-   }
+if (!defined $response) {
+  $answer=$session->error;
+  $session->close;
+  $state = 'CRITICAL';
+  print ("$PROGNAME $state: $answer, $opt_s - $opt_d");
+  exit $ERRORS{$state};
+}
+
+$session->close;
+
+$answer = sprintf("dlsw circuit %s - %s at host '%s',is %s\n", 
+		  $opt_s,
+		  $opt_d,
+		  $opt_H,
+		  $dlswCircuitStatus{$response->{$snmpoid}});
+
+if ( $response->{$snmpoid} == 8 ) {
+  $state = 'OK';
+} else {
+  $state = 'CRITICAL';
+}
 
-print ("$state: $answer");
+print ("$PROGNAME $state: $answer");
 exit $ERRORS{$state};
