nagios监控远程主机上的资源-cpu
利用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.cfgdefine 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/bashcpu=`uptime|awk '{print $9}'|sed -rn 's/(.*)\..*/\1/p'`if [ $cpu -gt 3 ];then echo fuck!!! the cup is died exit 2else echo Good the cup is ok exit 0fi
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、结果截图用ab 命令给对被监控主机压力测试,加重cpu的负载,使其实现报警
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.cfgdefine 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/bashcpu=`uptime|awk '{print $9}'|sed -rn 's/(.*)\..*/\1/p'`if [ $cpu -gt 3 ];then echo fuck!!! the cup is died exit 2else echo Good the cup is ok exit 0fi
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、结果截图用ab 命令给对被监控主机压力测试,加重cpu的负载,使其实现报警
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。