在監(jiān)控端及nagios服務(wù)器上添加如下腳本
我們提供的服務(wù)有:成都網(wǎng)站設(shè)計(jì)、做網(wǎng)站、微信公眾號(hào)開(kāi)發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、平谷ssl等。為數(shù)千家企事業(yè)單位解決了網(wǎng)站和推廣的問(wèn)題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的平谷網(wǎng)站制作公司
[root@nagios libexec]# cat /usr/local/nagios/libexec/check_mem.sh
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`
echo "$FREE MB ($PERCENT%) Free Memory"
exit 0
vim /usr/local/nagios/etc/objects/commands.cfg (添加)
definecommand{
command_namecheck_mem
command_line$USER1/check_mem.sh -H $HOSTADDRESS$
}
vim /usr/local/nagios/etc/objects/services.cfg (添加)
define service{
use local-service
host_name MySQLhost
service_groups mysqlgroup
service_description check_mem
check_command check_nrpe!check_mem.sh
max_check_attempts 2
normal_check_interval 3
retry_check_interval 2
check_period 24x7
notification_interval 5
notification_period 24x7
notification_options w,u,c,r
contact_groups admins
}
在被監(jiān)控端
[root@171 html]# cat /usr/local/nagios/libexec/check_mem.sh
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`
echo "$FREE MB ($PERCENT%) Free Memory"
exit 0
vim /usr/local/nagios/etc/nrpe.cfg (添加)
command[check_mem.sh]=/usr/local/nagios/libexec/check_mem.sh
重啟xientd服務(wù)
/etc/init.d/xinted restart
監(jiān)控端
重啟nagios服務(wù)
/etc/init.d/nagios restart