diff -ruN nagiosplug-save/contrib/check_inodes-freebsd.pl nagiosplug/contrib/check_inodes-freebsd.pl
--- nagiosplug-save/contrib/check_inodes-freebsd.pl	2002-08-14 20:00:17.000000000 +0100
+++ nagiosplug/contrib/check_inodes-freebsd.pl	2004-03-27 22:14:56.000000000 +0000
@@ -11,117 +11,113 @@
 # like / or /usr or /var (whatever you mount drives NOT the device names)
 # Andrew Ryder - 20020804 - atr@mrcoffee.org
 
-
+require 5.004;
 use strict;
-use Getopt::Long;
-use vars qw($opt_V $opt_h $opt_w $opt_c $opt_f $verbose $PROGNAME);
-use lib "/usr/local/libexec/nagios" ;
-use utils qw($TIMEOUT %ERRORS &print_revision &support);
-
-my $df = "/bin/df";
-my $grep = "/usr/bin/grep";
-
-$PROGNAME="df.pl";
-
-sub print_help ();
-sub print_usage ();
-
+use lib utils.pm ;
+use Plugin;
+use Plugin::Parameter qw(:DEFAULT :thresholds $filenameparameter $commandfileparameter);
+
+use vars qw($opt_V $opt_h $opt_w $opt_c $opt_f $opt_F $opt_t $PROGNAME);
+
+use utils qw(%ERRORS &usage);
+
+$filenameparameter->name("filesystem");
+$filenameparameter->default("/");
+$commandfileparameter->name("df");
+$commandfileparameter->description("Path to 'df'");
+$commandfileparameter->default("/bin/df");
+$commandfileparameter->type("PROGRAM");
+$w_opt->description("Inode percent at which a warning message is returned");
+$w_opt->default(50);
+$c_opt->description("Inode Percent at which a critical message is returned");
+$c_opt->default(75);
+
+my $plugin = new Plugin(-revision => '$Revision: 1.1$',
+			-copyright => "2002 Andrew Ryder, 2004 Howard Wilkinson <howard\@cohtech.com>",
+			-shortcomment => "Check available number of inodes on a filesystem",
+			-parameterlists => [ [ $filenameparameter,
+					       $w_opt,
+					       $c_opt,
+					       $commandfileparameter,
+					       $t_opt ], $h_opts, $V_opts ]);
 
 $ENV{'PATH'}='';
 $ENV{'BASH_ENV'}='';
 $ENV{'ENV'}='';
 
-Getopt::Long::Configure('bundling');
-GetOptions
-        ("V"   => \$opt_V, "version"    => \$opt_V,
-         "h"   => \$opt_h, "help"       => \$opt_h,
-         "w=s" => \$opt_w, "warning=s"  => \$opt_w, 
-         "c=s" => \$opt_c, "critical=s" => \$opt_c,
-	 "f=s" => \$opt_f, "filesystem=s" => \$opt_f);
-	
-
-if ($opt_V) {
-        print_revision($PROGNAME,'$Revision: 1.1 $ ');
-        exit $ERRORS{'OK'};
-}
+$plugin->init();
 
