系統(tǒng)環(huán)境:CentOS 6.3
成都創(chuàng)新互聯(lián)主要從事網(wǎng)站設(shè)計制作、成都網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)云岡,10多年網(wǎng)站建設(shè)經(jīng)驗,價格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):18982081108
本文檔描述了如何安裝Nagios程序和Nagios插件
1、安裝前準(zhǔn)備
Nagios安裝前,首先安裝相關(guān)主件,對于RHEL / CentOS系統(tǒng): (依賴包的安裝,其中httpd是為了是nagiox通過web界面顯示出來)
[root@server ~]#yum install -y wget httpd php gcc glibc glibc-common gd gd-devel make net-snmp
下載Nagios程序和Nagios插件
[root@server ~]#wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.4.1.tar.gz
[root@server ~]#wget http://sourceforge.net/projects/nagiosplug/files/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz
2、添加Nagios用戶和組
[root@server ~]#useradd nagios
[root@server ~]#groupadd nagcmd
[root@server ~]#usermod -a -G nagcmd nagios
3、Nagios 安裝
[root@server ~]#tar zxvf nagios-3.4.1.tar.gz
[root@server ~]#cd nagios
[root@server nagios]#./configure --with-command-group=nagcmd
[root@server nagios]#make all
[root@server nagios]#make install
[root@server nagios]#make install-init
[root@server nagios]#make install-config
[root@server nagios]#make install-commandmode
[root@server nagios]#make install-webconf
復(fù)制nagios/contrib/eventhandlers目錄下所有文件到/usr/local/nagios/libexec下:
[root@server nagios]#cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
修改用戶和主權(quán)限
[root@server nagios]#chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers
[root@server nagios]# ll /usr/local/nagios/libexec/eventhandlers/
總用量 28
-rwxr-xr-x. 1 nagios nagios 828 9月 27 11:33 disable_active_service_checks
-rwxr-xr-x. 1 nagios nagios 759 9月 27 11:33 disable_notifications
drwxr-xr-x. 2 nagios nagios 4096 9月 27 11:33 distributed-monitoring
-rwxr-xr-x. 1 nagios nagios 827 9月 27 11:33 enable_active_service_checks
-rwxr-xr-x. 1 nagios nagios 760 9月 27 11:33 enable_notifications
drwxr-xr-x. 2 nagios nagios 4096 9月 27 11:33 redundancy-scenario1
-rwxr-xr-x. 1 nagios nagios 1184 9月 27 11:33 submit_check_result
校驗Nagios配置文件,驗證配置是否有誤
[root@server nagios]#/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
重啟nagios、httpd
[root@server nagios]#/etc/init.d/nagios start
[root@server nagios]#/etc/init.d/httpd start
修改配置文件
[root@server nagios]#vim /usr/local/nagios/etc/objects/contacts.cfg
修改nagiosadmin(這里修改為你自己創(chuàng)建的帳號) 注:nagiosadmin是配置文件默認(rèn),可以不用修改。
創(chuàng)建一個默認(rèn)用戶登錄Web界面訪問: 創(chuàng)建HTTP認(rèn)證用戶登錄Nagios,用戶名nagiosadmin,密碼123456
[root@server nagios]#htpasswd –c /usr/local/nagios/etc/htpasswd.users nagiosadmin
4、Nagios插件安裝
[root@server ~]#tar zxvf nagios-plugins-1.4.15.tar.gz
[root@server ~]#cd /nagios-plugins-1.4.15
[root@server nagios-plugins-1.4.16]#./configure --with-nagios-user=nagios --with-nagios-group=nagios
[root@server nagios-plugins-1.4.16]#make
[root@server nagios-plugins-1.4.16]#make install
5、Nagios服務(wù)設(shè)置
以下命令將寄存器Nagios守護(hù)進(jìn)程運(yùn)行在系統(tǒng)啟動。
[root@server ~]#chkconfig --add nagios
[root@server ~]#chkconfig --add httpd
[root@server ~]#chkconfig nagios on
[root@server ~]#chkconfig httpd on
6、登錄到WEB界面
輸入用戶名密碼:nagiosadmin 123456
http://localhost/nagios
7、FQA
如果WEB無法訪問,檢查一下IPtables是否關(guān)閉。
[root@server ~]# service iptables status