老师,我从网上下载的。。。真的没思路啊。。
cd /usr/local/nagios/libexec/
vim check_vm
写入
#!/bin/bash
# check memory script
# Total memory
TOTAL=`free -m | head -2 |tail -1 |gawk '{print $2}'`
# Free memory
FREE=`free -m | head -2 |tail -1 |gawk '{print $4}'`
# check memory script
# Total memory
TOTAL=`free -m | head -2 |tail -1 |gawk '{print $2}'`
# Free memory
FREE=`free -m | head -2 |tail -1 |gawk '{print $4}'`
# to calculate free percent
# use the expression free * 100 / total
FREETMP=`expr $FREE \* 100`
PERCENT=`expr $FREETMP / $TOTAL`
# use the expression free * 100 / total
FREETMP=`expr $FREE \* 100`
PERCENT=`expr $FREETMP / $TOTAL`
echo "$FREE MB ($PERCENT%) Free Memory"
exit 0
exit 0
chmod +x check_vm
cd /usr/local/nagios/etc/objects
vim command
写入
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
vim services.cfg
define service{
host_name mysql
service_description check_vm
check_command check_nrpe!check_mem!192.168.111.3
max_check_attempts 3
normal_check_interval 2
retry_check_interval 1
check_period 24x7
notification_period 24x7
notification_options w,u,c,r
}
重启服务
service nsgios restart
转载于:https://blog.51cto.com/6241570/1087491