-if ($opt_h) {
-        print_help();
-        exit $ERRORS{'OK'};
+if ($opt_c < $opt_w) {
+  $plugin->usage();
+  usage("$PROGNAME UNKNOWN: Critical usage should be not be smaller than warning usage\n");
 }
 
-($opt_w) || ($opt_w = shift) || ($opt_w = 50);
-my $warning = $1 if ($opt_w =~ /([0-9]+)/);
-
-($opt_c) || ($opt_c = shift) || ($opt_c = 75);
-my $critical = $1 if ($opt_c =~ /([0-9]+)/);
-
-if ($opt_c < $opt_w) {
-        print "Critical offset should be larger than warning offset\n";
-        print_usage();
-        exit $ERRORS{"UNKNOWN"};
+unless (-e $opt_F) {
+  $plugin->usage();
+  usage("$PROGNAME UNKNOWN: Path to df program ($opt_F) is wrong");
 }
 
-($opt_f) || ($opt_f = "/");
+unless (-d $opt_f) {
+  $plugin->usage();
+  usage("$PROGNAME UNKNOWN: $opt_f is not a mount point\n"); 
+}
 
+my $state = 'UNKNOWN';
+my $answer = "Filesystem $opt_f not found";;
 
-unless (-e $df) {
-	print "UNKNOWN: $df is not where df is\n";
-	exit $ERRORS{'UNKNOWN'};
-	}
-
-unless (-e $grep) {
-	print "UNKNOWN: $grep is not where grep is\n";
-	exit $ERRORS{'UNKNOWN'};
-	}
+$plugin->start_timeout($opt_t, "Plugin hang waiting for output from df");
 
-unless (-d $opt_f) {
-	print "UNKNOWN: $opt_f is not a mount point\n"; 
-	exit $ERRORS{'UNKNOWN'};
-	}
-
-
-my $state = $ERRORS{'UNKNOWN'};
-my $answer;
-
-open(DF, "$df -i $opt_f| $grep -v Filesystem |");
-
-while (<DF>) {
-	
-		my ($fs,$onek,$used,$avail,$capacity,$iused,$ifree,$ipercent,$mounted) = split;
-		$ipercent =~ s/%//s;
-
-			if ($ipercent > $opt_w) {
-				$state = $ERRORS{'WARNING'};
-				$answer =  "WARNING: $ipercent percent inodes free on $opt_f\n";
-			} elsif ($ipercent > $opt_w) {
-				$state = $ERRORS{'CRITCAL'};
-        			$answer =  "CRITICAL: $ipercent percent inodes free on $opt_f\n";
-        		} elsif ($ipercent < $opt_w) {
-				$state = $ERRORS{'OK'};
-				$answer = "OK: $ipercent percent inodes free on $opt_f\n";
-			}
+open(DF, "$opt_F -i $opt_f|");
+
+# FreeBSD columns
+my $usecol = 7;
+my $mountcol = 8;
+my $freeratio = 1;
+foreach my $line (<DF>) {
+  # OK Linux produces different columns so adapt
+  if ($line =~ m/^Filesystem/i) {
+    my @columns = split /\s+/,$line;
+    my $j = 0;
+    for (my $i = 0; $i < @columns; $i++) {
+      if ($columns[$i] eq "") { next; }
+      if ($columns[$i] =~ m/IUse%/i) {
+	$usecol = $j;
+      } elsif ($columns[$i] =~ m/Mounted/i) {
+	$mountcol = $j;
+      }
+      $j++;
+    }
+    next;
+  }
+  if ($usecol != 7 || $mountcol != 8) {
+    # Linux semantics
+    $freeratio=0;
+  }
+  my @temp = split /\s+/,$line;
+  my @results = ();
+  foreach my $result (@temp) {
+    if ($result) { push @results, $result; }
+  }
+  unless ($results[$mountcol] = $opt_f) { next; }
+  my $ipercent = $results[$usecol];
+  $ipercent =~ s/%//s;
+  if (!$freeratio) {
+    $ipercent = 100 - $ipercent;
+  }
+  $answer =  "$ipercent percent inodes free on $opt_f";
+  if ((100 - $ipercent) < $opt_w) {
+    $state = 'OK';
+  } elsif ((100 - $ipercent) < $opt_c) {
+    $state = 'WARNING';
+  } else {
+    $state = 'CRITICAL';
+  }
+  last;
 }
 
 close(DF);
 
-print "$answer";
-exit $state;
-
-sub print_usage () {
-        print "Usage: $PROGNAME <filesystem> [-w <warn>] [-c <crit>]\n";
-	print "Example: $PROGNAME /dev/ad0s1a -w 50 -c 75\n";
-}
-                
-sub print_help () {
-        print_revision($PROGNAME,'$Revision: 1.1 $');
-        print "Copyright (c) 2002 Andrew Ryder\n";
-        print "\n";
-        print_usage();
-        print "\n";
-        print "<warn> = Inode Percent at which a warning message is returned. Defaults to 50.\n";
-        print "<crit> = Inode Percent at which a critical message is returned..\n        Defaults to 75.\n\n";
-        support();
-}
- 
+$plugin->stop_timeout();
 
+print "$PROGNAME $state: $answer\n";
+exit $ERRORS{state};
