diff options
author | Ethan Galstad <egalstad@users.sourceforge.net> | 2002-04-18 21:59:26 (GMT) |
---|---|---|
committer | Ethan Galstad <egalstad@users.sourceforge.net> | 2002-04-18 21:59:26 (GMT) |
commit | 58fad23452357dae19db896c06c025592f6d34c9 (patch) | |
tree | 45f66a2438a889c2e52b8ae8aedce9f2c83f4f43 /contrib | |
parent | 05f12af006afa4b642059bbd3b4f4c3bd736719f (diff) | |
download | monitoring-plugins-58fad23452357dae19db896c06c025592f6d34c9.tar.gz |
add check_inodes contrib plugin by John Jolet
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@16 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/check_inodes.pl | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/contrib/check_inodes.pl b/contrib/check_inodes.pl new file mode 100755 index 0000000..5767878 --- /dev/null +++ b/contrib/check_inodes.pl | |||
@@ -0,0 +1,69 @@ | |||
1 | #!/usr/bin/perl | ||
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. # | ||
8 | # # | ||
9 | ############################################################################## | ||
10 | |||
11 | $filesystem = $ARGV[0]; | ||
12 | $warnpercent = $ARGV[1]; | ||
13 | $critpercent = $ARGV[2]; | ||
14 | |||
15 | #------Find out what kind of syntax to expect | ||
16 | $systype=`uname`; | ||
17 | chomp($systype); | ||
18 | |||
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; | ||
23 | |||
24 | if ($#ARGV < 2) { | ||
25 | die "Usage: check_inodes filesystem warnpercent critpercent"; | ||
26 | }#end if | ||
27 | |||
28 | #------This gets the data from the df command | ||
29 | $inputline = `df -i $filesystem|grep -v "Filesystem"`; | ||
30 | |||
31 | #------replaces all spaces with a single :, that way we can use split | ||
32 | $inputline =~ y/ /:/s; | ||
33 | |||
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. | ||
38 | SWITCH: { | ||
39 | if ($systype eq "Linux") { | ||
40 | ($fs,$inodes,$iused,$ifree,$ipercent,$mntpt) = split(/:/,$inputline); | ||
41 | last SWITCH; | ||
42 | }#end if | ||
43 | if ($systype eq "AIX") { | ||
44 | ($fs,$blks,$free,$percentused,$iused,$ipercent,$mntpt) = split(/:/,$inputline); | ||
45 | last SWITCH; | ||
46 | }#end if | ||
47 | }#end switch | ||
48 | |||
49 | #------First we check for critical, since that is, by definition and convention | ||
50 | #------going to exceed the warning threshold | ||
51 | $ipercent =~ y/%//ds; | ||
52 | |||
53 | if ($ipercent > $critpercent) { | ||
54 | print "CRITICAL: $filesystem inode use exceeds critical threshold $critpercent ($ipercent)"; | ||
55 | exit 1; | ||
56 | }# end if | ||
57 | |||
58 | #------Next we check the warning threshold | ||
59 | if ($ipercent > $warnpercent) { | ||
60 | print "WARNING: $filesystem inode use exceeds warning threshold $warnpercent ($ipercent)"; | ||
61 | exit 2; | ||
62 | }# end if | ||
63 | |||
64 | |||
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)"; | ||
68 | exit 0; | ||
69 | |||