本篇内容主要讲解“nagios怎么监控linux内存”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“nagios怎么监控linux内存”吧!
在被监控机
1./usr/local/nagios/libexec/ 下添加check_mem
内容如下
#
#!/bin/bash# check memory script# sunny 2008.2.15
# 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 / totalFREETMP=`expr $FREE \* 100`PERCENT=`expr $FREETMP / $TOTAL`
echo "$FREE MB ($PERCENT%) Free Memory"exit 0
2. chmod a+x check_mem.sh
3.vi /usr/local/nagios/etc/nrpe.cfg 增加command
command[check_mem]=/usr/lib64/nagios/plugins/check_mem.sh -w 10 -c 5
nagios 服务端
1.在command.cfg添加如下 (这一步好像也可以不用)
# 'check_mem' command definitiondefine command{ command_name check_mem command_line $USER1$/check_mem -H $HOSTADDRESS$ }
2.修改linux客户机配置文件,添加
define service{
use generic-service
host_name mylinux
service_description check_mem
check_command check_nrpe!check_mem
}
3.验证配置: nagios -v /etc/nagios/nagios.cfg
4.重启nagios :service nagios restart
5.登录查看web监控
到此,相信大家对“nagios怎么监控linux内存”有了更深的了解,不妨来实际操作一番吧!这里是恰卡编程网网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!