RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
为nagios编写检查Mem脚本

[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
       }

重启服务即可


当前名称:为nagios编写检查Mem脚本
网站地址:http://scyingshan.cn/article/jidjsc.html