温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

nagios 监控内存的插件

发布时间:2020-06-16 02:33:38 来源:网络 阅读:587 作者:李伯翔 栏目:移动开发

 老师,我从网上下载的。。。真的没思路啊。。

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}'`
# 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

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

 

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI