[root@nagios-server libexec]# pwd
/wxl/nagios/libexec
[root@nagios-server libexec]# ll check_mem.sh
-rwxr-xr-x 1 nagios nagios 370 May 29 14:39 check_mem.sh 所属主及组都是nagios
[root@nagios-server libexec]# cat check_mem.sh
#!/bin/bash
# check memory script
# wuxinglai 2013-05-29
# 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`
echo "$FREE MB ($PERCENT%) Free Memory"
exit 0
[root@nagios-server libexec]#
在/wxl/nagios/etc/objects/commands.cfg里添加一下配置
#'check_mem' command definition
define command{
command_name check_mem
command_line $USER1$/check_mem.sh -H $HOSTADDRESS$
}
在service.cfg 定义文件
define service{
use local-service ; Name of service template to use
host_name server01
service_description Current Mem
check_command check_mem
}
重启服务即可
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。