• Nagios监控的部署与配置


    【安装Nagios】

    yum install -y httpd httpd-devel httpd-tools mysql mysql-devel mysql-server php php-devel php-mysql

    [root@Nagios-server ~]# wget http://jaist.dl.sourceforge.net/project/nagios/nagios-4.x/nagios-4.0.1/nagios-4.0.1.tar.gz

    [root@Nagios-server ~]# tar zxvf nagios-4.0.1.tar.gz

    [root@Nagios-server ~]# cd nagios-4.0.1

    [root@Nagios-server nagios-4.0.1]# useradd -M -s /sbin/nologin  nagios
    [root@Nagios-server nagios-4.0.1]# ./configure --prefix=/usr/local/nagios

    [root@Nagios-server nagios-4.0.1]# make all 

    [root@Nagios-server nagios-4.0.1]# make install

    [root@Nagios-server nagios-4.0.1]# make install-init

    [root@Nagios-server nagios-4.0.1]# make install-commandmode

    [root@Nagios-server nagios-4.0.1]# make install-config

    [root@Nagios-server nagios-4.0.1]# chkconfig --add nagios
    [root@Nagios-server nagios-4.0.1]# chkconfig nagios on

    [root@Nagios-server nagios-4.0.1]#ls /usr/local/nagios/
    bin etc libexec sbin share var

    【安装Nagios-plugins插件】

    [root@Nagios-server ~]# wget http://www.nagios-plugins.org/download/nagios-plugins-1.5.tar.gz

    [root@Nagios-server ~]# tar zxvf nagios-plugins-1.5.tar.gz 

    [root@Nagios-server ~]# cd nagios-plugins-1.5
    [root@Nagios-server nagios-plugins-1.5]# ./configure --prefix=/usr/local/nagios/

    oot@localhost nagios-plugins-1.5]# make && make install 

    [安装nrep插件]

    [root@Nagios-server ~]# yum install -y openssl-devel

    [root@Nagios-server ~]# wget http://jaist.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz

    [root@Nagios-server ~]# tar zxvf nrpe-2.15.tar.gz

    [root@Nagios-server ~]# cd nrpe-2.15
    [root@Nagios-server nrpe-2.15]# ./configure && make all 

    [root@Nagios-server nrpe-2.15]# make install-plugin

    为了安全设置页面认证权限

    [root@Nagios-server ~]# vim /etc/httpd/conf/httpd.conf

    ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin/"
    <Directory "/usr/local/nagios/sbin/">
    Options ExecCGI
    AllowOverride None
    Order allow,deny
    Allow from all
    AuthName "Nagios Acess"
    AuthType Basic
    AuthUserFile /usr/local/nagios/etc/htpasswd.users

    Require valid-user
    </Directory>
    Alias /nagios "/usr/local/nagios/share"
    <Directory "/usr/local/nagios/share">
    Options None
    AllowOverride None
    Order allow,deny
    Allow from all
    AuthName "Nagios Access"
    AuthType Basic
    AuthUserFile /usr/local/nagios/etc/htpasswd.users
    Require valid-user
    </Directory>

    [root@Nagios-server ~]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
    New password:
    Re-type new password:
    Adding password for user nagiosadmin

    [root@Nagios-server ~]# /etc/init.d/nagios start 

    配置nagios监控系统

    [root@Nagios-server ~]# vim /usr/local/nagios/etc/nagios.cfg

    cfg_file=/usr/local/nagios/etc/objects/hostgroups.cfg
    cfg_file=/usr/local/nagios/etc/objects/192.168.20.227.cfg

    [root@localhost ~]# vim /usr/local/nagios/etc/objects/hostgroups.cfg     #定义主机组

    define hostgroup{
    hostgroup_name
    alias
    members 192.168.20.227
    }    
    [root@localhost ~]# vim /usr/local/nagios/etc/objects/192.168.20.227.cfg     #定义被控主机的本地资源实际监控配置

    define host{
    use linux-server
    host_name 192.168.20.227
    alias 192.168.20.227
    address 192.168.20.227
    check_command check-host-alive
    max_check_attempts 5
    check_period 24x7
    notification_period 24x7
    notification_options d,u,r
    contact_groups bixiaoyu

    define service {
    user generic-service
    host_name 192.168.20.227
    service_description Disk Partition
    chkck_comand check_nrpe! check_disk
    }
    define service {
    user generice-service
    host_name 192.168.20.227
    service_description swap Useage
    chkck_comand chck_nrpe! check_swap
    }

    define service {
    user  generice-service
    host_name 192.168.20.227
    service_description MEM Partition
    chkck_comand chck_nrpe! check_mem
    }

    define service {
    user generice-service
    host_name 192.168.20.227
    service_description Current Load
    chkck_comand chck_nrpe! chck_load
    }


    define service {
    user generice-service
    host_name 192.168.20.227
    service_description Disk Partition
    chkck_comand chck_nrpe! check_iostat!5!11
    }

    define service {
    user  generice-service
    host_name 192.168.20.227
    service_description Ping
    chkck_comand chck_ping! 100.0,20%! 500.0,60%
    }

     

    【nagios被控端】

    [root@nagios-clinet ~]# yum install -y openssl openssl-devel

    [root@nagios-clinet ~]# useradd -s /sbin/nologin nagios
    [root@nagios-clinet ~]# wget http://www.nagios-plugins.org/download/nagios-plugins-1.5.tar.gz

    [root@nagios-clinet ~]# tar zxvf nagios-plugins-1.5.tar.gz

    [root@nagios-clinet ~]# cd nagios-plugins-1.5
    [root@nagios-clinet nagios-plugins-1.5]# ./configure --prefix=/usr/local/nagios

    [root@nagios-clinet nagios-plugins-1.5]# make && make install 

    [root@nagios-clinet nagios-plugins-1.5]# chown -R nagios:nagios /usr/local/nagios/

    [root@nagios-clinet ~]# wget http://jaist.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz

    [root@nagios-clinet ~]# tar zxvf nrpe-2.15.tar.gz

    [root@nagios-clinet ~]# cd nrpe-2.15
    [root@nagios-clinet nrpe-2.15]# ./configure --prefix=/usr/local/nagios/

    [root@nagios-clinet nrpe-2.15]# make all

    [root@nagios-clinet nrpe-2.15]# make install-plugin

    [root@nagios-clinet nrpe-2.15]# make install-daemon

    [root@nagios-clinet nrpe-2.15]# make install-daemon-config

    [root@nagios-clinet nrpe-2.15]# ps -ef | wc -l
    114
    [root@nagios-clinet nrpe-2.15]# more /proc/cpuinfo | grep proc | wc -l
    1

    [root@nagios-clinet nrpe-2.15]# vim /usr/local/nagios/etc/nrpe.cfg 

    allowed_hosts=127.0.0.1,192.168.20.226

    [root@nagios-clinet nrpe-2.15]# /usr/local/nagios/bin/nrpe   -c /usr/local/nagios/etc/nrpe.cfg -d 

    [root@nagios-clinet nrpe-2.15]# vim /etc/sysconfig/iptables      #开通监控机对5666端口访问的权限

    -A INPUT -p tcp --dport 5666 -j ACCEPT

    [root@nagios-clinet nrpe-2.15]# /etc/init.d/iptables restart 

    [root@Nagios-server ~]# /usr/local/nagios/libexec/check_nrpe -H 192.168.20.227
    NRPE v2.15

     PS:通过grep -ir 【IP地址】$ *修改完配置文件时,先检查配置文件,然后进行reload重新加载生效

    [root@nagios251-219 etc]# /opt/nagios/bin/nagios -v /opt/nagios/etc/nagios.cfg

    ###

    邮件通知 配置

  • 相关阅读:
    20190318-使用类做一个简单的图书馆管理系统
    20190313-面向对象的简单理解
    20190313-时间和日期-Time
    20190305-leetcode题目有效的括号
    20190227-做一个简易代码统计工具
    20190226-利用序列化完成小型记账程序
    20190221-文件操作
    20190131-文件操作命题练习
    Excel技巧—如何从重复行中取某一行
    Excel技巧—轻松搞定多级联动下拉列表
  • 原文地址:https://www.cnblogs.com/bixiaoyu/p/7764933.html
Copyright © 2020-2023  润新知