bin/checkfs
changeset 2 bc2f76c0908a
parent 1 56ae2cc9eea9
child 3 bdbd5e99f85a
equal deleted inserted replaced
1:56ae2cc9eea9 2:bc2f76c0908a
     1 #! /usr/bin/perl
     1 #! /usr/bin/perl
       
     2 use 5.10.0;
     2 use strict;
     3 use strict;
     3 use warnings;
     4 use warnings;
     4 use Pod::Usage;
     5 use Pod::Usage;
     5 use Getopt::Long;
     6 use Getopt::Long;
     6 use Nagios;
     7 use Nagios;
     7 
     8 
     8 my $fs;
     9 my $fs;
     9 
    10 
    10 GetOptions(
    11 GetOptions(
    11     "h|help" => sub { pod2usage(-exit => 0, -verbose => 1) },
    12     "h|help" => sub { pod2usage(-exit => 0, -verbose => 1) },
    12     "m|man" => sub { pod2usage(-exit => 0, -verbose => 2, 
    13     "m|man"  => sub {
    13 	-noperldoc => system("perldoc -V 2>/dev/null 1>&2")) },
    14         pod2usage(
       
    15             -exit      => 0,
       
    16             -verbose   => 2,
       
    17             -noperldoc => system("perldoc -V 2>/dev/null 1>&2")
       
    18         );
       
    19     },
    14 ) and $fs = shift // pod2usage;
    20 ) and $fs = shift // pod2usage;
    15 
    21 
    16 return Nagios::CRITICAL;
    22 ($fs, my ($blocks, $used, $avail, undef, $mp)) =
       
    23   split " " => (`df -P -B 1K $fs`)[1];
       
    24 my $msg = "$fs on $mp: left ${avail}kB of ${blocks}kB";
    17 
    25 
       
    26 given ($avail / $blocks) {
       
    27     when ($_ < 0.1) { print "FS CRIT - $msg\n"; exit Nagios::CRITICAL }
       
    28     when ($_ < 0.3) { print "FS WARN - $msg\n"; exit Nagios::WARNING }
       
    29     default         { print "FS OK - $msg\n";   exit Nagios::OK }
       
    30 }
    18 
    31 
    19 __END__
    32 __END__
    20 
    33 
    21 =head1 NAME
    34 =head1 NAME
    22 
    35 
    40 
    53 
    41 =item B<-m>|B<--man>
    54 =item B<-m>|B<--man>
    42 
    55 
    43 The usual help messages;
    56 The usual help messages;
    44 
    57 
    45 
       
    46 =back
    58 =back
    47 
    59 
    48