Edit the configuration file in the following location on the client
1, vim/usr/lib64/nagios/pligins/check_disk.sh
#!/bin/bash
#!/bin/bash
row= ' df-h |wc-l '
For i in ' seq 2 $row '
Do
ava= ' df-h |sed-n "$i" P|awk ' {print $4} '
u_per= ' df-h |sed-n "$i" P|sed-n "s/\%//" P|awk ' {print $
p_p= ' df-h-p|sed-n "$i" P|awk ' {print $6} '
if ["$u _per"-gt "];then "
echo-n "$p _p CRITICAL $u _per% $ava"
sta[$i]=2# represents an array
elif ["$u _per"-gt "];then "
echo-n "$p _p warning! $u _per% $ava "#echo-N to make the contents of the output non-newline
sta[$i]=1#表示数组
Else
echo-n "$p _p OK $u _per% $ava"
sta[$i]=0#表示数组
fi
Done
n=0
For J in ' seq 2 $row '
Do
if ["${sta[$j]}"-gt $n];then
n=${sta[$j]}
fi
Done
Exit $n
2. After saving, modify the permissions of the script
chmod +x/usr/lib/nagios/plugins//check_disk.sh (on client)
3. Then edit the/etc/nagios/nrpe.cfg file
Vim/etc/nagios/nrpe.cfg # Add a line: (on client)
command[check_disk]=/usr/lib/nagios/plugins/check_disk.sh
Save, restart Nrpe service
/etc/init.d/nrpe Restart (on client)
4. The way to detect if the script is working correctly is to execute the following command to the server side:
check_nrpe-h 192.168.0.12-c check_disk (on server)
if normal, it will output a row of disk detection data, or may be error.
5. Add the appropriate service to the server
cd/etc/nagios/conf.d/
Vim 192.168.0.12.cfg # Add the following:
define service{
Use generic-service
host_name 192.168.0.12
service_description Check_disk
Check_command Check_nrpe!check_disk
max_check_attempts 5
Normal_check_interval 1
}
6. Restart the Nagios service
/etc/init.d/nagios Restart (on server)
7. Use browser access to discover that a monitoring service has been added
This article is from the "愺 Burgundy pounding his 豩" blog, please be sure to keep this source http://riverxyz.blog.51cto.com/533303/1793144
Nagios Custom Monitoring HDD Script