3 # check_inodes.pl for FreeBSD
4 # Designed on FreeBSD 4.6 (although this should not matter)
5 # parses df output, splits, and then takes variables
6 # df.pl -f mountpoint -w warningnumber -c critical number
7 # USE NUMBERS AND NOT PERCENTS FOR wanring and critical values
11 # like / or /usr or /var (whatever you mount drives NOT the device names)
12 # Andrew Ryder - 20020804 - atr@mrcoffee.org
17 use vars
qw($opt_V $opt_h $opt_w $opt_c $opt_f $verbose $PROGNAME);
18 use lib "/usr/local/libexec/nagios" ;
19 use utils qw($TIMEOUT %ERRORS &print_revision &support);
22 my $grep = "/usr/bin/grep";
34 Getopt::Long::Configure('bundling');
36 ("V" => \$opt_V, "version" => \$opt_V,
37 "h" => \$opt_h, "help" => \$opt_h,
38 "w=s" => \$opt_w, "warning=s" => \$opt_w,
39 "c=s" => \$opt_c, "critical=s" => \$opt_c,
40 "f=s" => \$opt_f, "filesystem=s" => \$opt_f);
44 print_revision($PROGNAME,'$Revision: 72 $ ');
53 ($opt_w) || ($opt_w = shift) || ($opt_w = 50);
54 my $warning = $1 if ($opt_w =~ /([0-9]+)/);
56 ($opt_c) || ($opt_c = shift) || ($opt_c = 75);
57 my $critical = $1 if ($opt_c =~ /([0-9]+)/);
59 if ($opt_c < $opt_w) {
60 print "Critical offset should be larger than warning offset\n";
62 exit $ERRORS{"UNKNOWN"};
65 ($opt_f) || ($opt_f = "/");
69 print "UNKNOWN: $df is not where df is\n";
70 exit $ERRORS{'UNKNOWN'};
74 print "UNKNOWN: $grep is not where grep is\n";
75 exit $ERRORS{'UNKNOWN'};
79 print "UNKNOWN: $opt_f is not a mount point\n";
80 exit $ERRORS{'UNKNOWN'};
84 my $state = $ERRORS{'UNKNOWN'};
87 open(DF, "$df -i $opt_f| $grep -v Filesystem |");
91 my ($fs,$onek,$used,$avail,$capacity,$iused,$ifree,$ipercent,$mounted) = split;
94 if ($ipercent > $opt_w) {
95 $state = $ERRORS{'WARNING'};
96 $answer = "WARNING: $ipercent percent inodes free on $opt_f\n";
97 } elsif ($ipercent > $opt_w) {
98 $state = $ERRORS{'CRITCAL'};
99 $answer = "CRITICAL: $ipercent percent inodes free on $opt_f\n";
100 } elsif ($ipercent < $opt_w) {
101 $state = $ERRORS{'OK'};
102 $answer = "OK: $ipercent percent inodes free on $opt_f\n";
112 print "Usage: $PROGNAME <filesystem> [-w <warn>] [-c <crit>]\n";
113 print "Example: $PROGNAME /dev/ad0s1a -w 50 -c 75\n";
117 print_revision($PROGNAME,'$Revision: 72 $');
118 print "Copyright (c) 2002 Andrew Ryder\n";
122 print "<warn> = Inode Percent at which a warning message is returned. Defaults to 50.\n";
123 print "<crit> = Inode Percent at which a critical message is returned..\n Defaults to 75.\n\n";