--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/checkfs.dominik Fri Jan 20 14:17:34 2012 +0100
@@ -0,0 +1,89 @@
+#!/usr/bin/perl
+
+#use 5.10.0;
+use strict;
+use warnings;
+use Pod::Usage;
+use Getopt::Long;
+use Nagios;
+
+#use Switch 'Perl6';
+
+my $fs;
+my $input = undef;
+my $mp;
+my $avail;
+my $blocks;
+my $used;
+my $msg;
+
+GetOptions(
+ "i|input=s" => \$input,
+ "h|help" => sub { pod2usage(-exit => 0, -verbose => 1) },
+ "m|man" => sub {
+ pod2usage(
+ -exit => 0,
+ -verbose => 2,
+ -noperldoc => system("perldoc -V 2>/dev/null 1>&2")
+ );
+ },
+);
+
+if (not defined $input) {
+ ($fs, $blocks, $used, $avail, undef, $mp) =
+ split " " => (`df -P -B 1K $fs`)[1];
+ $msg = "$fs on $mp: left ${avail}kB of ${blocks}kB";
+}
+else {
+ ($fs, $blocks, $used, $avail, undef, $mp) =
+ split " " => $input;
+ $msg = "$fs on $mp: left ${avail}kB of ${blocks}kB";
+}
+
+if ($avail * 100 / $blocks > 90) {
+ print "Warning - $msg\n";
+ exit Nagios::WARNING;
+}
+else {
+ print "OK - $msg\n";
+ exit Nagios::OK;
+}
+
+#given ($avail / $blocks) {
+# when ($_ < 0.1) { print "FS CRIT - $msg\n"; exit Nagios::CRITICAL }
+# when ($_ < 0.3) { print "FS WARN - $msg\n"; exit Nagios::WARNING }
+# default { print "FS OK - $msg\n"; exit Nagios::OK }
+#}
+
+__END__
+
+=head1 NAME
+
+ checkfs - check the current file system
+
+=head1 SYNOPSIS
+
+ checkfs [-i|--input]
+ checkfs [-h|--help]
+ checkfs [-m|--man]
+ checkfs <filesystem>
+
+=head1 DESCRIPTION
+
+B<checkfs> checks the filesystem.
+
+=head1 OPTIONS
+
+=over 5
+
+=item B<-i>|B<--input>
+
+=item B<-h>|B<--help>
+
+=item B<-m>|B<--man>
+
+The usual help messages;
+
+=back
+
+