equal
deleted
inserted
replaced
1 #! /usr/bin/perl |
|
2 |
|
3 #use 5.10.0; |
|
4 use Switch 'Perl6'; |
|
5 use strict; |
|
6 use warnings; |
|
7 use Pod::Usage; |
|
8 use Getopt::Long; |
|
9 use Nagios; |
|
10 |
|
11 my $fs; |
|
12 |
|
13 GetOptions( |
|
14 "h|help" => sub { pod2usage(-exit => 0, -verbose => 1) }, |
|
15 "m|man" => sub { |
|
16 pod2usage( |
|
17 -exit => 0, |
|
18 -verbose => 2, |
|
19 -noperldoc => system("perldoc -V 2>/dev/null 1>&2") |
|
20 ); |
|
21 }, |
|
22 ) |
|
23 and defined($fs = shift) |
|
24 or pod2usage; |
|
25 |
|
26 my @df = $ENV{HARNESS_ACTIVE} ? <STDIN> : `df -P -B 1K '$fs'`; |
|
27 |
|
28 ($fs, my ($blocks, $used, $avail, undef, $mp)) = split " " => $df[1]; |
|
29 |
|
30 if (not defined $avail or not defined $blocks or $blocks == 0) { |
|
31 print "FS UNKNOWN - can't determine values for $fs\n"; |
|
32 exit Nagios::UNKNOWN; |
|
33 } |
|
34 |
|
35 my $ratio = int(100 * ($avail / $blocks)); |
|
36 my $msg = "$fs on $mp: left ${avail}kB of ${blocks}kB ($ratio%)"; |
|
37 if ($ratio > 30) { print "FS OK - $msg\n"; exit Nagios::OK } |
|
38 if ($ratio > 10) { print "FS WARN - $msg\n"; exit Nagios::WARNING } |
|
39 |
|
40 print "FS CRIT - $msg ($ratio%)\n"; |
|
41 exit Nagios::CRITICAL; |
|
42 |
|
43 __END__ |
|
44 |
|
45 =head1 NAME |
|
46 |
|
47 checkfs - check the current file system |
|
48 |
|
49 =head1 SYNOPSIS |
|
50 |
|
51 checkfs [-h|--help] |
|
52 checkfs [-m|--man] |
|
53 checkfs <filesystem> |
|
54 |
|
55 =head1 DESCRIPTION |
|
56 |
|
57 B<checkfs> checks the filesystem. |
|
58 |
|
59 =head1 OPTIONS |
|
60 |
|
61 =over 4 |
|
62 |
|
63 =item B<-h>|B<--help> |
|
64 |
|
65 =item B<-m>|B<--man> |
|
66 |
|
67 The usual help messages; |
|
68 |
|
69 =back |
|
70 |
|