温馨提示×

温馨提示×

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

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

nagios监控远程主机上的资源-cpu

发布时间:2020-06-09 06:11:45 来源:网络 阅读:2321 作者:vfast_gy_jingxl 栏目:移动开发
    利用nrpe通过nagios插件check_load监控主机的cpu使用情况
联系人及联系方式,发邮件等都已设置好,这里不再叙述。
1、在被监控主机上安装nrpe服务器,然后把nagios的所有插件都cp到nrpe的安装目录下,打开nrpe的配置文件nrpe.cfg,根据实际情况修改check_load插件的监控阀值。
command[check_load]=/usr/local/nagios/libexec/check_load -w 4,3,3 -c 6,4,3

2、在nagios端配置监控主机和服务,localhost.cfg文件
define host {
        host_name       Mmysql
        alias           master
        address         10.1.1.2
        check_command   check-host-alive
        notification_options    d,u,r
        check_interval  1
        max_check_attempts      2
        contact_groups  admins
        notification_interval   10
        notification_period     24x7
}
define service {
        host_name       Mmysql
        service_description     cpu
        check_period    24x7
        normal_check_interval   1
        retry_check_interval    1
        max_check_attempts      3
        notification_period     24x7
        notification_options    w,u,c,r
        check_command   check_nrpe!check_load
}
配置commands.cfg
define command {
        command_name    check_nrpe
        command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
3、重新载入nagios ,

4、自己编写插件,监控cpu
在被监控主机/usr/local/nagios/libexec 下编写check_cpu  shell脚本。
#!/bin/bash
cpu=`uptime|awk '{print $9}'|sed -rn 's/(.*)\..*/\1/p'`
if [ $cpu -gt 3 ];then
   echo fuck!!! the cup is died
  exit 2
else
   echo Good the cup is ok
  exit 0
fi

5、在nrpe的配置文件nrpe.cfg文件中定义新建的插件命令
command[check_cpu]=/usr/local/nagios/libexec/check_cpu  

6、在nagios端的localhost.cfg文件中定义监控服务

define service {
        host_name       Mmysql
        service_description     cpu_01
        check_period    24x7
        normal_check_interval   1
        retry_check_interval    1
        max_check_attempts      3
        notification_period     24x7
        notification_options    w,u,c,r
        check_command   check_cpu!check_cpu 
}

7、在commands.cfg文件中定义命令
define command {
        command_name    check_cpu
        command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}

8、重新载入nagios 

9、结果截图
nagios监控远程主机上的资源-cpu
用ab 命令给对被监控主机压力测试,加重cpu的负载,使其实现报警
nagios监控远程主机上的资源-cpu


nagios监控远程主机上的资源-cpu
向AI问一下细节

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

AI