Search Exchange
Search All Sites
Nagios Live Webinars
Let our experts show you how Nagios can help your organization.Login
Directory Tree
check_disk - % used space
Meet The New Nagios Core Services Platform
Built on over 25 years of monitoring experience, the Nagios Core Services Platform provides insightful monitoring dashboards, time-saving monitoring wizards, and unmatched ease of use. Use it for free indefinitely.
Monitoring Made Magically Better
- Nagios Core on Overdrive
- Powerful Monitoring Dashboards
- Time-Saving Configuration Wizards
- Open Source Powered Monitoring On Steroids
- And So Much More!
Everybody is certanly asking 'why to write another check_disk plugin since the official "Nagios Plugins" comes with one?'
1) the official plugin prints the used space in the perfdata section in absolute values (MB), which isn't good for graphing, and
2) it's binary, and I need maximum portability (without recompiling it on every machine);
So this little Bourne Shell check_disk script was written.
It simple runs the 'df' program, greps the line of the specified device/mountpoint and prints the Used% column, do some basic checking to see if the result is suitable, sets the corresponding level (OK, WARNING or CRITICAL) and prints the results in nagios format.
1) the official plugin prints the used space in the perfdata section in absolute values (MB), which isn't good for graphing, and
2) it's binary, and I need maximum portability (without recompiling it on every machine);
So this little Bourne Shell check_disk script was written.
It simple runs the 'df' program, greps the line of the specified device/mountpoint and prints the Used% column, do some basic checking to see if the result is suitable, sets the corresponding level (OK, WARNING or CRITICAL) and prints the results in nagios format.
Reviews (2)
Here is my NRPE Output:
####NRPE Command####
# /usr/local/nagios/libexec/check_disk -w 80 -c 90 -d /dev/cciss/c0d0p1
OK - /dev/cciss/c0d0p1 space used=79% | '/dev/cciss/c0d0p1 usage'=79%;80;90;
###NRPE Config in /usr/local/nagios/etc/nrpe.cfg file###
command[check_root]=/usr/local/nagios/libexec/check_disk -w 80 -c 90 -d /dev/cciss/c0d0p1
###NAGIOS SERVER CONFIG###
define service{
use generic-service
host_name test.example.local
service_description ROOT Partition
check_command check_nrpe!check_root
check_interval 15
retry_interval 1
}
####NRPE Command####
# /usr/local/nagios/libexec/check_disk -w 80 -c 90 -d /dev/cciss/c0d0p1
OK - /dev/cciss/c0d0p1 space used=79% | '/dev/cciss/c0d0p1 usage'=79%;80;90;
###NRPE Config in /usr/local/nagios/etc/nrpe.cfg file###
command[check_root]=/usr/local/nagios/libexec/check_disk -w 80 -c 90 -d /dev/cciss/c0d0p1
###NAGIOS SERVER CONFIG###
define service{
use generic-service
host_name test.example.local
service_description ROOT Partition
check_command check_nrpe!check_root
check_interval 15
retry_interval 1
}
bytmoensted, March 5, 2013
I like the fact that you report how much is used instead of how much is free.
A couple of suggestions;
Instead of getting details for all devices (df -P | grep -w $device) try just checking the needed device (df -P $device |tail -1)
I like to also see the numbers the percentage is based on in nagios - you could consider checking like this;
read size used free usedPercent rinting the results:
echo "$msg - $device space used=$usedPercent% ($used of $size used) | '$device usage'=$usedPercent%;$warning;$critical;"
Just my thoughs :)
Best regards
Theis M. Mønsted
A couple of suggestions;
Instead of getting details for all devices (df -P | grep -w $device) try just checking the needed device (df -P $device |tail -1)
I like to also see the numbers the percentage is based on in nagios - you could consider checking like this;
read size used free usedPercent rinting the results:
echo "$msg - $device space used=$usedPercent% ($used of $size used) | '$device usage'=$usedPercent%;$warning;$critical;"
Just my thoughs :)
Best regards
Theis M. Mønsted