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


Remember Me

check_disk - % used space

5 votes
check_diskcheck_disk v0.0.2

Help Support Ethan Galstad's New Project:

Help Support Ethan

A Message From The Founder...

As the founder of Nagios, I'm asking for your help in a cause that's dear to my heart.

I'm launching a new project to help better the world by providing the information, ideas, and inspiration that I believe can improve the lives of people everywhere.

I know you're busy managing networks, but I would appreciate it if you would consider liking my Facebook page and showing your support for the content and messages I produce by sharing them with your friends and family.

You can learn more about my project by visiting ethangalstad.me/nagios. Thank you for your time. I wish you all the best in your endeavors, whatever they may be.

- Ethan

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

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