u_per= ' df-h |sed-n ' $i "p|sed-n" s/\%//"P|awk ' {print $} '
p_p= ' df-h-p|sed-n ' $i" P|aw K ' {print $6} '
If ["$u _per"-gt "" ];then
Echo-n "$p _p CRITICAL $u _per% $ava "
sta[$i ]=2
Elif ["$u _per"-gt "];then
echo-n" $p _p warning! $u _per% $ava "
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< Br>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.210.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
192.168.210.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)
A Nagios script for monitoring disks