LAMP壞境和LNMP環境安裝Nagios4.1.1和基本配置

來源:互聯網
上載者:User

標籤: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和基本配置

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.