天天看點

Nagios 監控平台快速安裝

Nagios是一款開源的免費網絡監視工具,能有效監控Windows、Linux和Unix的主機狀态,交換機路由器等網絡設定,列印機等。

一、首先安裝apache:

安裝apache,采用yum方式安裝,安裝的指令是yum install –y httpd  

安裝完apache後,啟動apache指令/etc/init.d/httpd restart 即可! 

二、安裝php:

Nagios是基于php語音編寫的程式,是以需要安裝php,也采用yum方式安裝  

Yum install php php-devel -y即可 

三、下載下傳nagios:

現在nagios版本和用戶端插件位址如下:  

wget http://sourceforge.net/projects/nagios/files/nagios-3.x/nagios-3.2.1/nagios-3.2.1.tar.gz/download  

wget http://sourceforge.net/projects/nagiosplug/files/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz/download   

wget  http://jaist.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.13/nrpe-2.13.tar.gz   

建立使用者維護Nagios的使用者群組  

useradd nagios  

passwd nagios 

四、在伺服器端,安裝Nagios和nrpe、nagios插件:

安裝Nagios  

tar zxvf nagios-3.2.1.tar.gz  

cd nagios-3.2.1  

./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios  

make all  

make install                   //來安裝主程式,CGI和HTML檔案  

make install-init              //在/etc/rc.d/init.d安裝啟動腳本  

make install-config            //來安裝示例配置檔案,安裝的路徑是/usr/local/nagios/etc  

make install-commandmode//來配置目錄權限   

make install-webconf     寫入配置檔案  

安裝Nagios-plugins  

tar zxvf nagios-plugins-1.4.15.tar.gz  

cd nagios-plugins-1.4.15  

make && make install  

安裝nrpe   

tar -xzf nrpe-2.13.tar.gz && cd nrpe-2.13 &&./configure --enable-ssl --with-ssl-lib &&make all && make install-plugin && make install-daemon && make install-daemon-config  

chown  -R nagios:nagios /usr/local/nagios/   

/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d  啟動nrpe服務 

五、建立web 通路使用者:

增加通路控制驗證使用者:(第一次建立時要加參數c)  

htpasswd -c /usr/local/nagios/etc/htpasswd.users  nagiosadmin  

nagios安裝完畢,然後重新開機apache,重新開機nagios,/etc/init.d/nagios restart  

通路:http://localhost/nagios/ 即可! 即可通路到nagios最初安裝界面 

六、在用戶端安裝nrpe、nagios-plugin:

首先下載下傳nagios-plugins-1.4.15.tar.gz和nrpe-2.13.tar.gz,  

執行如下腳本即可:  

#!/bin/sh  

###auto make install nagios_plugin and nrpe  

tar -xzf nagios-plugins-1.4.15.tar.gz &&cd nagios-plugins-1.4.15 &&./configure --prefix=/usr/local/nagios &&make &&make install  

sleep 2  

echo "This is make install nrpe ,please waiting .................."  

cd ../ ; tar -xzf nrpe-2.13.tar.gz && cd nrpe-2.13 &&./configure --enable-ssl --with-ssl-lib &&make all && make install-plugin && make install-daemon && make install-daemon-config  

chown  -R nagios:nagios /usr/local/nagios/  

cd .. ;cp nrpe.cfg /usr/local/nagios/etc/nrpe.cfg  

/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d  

###Add auto start  

grep "nrpe" /etc/rc.local  

if [ $? -ne 0 ];then  

echo "/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d" >>/etc/rc.local  

else  

echo "nrpe is exist"  

fi  

儲存即可! 

本文轉自 wgkgood 51CTO部落格,原文連結:http://blog.51cto.com/wgkgood/778692