2
##############################################################################
3
# This plugin uses df to gather filesystem statistics and check the percent #
4
# used of inodes. I've put a switch in here since i've got both aix and #
5
# linux systems...adjust for your syntax's results. #
6
# Note: the percentages passed in MUST NOT have % after them #
7
# No warranty is either implied, nor expressed herein. #
9
##############################################################################
11
$filesystem = $ARGV[0];
12
$warnpercent = $ARGV[1];
13
$critpercent = $ARGV[2];
15
#------Find out what kind of syntax to expect
19
#------Make sure we got called with the right number of arguments
20
#------you could also put a check in here to make sure critical level is
21
#------greater than warning...but what the heck.
22
die "Usage: check_inodes filesystem warnpercent critpercent" unless @ARGV;
25
die "Usage: check_inodes filesystem warnpercent critpercent";
28
#------This gets the data from the df command
29
$inputline = `df -i $filesystem|grep -v "Filesystem"`;
31
#------replaces all spaces with a single :, that way we can use split
32
$inputline =~ y/ /:/s;
34
#------different oses give back different sets of columns from the df -i
35
#------(at least mine do). This way I can use this plugin on all my hosts
36
#------if neither of these work, add your own in, or if you've got one that
37
#------just flat out reports something different...well...perl is your friend.
39
if ($systype eq "Linux") {
40
($fs,$inodes,$iused,$ifree,$ipercent,$mntpt) = split(/:/,$inputline);
43
if ($systype eq "AIX") {
44
($fs,$blks,$free,$percentused,$iused,$ipercent,$mntpt) = split(/:/,$inputline);
49
#------First we check for critical, since that is, by definition and convention
50
#------going to exceed the warning threshold
53
if ($ipercent > $critpercent) {
54
print "CRITICAL: $filesystem inode use exceeds critical threshold $critpercent ($ipercent)";
58
#------Next we check the warning threshold
59
if ($ipercent > $warnpercent) {
60
print "WARNING: $filesystem inode use exceeds warning threshold $warnpercent ($ipercent)";
65
#------thanks to the magic of procedural programming, we figure if we got here,
66
#------everything MUST be fine.
67
print "$filesystem inode use within limits ($ipercent)";