apt-get install -y python nagios-nrpe-server useradd nrpe && update-rc.d nagios-nrpe-server defaults
#!/usr/bin/python
import os, sys
used_space=os.popen("df -h / | grep -v Filesystem | awk '{print $5}'").readline().strip()
if used_space < "85%":
print "OK - %s of disk space used." % used_space
sys.exit(0)
elif used_space == "85%":
print "WARNING - %s of disk space used." % used_space
sys.exit(1)
elif used_space > "85%":
print "CRITICAL - %s of disk space used." % used_space
sys.exit(2)
else:
print "UKNOWN - %s of disk space used." % used_space
sys.exit(3)
chmod +x /usr/lib/nagios/plugins/usedspace.py
| Exit Code | Status |
| 0 | OK |
| 1 | WARNING |
| 2 | CRITICAL |
| 3 | UNKNOWN |
log_facility=daemon pid_file=/var/run/nagios/nrpe.pid server_port=5666 nrpe_user=nrpe nrpe_group=nrpe allowed_hosts=198.211.117.251 dont_blame_nrpe=1 debug=0 command_timeout=60 connection_timeout=300 include_dir=/etc/nagios/nrpe.d/ command[usedspace_python]=/usr/lib/nagios/plugins/usedspace.py
service nagios-nrpe-server restart
define command{
command_name usedspace_python
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c usedspace_python
}define service {
use generic-service
host_name Ubuntu
service_description Custom Disk Checker In Python
check_command usedspace_python
}service nagios restart
Article ID: 262
Created On: Sat, Jan 4, 2014 at 1:31 AM
Last Updated On: Tue, Sep 23, 2025 at 11:06 PM
Authored by: ASPHostServer Administrator [[email protected]]
Online URL: http://faq.asphosthelpdesk.com/article.php?id=262