溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

CentOS安裝配置nagios(1)

發(fā)布時間:2020-07-08 11:21:05 來源:網(wǎng)絡(luò) 閱讀:478 作者:hujunshao 欄目:移動開發(fā)

一,事前準備

   安裝nagios前需要解決用戶,依賴包之類的問題。正所謂三軍未動糧草先行。


    1.yum -y install gcc automake autoconf libtool make gd zilb

         安裝   gcc等必要工具

         2. 建立nagios專用的用戶和組。  useradd nagios

        3. 源碼安裝apache

           httpd-2.2.3/

            ./configure --prefix=/usr/local/apache --enable-modules=so --enable-rewrite

           make && make install

      4.源碼安裝PHP  

         cd ../php-5.2.2

          ./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/lib --with-gd --with-zlib --enable-track-vars --with-xml

   make && make install

 5. 將apache運行用戶加入nagios組(讓apache對nagios有寫權(quán)限,啟動web修改功能)


二。開始正式安裝主程序

     tar zxvf nagios-3.2.3.tar.gz

cd nagios-3.2.3

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

     make all

     make install

執(zhí)行完這個步驟后,程序會提示依次運行make install-init ,make install-commandmode,make install-config 這幾個命令。

           make install-init

          make install-commandmode

           make install-config

       make install-webconf

          接下來安裝插件nagios-plugins-1.4.15.tar.gz 主要為nagios提供各種腳本來監(jiān)控主機。

                       tar zxvf  nagios-plugins-1.4.15.tar.gz

                      cd nagios-plugins-1.4.15

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

                        make && make install

               添加網(wǎng)頁訪問的管理員賬號

/usr/local/apache/htpasswd -c /usr/local/nagios/etc/htpasswd nagiosadmin

             這里會設(shè)置密碼,要記住。

三。 APACHE的配置修改

     打開APACHE的配置文件 /etc/httpd/conf/httpd.conf (yum安裝的httpd路徑,如果為源代碼安裝 則是源代碼安裝的路徑)

   在末尾添加如下信息

#setting for nagios

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 Access"

   AuthType Basic

AuthUserFile /usr/local/nagios/etc/htpasswd  //這里路徑會根據(jù)nagios版本不同有所差異

   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  //這里路徑會根據(jù)nagios版本不同有所差異

   Require valid-user

</Directory>


如果你的httpd是初次安裝,則還需要修改以下幾項

ServerName 127.0.0.1:80

DirectoryIndex index.html index.php

AddType application/x-httpd-php .php .phtml
AddType applicatoin/x-httpd-php-source .phps



四。啟動nagios前的最后準備

1.

檢查配置文件是否正確

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

2.開啟服務(wù)

service httpd start

chkconfig --add  nagios

chkconfig nagios on

service nagios   start

3.關(guān)閉防火墻

services iptables stop

4.這樣就能登錄上去了。但是如果還不能看,可能是因為開啟了SElinux

輸入如下命令

chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin/
chcon -R -t httpd_sys_content_t /usr/local/nagios/share/

這樣一個監(jiān)控端的nagios就起來了

但是他還沒有進行任何配置,所以還無法監(jiān)控其他主機。

具體配置我下期再寫吧- -



向AI問一下細節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI