Monitoring /proc/sys/fs/inode-nr
As part of a general overhaul of some Nagios scripts, I am adding parameters to the scripts so that the thresholds can be determined on a machine-by-machine basis. As an example, we are specifying percentage of disk free at which to trigger the critical and warning alerts.
One of the scripts monitors /proc/sys/fs/inode-nr
- this has two values, nr_inodes
and nr_free_inodes
. I don't have much understanding of the innards of UNIX, so I'm not quite sure whether it's possible to set a threshold on this file based upon the values within it.
nr_inodes
and nr_free_inodes
would suggest that the number of in-use inodes can be calculated as (nr_inodes - nr_free_inodes)
. Therefore, at a guess, as the number in-use gets closer to X% and Y% of nr_inodes
, the script should be triggering warning and critical alerts respectively.
Does this seem like a correct kind of assumption to make?
Solution 1:
Quoting kernel/Documentation/sysctl/fs.txt
Nr_inodes stands for the number of inodes the system has allocated, this can be slightly more than inode-max because Linux allocates them one pageful at a time.
Nr_free_inodes represents the number of free inodes (?) and preshrink is nonzero when the nr_inodes > inode-max and the system needs to prune the inode list instead of allocating more.
So your assumption is rather incorrect.
You can use "df -i" instead to get inode utilization.
Solution 2:
If you're looking to check disk inode usage (which is actually important for Virtuozzo/OpenVZ installs since we've had issues with that) the check_disk Nagios plugin has -iwarning and -icritical options:
-W, --iwarning=PERCENT% Exit with WARNING status if less than PERCENT of inode space is free
-K, --icritical=PERCENT% Exit with CRITICAL status if less than PERCENT of inode space is free