1、基礎支援套件:
rpm -qa gcc glibc glibc-common gd gd-devel xinetd openssl-devel
[root@node1 ~]# rpm -qa gcc glibc glibc-common gd gd-devel xinetd openssl-devel
glibc-common-2.12-1.132.el6.x86_64
glibc-2.12-1.132.el6.x86_64
yum install -y gcc glibc glibc-common gd gd-devel xinetd openssl-devel
2 建立nagios使用者和使用者組
useradd -s /sbin/nologin nagios
mkdir /usr/local/nagios
chown -r nagios.nagios /usr/local/nagios
檢視nagios 目錄的許可權
[root@node1 ~]# ll -d /usr/local/nagios/
drwxr-xr-x 2 nagios nagios 4096 nov 23 06:34 /usr/local/nagios/
3 編譯安裝nagios
wget
tar zxvf nagios-3.4.3.tar.gz
cd nagios
./configure --prefix=/usr/local/nagios
make all
make install
make install-init
make install-commandmode
make install-config
chkconfig --add nagios
chkconfig --level 35 nagios on
chkconfig --list nagios
4 驗證程式是否被正確安裝
切換目錄到安裝路徑(這裡是/usr/local/nagios),看是否存在etc、bin、sbin、share、var 這五個目錄,如果存在則可以表明程式被正確的安裝到系統了。nagios 各個目錄用途說明如下:
binnagios 可執行程式所在目錄
etcnagios 配置檔案所在目錄
sbin
nagios cgi 檔案所在目錄,也就是執行外部命令所需檔案所在的目錄
share
nagios網頁檔案所在的目錄
libexec
nagios 外部外掛程式所在目錄
varnagios 日誌檔案、lock 等檔案所在的目錄
var/archives
nagios 日誌自動歸檔目錄
var/rw
用來存放外部命令檔案的目錄
5 安裝nagios 外掛程式
wget
tar zxvf nagios-plugins-1.4.16.tar.gz
cd nagios-plugins-1.4.16
./configure --prefix=/usr/local/nagios
make && make install
6 安裝與配置apache和php
apache 和php 不是安裝nagios 所必須的,但是nagios提供了web監控介面,通過web監控介面可以清晰的看到被監控主機、資源的執行狀態,因此,安裝乙個web服務是很必要的。
a. 安裝apache
若出現錯誤:
則在編譯時入加 --with-included-apr 即可解決。
b. 安裝php
wget
tar zxvf php-5.4.10.tar.gz
cd php-5.4.10
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs
遇到這個報錯configure: error: xml2-config not found. please check your libxml2 installatio
需要yum install libxml2*
make && make install
c. 配置apache
找到apache 的配置檔案/usr/local/apache2/conf/httpd.conf
找到:user daemon
group daemon
修改為
user nagios
group nagios
然後找到
directoryindex index.html
修改為
directoryindex index.html index.php
接著增加如下內容:
為了安全起見,一般情況下要讓nagios 的web 監控頁面必須經過授權才能訪問,這需要增加驗證配置,即在httpd.conf 檔案最後新增如下資訊:
#setting for nagios
scriptalias /nagios/cgi-bin "/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
alias /nagios "/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
d. 建立apache目錄驗證檔案
在上面的配置中,指定了目錄驗證檔案htpasswd,下面要建立這個檔案:
/usr/local/apache2/bin/htpasswd -c /usr/local/nagios/etc/htpasswd wolf
這樣就在/usr/local/nagios/etc 目錄下建立了乙個htpasswd 驗證檔案,當通過 訪問時就需要輸入使用者名稱和密碼了。
e. 檢視認證檔案的內容
# cat /usr/local/nagios/etc/htpasswd
f. 啟動apache 服務
# /usr/local/apache2/bin/apachectl start
報錯1:
addtype requires at least two arguments, a mime type followed by one or more file extensions
安裝完apache伺服器後,啟動不了
開啟http.conf 進行檢查發現了這麼一行:
到這裡nagios 的安裝也就基本完成了,你可以通過web來訪問了
報錯2:
原因:這個問題應該是沒有在 /etc/httpd/conf/httpd.conf 中設定 servername。所以apache會用主機上的名稱來取代,首先會去找 /etc/hosts 中有沒有主機的定義。
解決辦法:
(1)可以設定httpd.conf檔案中的 servername,如下:servername localhost:80
(2)在 /etc/hosts 中填入自己的主機名稱 bogon,如下:127.0.0.1 shiwei (使用者名稱)
下面就可以通過訪問
nagios安裝教程
nagios伺服器安裝 監控端 一 準備工作 安裝nagios伺服器用到的安裝包包括 nagios 3.2.3.tar.gz nagios plugins 1.4.15.tar.gz nrpe 2.12.tar.gz 當然要想方便的使用nagios還要有apache服務,安裝包為 httpd 2.2...
nagios安裝文件
1,nagios安裝 安裝環境nagios依賴的環境 yum y install gcc yum y install glibc glibc common yum y install gd gd devel 解壓並安裝 cd opt soft tar xf nagios 3.4.1.tar.gz o...
nagios一鍵安裝指令碼
nagios具有非常強大的報警功能。還可以結合pnp實現時時繪製圖形。可以根據自己的需求定義 nagios的腳控型別,可以說監控服務,nagios已經做到了無所不能 下面給出nagios的安裝腳步。後期會慢慢更新如何編寫腳步定義企業nagios監控系統 腳步的安裝包是已經放到 usr local s...