nagios监控配置与邮件告警

nagios监控配置与邮件告警

ip 主机名 备注
172.16.121.227 nagios 服务端
172.16.121.228 client 客户端

这里还需要安装nagios服务以及插件可以参考我之前的博客:https://blog.csdn.net/miss_miss6/article/details/105061694
1.先设置服务端
[root@nagios ~]# vi /usr/local/nagios/etc/nrpe.cfg
修改和添加2条命令

allowed_hosts=127.0.0.1,::1,172.16.121.0/24    加上监控网段
command[check_nagios]=/usr/local/nagios/libexec/check_nagios -e 5 -F /usr/local/nagios/var/status.dat -C /usr/local/nagios/bin/nagios     

2.配置客户端
这里先测试服务端配置是否正常

[root@client ~]# cd /usr/local/nagios/libexec/
[root@client libexec]# ./check_nrpe -H 172.16.121.227
NRPE v3.1.0-rc1
[root@client libexec]# ./check_nrpe -H 172.16.121.227 -c check_nagios
NAGIOS OK: 6 processes, status log updated 1 second ago

复制相关文档到/usr/local/nagios/libexec/eventhandlers/下

cd /root/wjh/nagios-4.3.1/contrib/eventhandlers/
cp enable_notifications /usr/local/nagios/libexec/eventhandlers/
cp disable_notifications /usr/local/nagios/libexec/eventhandlers/
cp redundancy-scenario1/handle-master-host-event /usr/local/nagios/libexec/eventhandlers/
cp redundancy-scenario1/handle-master-proc-event /usr/local/nagios/libexec/eventhandlers/
sed -i 's/active_service_checks/notifications/g' /usr/local/nagios/libexec/eventhandlers/handle-master-proc-event
chown nagios.nagios /usr/local/nagios/libexec/eventhandlers/*
chmod 755 /usr/local/nagios/libexec/eventhandlers/*

修改/usr/local/nagios/etc/objects/commands.cfg文件

define command {
 command_name handle-master-host-event
 command_line $USER1$/eventhandlers/handle-master-host-event $HOSTSTATE$ $HOSTSTATETYPE$ $HOSTATTEMPT$
}

define command {
 command_name handle-master-proc-event
 command_line $USER1$/eventhandlers/handle-master-proc-event $SERVICESTATE$ $SERVICESTATETYPE$ $SERVICEATTEMPT$
}

define command {
 command_name check_nrpe
 command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}

修改主机文件/usr/local/nagios/etc/objects/localhost.cfg

define host {
        use                             critical-host
        host_name                       nagiosMaster
        alias                           nagios master
        address                         172.16.121.227
        event_handler                   handle-master-host-event
}

define service {
        use                              critical-service
        host_name                        nagiosMaster
        service_description              NAGIOS
        check_command                    check_nrpe!check_nagios
        event_handler                    handle-master-proc-event
}

修改模板文件 /usr/local/nagios/etc/objects/templates.cfg

[root@client eventhandlers]# vi /usr/local/nagios/etc/objects/templates.cfg
define host{
        name                            critical-host
        use                             generic-host
        check_period                    24x7
        check_interval                  5
        retry_interval                  1
        max_check_attempts              10
        check_command                   check-host-alive
        notification_period             workhours
        notification_interval           120
        notification_options            d,u,r
        contact_groups                  admins
        register                        0
        }

define service{
        name                            critical-service
        active_checks_enabled           1
        passive_checks_enabled          1
        parallelize_check               1
        obsess_over_service             1
        check_freshness                 0
        notifications_enabled           1
        event_handler_enabled           1
        flap_detection_enabled          1
        failure_prediction_enabled      1
        process_perf_data               1
        retain_status_information       1
        retain_nonstatus_information    1
        is_volatile                     0
        check_period                    24x7
        max_check_attempts              1
        normal_check_interval           1
        retry_check_interval            1
        contact_groups                  admins
        notification_options            w,u,c,r
        notification_interval           60
        notification_period             24x7
         register                        0
        }

修改 /usr/local/nagios/etc/nagios.cfg

enable_notifications=0
use_retained_program_state=0

到这里监控服务端的配置基本完成重启两台的nagios服务
在这里插入图片描述
在这里插入图片描述
告警配置失败

发布了16 篇原创文章 · 获赞 0 · 访问量 357
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 深蓝海洋 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览