• 通过yum安装Nagios


    通过yum安装Nagios
    2012年04月05日 ⁄ Nagios ⁄ 暂无评论
     
     

    前提先自行安装好Apache+php

    测试环境
    主监控机:CentOS 6.0
    被监控机:CentOS 6.2

    主监控机设置:
    1、安装epel
    # cat /etc/issue
    CentOS release 6.0 (Final)
    Kernel on an m

    # rpm -ivh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm
    2、安装nagios、nagios-plugin与nrpe (nagios 3.3.1版本)
    # yum install nagios nagios-plugins nagios-plugins-all nagios-plugins-nrpe nrpe

    3、创建一个nagiosadmin 的用户用于Nagios的WEB接口登录,用户认证配置
    # htpasswd -c /usr/local/nagios/etc/htpasswd.users admin
    New password:
    Re-type new password:
    Adding password for user nagiosadmin

    4、修改nagios.conf
    修改保存用户密码文件
    AuthUserFile /etc/nagios/passwd 修改成--> AuthUserFile /etc/nagios/htpasswd.users
    保存退出

    5、修改cgi.cfg文件,找到use_authentication=1 这行,把1改成0

    6、启动apache与nagios
    # /etc/init.d/httpd restart
    # /etc/init.d/nagios start

    7、登陆http://localhost/nagios/,输入用户密码后查看是否正常运行
    注:别忘记了nagios后面那个/,不然……

    被监控机设置:
    1、安装需要软件
    # yum install nagios-plugins nagios-plugins-nrpe nrpe

    2、配置nrpe
    # vi /etc/nagios/nrpe.cfg 修改监控机的地址或域名
    allowed_hosts=127.0.0.1,192.168.5.11

    3、修改/etc/hosts.allow增加监控机ip
    # echo 'nrpe:192.168.5.22' >> /etc/hosts.allow

    4、检查 NRPE 是否正常:
    # /usr/lib/nagios/plugins/check_nrpe -H 192.168.5.11
    NRPE v2.12
    查看相应的端口:netstat -an |grep 5666
    防火墙开启5666 允许局域网IP或固定IP连接

    5、启动 NRPE 守护进程:
    # /usr/sbin/nrpe -c /etc/nagios/nrpe.cfg -d

    在回到监控机:
    添加nrpe的定义
    # vi commands.cfg
    # 'check_nrpe' command definition
    define command{
    command_name check_nrpe
    command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
    }

    增加主机监控配置项11.cfg
    define host{
    use linux-server
    host_name 192.168.5.11
    alias 192.168.5.11
    address 192.168.5.11
    }
    define service{
    use generic-service
    host_name 192.168.5.11
    service_description load
    check_command check_nrpe!check_load
    }
    define service{
    use generic-service
    host_name 192.168.5.11
    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.5.11
    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.5.11
    service_description SSH
    check_command check_ssh
    max_check_attempts 5
    normal_check_interval 1
    }
    define service{
    use generic-service
    host_name 192.168.5.11
    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
    其他机器如法炮制即可

    重启监控机nagios查看效果,关于短信通知参考另外一篇文章 http://blog.51bbo.com/archives/651

  • 相关阅读:
    大数板子
    数位dp
    BM算法
    牛客小白月赛7
    划分树
    可持久化线段树
    素数
    一些数学公式
    线性基
    ConcurrentHashMap 并发HashMap原理分析
  • 原文地址:https://www.cnblogs.com/best-jobs/p/3816862.html
Copyright © 2020-2023  润新知