Home Directory Plugins Operating Systems Linux check_disk - % used space

Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com

Login

Remember Me

Directory Tree

check_disk - % used space

Rating
5 votes
Favoured:
1
Hits
189863
Files:
FileDescription
check_diskcheck_disk v0.0.2
Network Monitoring Software - Download Nagios XI
Log Management Software - Nagios Log Server - Download
Netflow Analysis Software - Nagios Network Analyzer - Download
Check the used space of a mounted partition using df, and prints it in percent scale.
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.
Reviews (2)
bynishith, September 20, 2017
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
}
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