Centos 6.2 nagios監控服務器集羣 系列之安裝篇

      回想當年,不知道如何安裝nagios,不知道如何監控windows,不知道如何監控網絡設備(linux),網上的教程一車一車的....最終,我如今能夠進行服務器監控,而且配置了pnp,道路艱辛,爲各位同僚拋磚引玉了.... php

       安裝:我用的系統是Centos,因此全部步驟都基於此係統,其餘的沒有嘗試過.... linux

       

      安裝相關編譯環境: ios

yum install httpd
yum install gcc
yum install glibc glibc-common
yum install gd gd-devel
yum install php(此爲圖形化界面必須)

建立用戶: web

/usr/sbin/useradd nagios
設置密碼:
passwd nagios
此處設爲nagiospasswd
建立一個用戶組名爲nagcmd用於從Web接口執行外部命令。將nagios用戶和apache用戶都加到這個組中。(此處網上參考均如此,保險起見,不作修改)
/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -G nagcmd nagios
/usr/sbin/usermod -G nagcmd apache

 

建立文件夾: shell

mkdir download apache

cd download windows

下載相關軟件:


nagios-3.3.1.tar.gz以及nagios-plugins-1.4.15.tar.gz 服務器

下載地址官網就有最新的,找不到留言給我... 網絡

tar xzf nagios-3.3.1.tar.gz
./configure --with-command-group=nagcmd
 
make all


make install
make install-init
make install-config
make install-commandmod


vi /usr/local/nagios/etc/objects/contacts.cfg


make install-webconf
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin


建立密碼和用戶
設置密碼爲nagiospasswd
下面編譯安裝插件


cd ..
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install


chkconfig --add nagios
chkconfig nagios on


驗證Nagios的樣例配置文件
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

service nagios start


更改SELinux設置
setenforce 0


若是想發送郵件還要啓動郵件服務:


service sendmail start

此處還要修改http.conf 增長index.php

如今咱們再配置一下才能夠收到郵件 this


cd /usr/local/nagios/etc/objects/

localhost.cfg

將notifications_enabled 設爲1

重啓nagios


service nagios restart


我在安裝的時候報錯:

 tail nagios.log

 Error: Could not create external command file '/usr/local/nagios/var/rw/nagios.c
md' as named pipe: (2) -> No such file or directory.  If this file already exists and you are

進入/usr/local/nagios/var目錄,原來沒有rw目錄,啓動nagios沒法寫入文件,

手動解決吧:


#mkdir rw

#chown -R nagios.nagios rw/

#chmod 777 -R rw/  給入全局權限

#service nagios start



至此,nagios初步安裝成功,能夠監控本機了,記得把80端口看看,若是你不想麻煩,直接service iptables stop 而後經過訪問你服務器的ip地址/nagios便可訪問,輸入帳號密碼 nagiosadmin/nagiospasswd便可


若文中有任何不妥或者錯誤之處,請不吝zhichu

相關文章
相關標籤/搜索