码迷,mamicode.com
首页 > 移动开发 > 详细

LAMP坏境和LNMP环境安装Nagios4.1.1和基本配置

时间:2016-12-22 19:51:40      阅读:248      评论:0      收藏:0      [点我收藏+]

标签:admin   步骤   创建   cto   http   开机   .net   require   one   

----------------------------------------以下内容为笔者生产环境的监控,安装都是经过一步步测试的--------------------------------

    环境:LAMP :CentOS 6.8  、Apache 2.4、 Mysql 5.6 、 PHP 5.6.22

       LNMP: CentOS 6.8  、Nginx 1.10、 Mysql 5.6 、 PHP 5.6.22

    软件:Nagios4.1.1 、NRPE2.15、Nagios-plugins2.14、pnp4nagios0.6.25、NSClient++-Stable

安装环境确认:

  首先确认已经安装好LAMP环境或者LNMP环境,然后在按照需要看对应环境下的安装说明。

  我这里使用的是LAMP、LNMP一键安装包,安装的时候可以按需求安装对应软件的版本。wget http://soft.vpser.net/lnmp/lnmp1.3-full.tar.gz 

      其他软件请自行到Nagios官网去下载https://www.nagios.org/downloads/nagios-core, 或者百度搜索软件名称就会有了。我这里就不提供连接了

LAMP坏境下安装Nagios4.1.1

    服务器端安装:

      安装Nagios-4.1.1

      1、新建nagios用户

        useradd -s /sbin/nologin nagios

      2、解压nagios4.1.1软件,并且安装

        tar zxvf nagios-4.1.1.tat.gz

        cd nagios-4.1.1/

        ./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios

        make all && make install && make install-init && make install-commandmode && make install-config

      3、添加nagios开机自动启动

        chkconfig --add nagios

        chkconfig --level 35 nagios on

        chkconfig --list nagios

     安装nagios-plugin插件

      4、解压nagios-plugin软件,并且安装

        tar zxvf nagios-plugin-2.1.4.tar.gz

        ./configure --prefix=/usr/local/nagios && make && make install

      5、修改安装后的nagios目录所有者

        chown –R nagios.nagios /usr/local/nagios

     安装nrpe插件

      6、解压nrpe软件,并且安装 (这里只需要安装nrpe其中一个check_nrpe的插件即可)

        tar zxvf nrpe-2.15.tar.gz && cd nrpe.2.15

        ./configure && make all && make install-plugin 

      7、添加nrpe的命令到nagios的command.cfg文件里

        vim /usr/local/nagios/etc/objects/commands.cfg 添加如下:

          #‘check_nrpe ‘ command definition

            define command{

                          command_name check_nrpe

                    command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$

            }

    apache支持nagios配置

      8、修改apache文件vim /usr/local/apache/conf/httpd.conf

        添加或者修改:  

        User nagios

        Group nagios

        LoadModule actions_module modules/mod_actions.so

        LoadModule cgid_module modules/mod_cgid.so

        AddType application/x-httpd-php .php       

        DirectoryIndex index.html 后面添加 index.php

        文件最后添加如下内容:  

#setting for nagios

ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"

<Directory "/usr/local/nagios/sbin">

     AuthType Basic

     Options ExecCGI

     AllowOverride None

     Order allow,deny

     Allow from all

     AuthName "Nagios Access"

     AuthUserFile /usr/local/nagios/etc/htpasswd   //用于此目录访问身份验证的文件

     Require valid-user

</Directory>

Alias /nagios "/usr/local/nagios/share"

<Directory "/usr/local/nagios/share">

     AuthType Basic

     Options None

     AllowOverride None

     Order allow,deny

     Allow from all

     AuthName "nagios Access"

     AuthUserFile /usr/local/nagios/etc/htpasswd

     Require valid-user

</Directory>

  

      9、创建nagios web帐号

        /usr/local/apache2/bin/htpasswd -c /usr/local/nagios/etc/htpasswd nagiosadmin (这是nagios默认的帐号,也可以使用其他名称,,但要在cgi.cfg去添加自己的帐号)

      10、启动、停止Nagios

             Service nagios restart  重启nagios

             Service httpd restart   重启apache

      11、web登陆nagios

        http://xxx.xxx.xxx.xxx/nagios,帐号密码为第五步设置的帐号密码

至此Nagios的服务器端就安装好了!

 

Nagios监控Linux客户端

    Linux客户端只需要安装nagios-plugins和nrpe即可,步骤如下:

      1、新建nagios用户

        useradd -s /sbin/nologin nagios

      2、解压nagios-plugin软件,并且安装

        tar zxvf nagios-plugin-2.1.4.tar.gz

        ./configure --prefix=/usr/local/nagios && make && make install

      3、修改安装后的nagios目录所有者

        chown –R nagios.nagios /usr/local/nagios

      4、安装nrpe监控远程linux插件

        tar zxvf nrpe-2.15.tar.gz && cd nrpe-2.15

        ./configure && make all && make install-plugin && make install-daemon && make install-daemon-config && make install xinetd

      5、安装xinetd服务,nrpe依靠xinetd服务

        yum -y install xinetd

      6、修改nrpe配置文件

       vim /etc/xinetd.d/nrpe

             Only_from 后面增加nagios服务器的IP ,逗号隔开不要空格

             vim /usr/local/nagios/etc/nrpe.cfg

            allowed_hosts后面增加nagios服务器的IP ,逗号隔开不要空格

      7、启动nrpe和xinetd

             /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg –d

             service xinetd start

      8、nagios服务器端检查和被监控linux主机的通讯

        /usr/local/nagios/libexec/check_nrpe -H 192.168.16.222  (出现NRPE v2.15表示正常)

          NRPE v2.15

至此nagios的客户端就安装完毕!

 

Nagios监控Window客户端

    1、安装NSClient++

      双击运行,一直下一步,直到出现输入allowed hosts 和NSClient passwd

      输入对应nagios的服务器的IP,以及设置一个NSClient 的密码

      Modules to load 勾选里面 除了Enable WMI checks不勾选之外,其他都勾选,下一步安装完成。

    2、配置NSClient++

       进入NSClient的安装目录,打开NSC.ini文件,

       修改[modules]内容:除了;CheckWMI.dll 和 ;RemoteConfiguration.dll 其他的都去掉前面的分号。注意同样的就不需要重复打开了

         修改[Settings]内容:修改allowed_hosts= nagios的ip  password= 安装NSClient设置的密码

       修改[NSClient]内容:修改port=12489

     保存即可!

     3、启动NSClient

       cmd——>services.msc——>NSClient++ 启动该服务,并且设置为自动,登陆选项选择允许交互打勾。

至此nagios监控windows主机配置完成!

      

 

LAMP坏境和LNMP环境安装Nagios4.1.1和基本配置

标签:admin   步骤   创建   cto   http   开机   .net   require   one   

原文地址:http://www.cnblogs.com/harlanzhang/p/6212134.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!