1,nagios安裝
下載下傳的nagios版本為:nagios-3.4.1.tar.gz
安裝環境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
# /opt/soft/nagios
添加nagios使用者:
# useradd nagios
對安裝進行配置:
# ./configure --prefix=/opt/nagios --with-gd-lib=/usr/local/lib --with-gd-inc=/usr/local/include
編譯:
# make all
安裝主程式,CGI以及HTML網頁等:
# make install
在/etc/rc.d/init.d/目錄中安裝啟動腳本:
# make install-init
安裝和配置外部指令對Nagios主路徑操作的權限(這裡所謂的外部指令主要是指Apache服務通過CGI來對Nagios的進行的操作。使用者将通過Web以執行CGI程式腳本的方式來對Nagios的檢測結果進行讀取和調用):
# make install-commandmode
在/usr/local/etc/這個Nagios編譯安裝的主配置路徑下安裝示例配置模闆
# make install-config
2,安裝nagios插件
# tar xzf nagios-plugins-1.4.15.tar.gz
# cd nagios-plugins-1.4.15
# ./configure --prefix=/opt/nagios --enable-redhat-pthread-workaround && make all && make install && chown -R nagios.nagios /opt/nagios/
(在redhat系統上面安裝可能出現configure時,到這裡checking for redhat spopen problem...就不動了,是以需要在configure時再加上這個 --enable-redhat-pthread-workaround
檢視nagios的插件是否正常安裝:
# ls /opt/nagios/libexec
3,編譯安裝nrpe:
由于server端會使用check_nrpe,建議在本機編譯生成cherk_nrpe,拷貝其他機器生成的可能導緻無法使用
# tar xzf nrpe-2.13.tar.gz
# nrpe-2.13
# ./configure --enable-ssl --enable-command-args --prefix=/opt/nagios/
安裝check_nrpe 這個插件
# make install-plugin
安裝deamon
# make install-daemon
安裝nrpe配置檔案
# make install-daemon-config
4,安裝apache服務并配置:
# yum -y install httpd
# cd /etc/httpd/conf
# vim httpd.conf
添加如下内容:
設定Nagios的CGI執行目錄對應的系統路徑和網頁URL對應的系統路徑,并進行通路控制:
ScriptAlias /nagios/cgi-bin/ "/opt/nagios/sbin/"
<Directory "/opt/nagios/sbin/">
AllowOverride None
Options None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /opt/nagios/etc/htpasswd
Require valid-user
</Directory>
Alias /nagios "/opt/nagios/share/"
<Directory "/opt/nagios/share/">
建立mops使用者并設定密碼為"SoHu&*":
# htpasswd -c /opt/nagios/etc/htpasswd mops
# sed -i 's/nagiosadmin/mops/g' /opt/nagios/etc/cgi.cfg
讓Apache有适當的權限能夠通過CGI腳本程式對Nagios進行調用,否則Apache将沒有權限調用Nagios,使用者通過Web将無法通路Nagios處理的所有資訊:
# usermod -G nagios apache
使apache支援對php頁面的支援
首先要确認自己安裝了php(如果是用yum install php指令安裝的php,則隻需修改A即可)
# vim /etc/httpd/conf/httpd.conf
修改如下:
A、修改檔案/etc/httpd/conf/httpd.conf添加預設檔案
DirectoryIndex index.html index.htm index.php
B、加載支援php5的子產品
LoadModule php5_module modules/libphp5.so
C、添加php識别
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
5,nagios的啟動
檢查其主配置檔案的文法是否正确:
# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
如果上面的文法檢查沒有問題,接下來就可以正式啟動nagios服務了:
# service nagios start
6,啟動httpd,我們就可以通過url通路:
# service httpd start
http://10.13.82.231/nagios/
輸入使用者名和密碼即可登入nagios
本文轉自 leejia1989 51CTO部落格,原文連結:http://blog.51cto.com/leejia/1198031,如需轉載請自行聯系原作者