CentOS環(huán)境Nagios的安裝與配置
CentOS環(huán)境Nagios的安裝與配置其實(shí)挺簡(jiǎn)單,來(lái)隨我看看!
在上文中講到有關(guān)cacti的安裝與配置,它在網(wǎng)絡(luò)流量性能監(jiān)控以及圖表繪制等方面非常的強(qiáng)大。但是服務(wù)器和服務(wù)本身狀態(tài)的監(jiān)控以及錯(cuò)誤報(bào)警機(jī)制,則需要本文介紹的Nagios神器來(lái)實(shí)現(xiàn)。Nagios的功能是監(jiān)控服務(wù)和主機(jī),根據(jù)配置在服務(wù)器異常的時(shí)候提供報(bào)警功能,并提供友好的WEB界面查看當(dāng)前的網(wǎng)絡(luò)狀態(tài)、通知和故障歷史、日志文件……但是他自身并不包括這部分功能的代碼,所有的監(jiān)控、檢測(cè)功能都是有插件來(lái)完成的。
一、安裝環(huán)境:CentOS5.4 + Apache2 + PHP5.2,請(qǐng)確保已安裝PHP+Apache,可參看本博有關(guān)Apache與PHP的安裝教程;
二、創(chuàng)建Nagios用戶及用戶組,命令如下:
#useradd -m nagios
--創(chuàng)建nagcmd組用來(lái)運(yùn)行通過(guò)web接口傳輸過(guò)來(lái)的命令,同時(shí)添加nagios和apache
- #groupadd nagcmd
- #usermod -a -G nagcmd nagios
- #usermod -a -G nagcmd apache
#p#
三、下載安裝Nagios及Nagios插件,過(guò)程如下:
——下載Nagios
#wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.1.tar.gz
——下載Nagios插件
#wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.14.tar.gz
——解壓Nagios
#tar -zvxf nagios-3.2.1.tar.gz
#cd nagios-3.2.1
——編譯
#./configure --with-command-group=nagcmd #make all
——安裝Nagios,初始化腳本及配置文件,Nagios將會(huì)被安裝至/usr/local/nagios #make install #make install-init #make install-config #make install-commandmode
——安裝WEB界面,界面將會(huì)安裝到 /usr/local/nagios/share ( http 配置文件默認(rèn)添加到 /etc/httpd/conf.d/nagios.conf,如果沒(méi)有則執(zhí)行:#cp sample-config/httpd.conf /etc/apache2/conf.d/nagios.conf )
#make install-webconf
——創(chuàng)建HTTP認(rèn)證用戶登錄Nagios,用戶名nagiosadmin,密碼123456
#htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
——重啟apache
#service httpd restart
——安裝Nagios插件
#tar -zvxf nagios-plugins-1.4.14.tar.gz
#cd nagios-plugins-1.4.14
#./configure --with-nagios-user=nagios --with-nagios-group=nagios #make && make install
——配置Nagios管理員接受告警信息的郵箱,寫(xiě)入管理員郵箱 #vim /usr/local/nagios/etc/objects/contacts.cfg email admin@admin.com ; ——校驗(yàn)Nagios配置文件,驗(yàn)證配置是否有誤 #/usr/local/nagios/bin/nagios -v
——啟動(dòng)Nagios,配置在系統(tǒng)啟動(dòng)時(shí)運(yùn)行Nagios
- #chkconfig --add nagios
- #chkconfig nagios on
- #chkconfig httpd on
——運(yùn)行Nagios
#service nagios start
#p#
四、登陸到Web界面,輸入用戶名密碼:nagiosadmin 123456,http://localhost/nagios/
五、錯(cuò)誤處理
1、本機(jī)監(jiān)控HTTP SSH的Notifications顯示警告錯(cuò)誤,解決方法:
#vim /usr/local/nagios/etc/objects/localhost.cfg
define service{
use local-service ; Name of service template to use
host_name localhost
service_description SSH
check_command check_ssh
notifications_enabled 1 #改為1,即可
}
# Define a service to check HTTP on the local machine.
# Disable notifications for this service by default, as not all users may have HTTP enabled.
define service{
use local-service ; Name of service template to use
host_name localhost
service_description HTTP
check_command check_http
notifications_enabled 1 #改為1,即可
}
2、Nagios顯示類(lèi)似錯(cuò)誤:HTTP WARNING: HTTP/1.1 403 Forbidden - 5240 bytes in 0.002 second response time。
該錯(cuò)誤表明在apache web根目錄沒(méi)有index.html文件。解決方法:在web根目錄(如:/var/www/html/目錄)建立index.html文件,重啟apache和nagios即可。
通過(guò)文章我們清楚的知道了CentOS環(huán)境Nagios的安裝與配置的詳細(xì)過(guò)程!
【編輯推薦】