zoukankan      html  css  js  c++  java
  • yum安装nagois

    多少年前就装过了,今天再来用yum装一次,都忘干净了~~

    主监控机:CentOS 6.5 192.168.0.105
    被监控机:CentOS 6.5 192.168.0.107


    主监控机设置:
    1、安装epel,http,php

    wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm 
    rpm -ivh epel-release-latest-6.noarch.rpm
    yum -y install httpd php

    2、安装nagios、nagios-plugin与nrpe (nagios 4.3.4版本)

    yum install -y nagios nagios-plugins nagios-plugins-all nagios-plugins-nrpe nrpe
    3、启动apache与nagios
    /etc/init.d/httpd restart
    /etc/init.d/nagios start
    4、登陆http://localhost/nagios/,输入用户密码后查看是否正常运行
    注:别忘记了nagios后面那个/,不然……


    被监控机设置:
    1、安装需要软件

    wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm 
    rpm -ivh epel-release-latest-6.noarch.rpm
    yum install -y nagios-plugins nagios-plugins-nrpe nrpe nagios-plugins-load nagios-plugins-disk nagios-plugins-swap

    2、配置nrpe

    vi /etc/nagios/nrpe.cfg 修改监控机的地址或域名
    allowed_hosts=127.0.0.1,192.168.0.105
    3、修改/etc/hosts.allow增加主监控机ip
    echo 'nrpe:192.168.0.105' >> /etc/hosts.allow
    4、启动 NRPE 守护进程:
    /usr/sbin/nrpe -c /etc/nagios/nrpe.cfg -d
    可以将此命令加入 /etc/rc.local ,以便开机自动启动。
    echo "/usr/sbin/nrpe -c /etc/nagios/nrpe.cfg -d" >> /etc/rc.local

    以下在主监控机上执行
    1、从主监控机上检查 NRPE 是否正常:
    /usr/lib64/nagios/plugins/check_nrpe -H 192.168.0.107
    输出为NRPE v3.2.0

    2. 添加nrpe的定义
    vi /etc/nagios/objects/commands.cfg

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

    3. 增加主监控机配置项vi /etc/nagios/objects/11.cfg

    define host{
    use linux-server
    host_name 192.168.0.107
    alias 192.168.0.107
    address 192.168.0.107
    }
    define service{
    use generic-service
    host_name 192.168.0.107
    service_description load
    check_command check_nrpe!check_load
    }
    define service{
    use generic-service
    host_name 192.168.0.107
    service_description PING
    check_command check_ping!100.0,20%!200.0,50%
    max_check_attempts 5
    normal_check_interval 1
    }
    define service{
    use generic-service
    host_name 192.168.0.107
    service_description FTP
    check_command check_ftp!21
    max_check_attempts 5
    normal_check_interval 1
    }
    define service{
    use generic-service
    host_name 192.168.0.107
    service_description SSH
    check_command check_ssh
    max_check_attempts 5
    normal_check_interval 1
    }
    define service{
    use generic-service
    host_name 192.168.0.107
    service_description HTTP
    check_command check_http
    max_check_attempts 5
    normal_check_interval 1
    }

    并把11.cfg添加到nagios主配置项

    echo "cfg_file=/etc/nagios/objects/11.cfg" >> /etc/nagios/nagios.cfg
    其他机器如法炮制即可

    4. 重启监控机nagios
    /etc/init.d/nagios reload
    重新打开监控查看,是否已经有新机器上线!

     看看效果

    哎!想当年那环境,苦逼的离线安装各种软件。。。。没网真的不行啊!!!!! 

  • 相关阅读:
    数据库语句中(+)是什么意思
    MySQL的存储引擎(二)解决Warning Code : 3719 'utf8' is currently an alias for the character set UTF8MB3,...
    MSQL存储引擎(一)
    fastjson的使用,在redis里面存list
    js的发展历史,笔记
    spring的断言工具类Assert的基本使用
    httpclient的使用
    nginx的反向代理
    使用 Redis 连接池的原因
    springboot的yml自定义值的笔记
  • 原文地址:https://www.cnblogs.com/tcicy/p/8531718.html
Copyright © 2011-2022 走看看