搭建nagios+centreon分散式

Michael_DD發表於2014-08-11

 搭建nagios+centreon分散式




1   測試server端保持不變,增加了一臺代理伺服器及客戶端節點。


server172.25.128.35        

proxy172.25.128.40  (節點)

 clienttest

#拷貝前面實驗的nagios客戶端程式,修改allowed_hosts192.168.128.39

 

2  proxy  (直接從server拷貝)

 2.修改

安裝服務,需要安裝nagiosnagios-pluginsnrpendoutils,安裝過程與server端完全一樣。

安裝完後後從server端拷貝一個指令碼檔案到proxy

[root@centreon libexec]#scp process-service-perfdata 192.168.128.39:/usr/local/nagios/libexec/

啟動服務:

[root@localhost ~]#/etc/init.d/nagios start

[root@localhost ~]#/etc/init.d/ndo2db start

[root@localhost ~]#/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d

 

server端與proxynagios使用者間建立ssh互信,因為server端通過web新增完配置之後,需要通過ssh將配置傳送到proxy端。

[root@centreon ~]# su nagios

[nagios@centreon root]$cd

[nagios@centreon ~]$ ssh-keygen

[nagios@centreon ~]$ ssh-copy-id -i ~/.ssh/id_rsa.pub 192.168.128.39

[nagios@centreon ~]$ ssh 192.168.128.39    #測試無密碼登陸

 

4  web頁面配置

1  新增poller,配置-Centreon -》增加(可以複製Central再修改)

Poller Nameidc_bj

輸出填寫proxyIP


2  新增pollerndomod.cfg檔案,配置-Centreon-ndomod.cfg -》增加

例項名稱:idc_bj

輸出填寫serverIP192.168.128.21



  

3  新增pollerndomod.cfg檔案,配置-Centreon-ndo2db.cfg -》增加




修改資料庫選項:使用者名稱和密碼是給proxy開通的使用者,需在mysql中授權





 4)新增poller的nagios.cfg檔案




4  新增proxyserver端資料庫訪問許可權

mysql> grant all privileges ON centstatus.* to centreon@'129.168.128.39' identified by 'centreon';

mysql> flush privileges;

5  proxy伺服器新增nagios使用者相關命令的sudo許可權

[root@localhost ~]# vi  /etc/sudoers

nagios   ALL=NOPASSWD: /etc/init.d/nagios restart

nagios   ALL=NOPASSWD: /etc/init.d/nagios stop

nagios   ALL=NOPASSWD: /etc/init.d/nagios start

nagios   ALL=NOPASSWD: /etc/init.d/nagios reload

nagios   ALL=NOPASSWD: /usr/sbin/nagiostats

nagios  ALL=NOPASSWD: /usr/sbin/nagios *

 

修改完成後可以在servernagios使用者下執行ssh sudo 命令:

[nagios@centreon ~]$ ssh 192.168.128.39 sudo /etc/init.d/nagios restart

 

如果報以下錯:

sudo: sorry, you must have a tty to run sudo

解決方法:註釋/etc/sudoers Defaults requiretty

6  新增proxy後端主機:配置-》主機-》新增

與以前的新增主機過程一樣,“監控自”選擇idc_bj





儲存後自動生成服務



匯出nagios配置後檢視監控頁面





如果app節點為非執行狀態,可以嘗試如下方法:

/usr/local/nagios/etc  下的配置檔案web端重啟後無法更新。


因為是原來的配置檔案,所以把原來的配置檔案刪除一次既可。
[root@nagios_app1]# cd /usr/loca/nagios/etc
[root@nagios_app1 etc]# ll
total 168
-rw-r--r-- 1 centreon centreon  1806 Jun  4 14:42 centreon.conf
-rw-rw-r-- 1 nagios   nagios    1827 Jun  4 14:42 cgi.cfg
-rwxrwxr-x 1 nagios   nagios    1825 Jun  2 19:05 cgi.cfg~
-rw-rw-r-- 1 apache   apache   11357 Jun  4 09:49 checkcommands.cfg
-rw-rw-r-- 1 apache   apache    1089 Jun  4 09:49 connectors.cfg
-rw-rw-r-- 1 apache   apache    1383 Jun  4 09:49 contactgroups.cfg
-rw-rw-r-- 1 apache   apache    2744 Jun  4 09:49 contacts.cfg
-rw-rw-r-- 1 apache   apache    1509 Jun  4 09:49 contactTemplates.cfg
-rw-rw-r-- 1 apache   apache    1089 Jun  4 09:49 dependencies.cfg
-rw-rw-r-- 1 apache   apache    1089 Jun  4 09:49 escalations.cfg
-rw-rw-r-- 1 apache   apache    1211 Jun  4 09:49 hostgroups.cfg
-rw-rw-r-- 1 apache   apache    1575 Jun  4 09:49 hosts.cfg
-rw-rw-r-- 1 apache   apache    2949 Jun  4 09:49 hostTemplates.cfg
-rw-r--r-- 1 root     root        26 Jun  3 14:32 htpasswd.users
-rw-rw-r-- 1 apache   apache    1573 Jun  4 09:49 meta_commands.cfg
-rw-rw-r-- 1 apache   apache    1089 Jun  4 09:49 meta_contact.cfg
-rw-rw-r-- 1 apache   apache    1089 Jun  4 09:49 meta_contactgroup.cfg
-rw-rw-r-- 1 apache   apache    1089 Jun  4 09:49 meta_dependencies.cfg
-rw-rw-r-- 1 apache   apache    1089 Jun  4 09:49 meta_escalations.cfg
-rw-rw-r-- 1 apache   apache    1089 Jun  4 09:49 meta_host.cfg
-rw-rw-r-- 1 apache   apache    1089 Jun  4 09:49 meta_hostgroup.cfg
-rw-rw-r-- 1 apache   apache    1089 Jun  4 09:49 meta_services.cfg
-rw-rw-r-- 1 apache   apache    1341 Jun  4 09:49 meta_timeperiod.cfg
-rw-rw-r-- 1 apache   apache    3779 Jun  4 09:49 misccommands.cfg
-rw-rw-r-- 1 nagios   nagios    3718 Jun  4 14:42 nagios.cfg
-rwxrwxr-x 1 nagios   nagios    4146 Jun  2 19:05 nagios.cfg~
-rw-rw-r-- 1 centreon centreon  3019 Jun  4 14:42 nagiosCFG.DEBUG
-rw-rw-r-- 1 apache   apache    1448 Jun  4 09:49 ndo2db.cfg
-rw-rw-r-- 1 apache   apache    1351 Jun  4 09:49 ndomod.cfg
-rw-r--r-- 1 nagios   nagios    8002 Jun  3 23:04 nrpe.cfg
drwxrwxr-x 2 nagios   nagios    4096 Jun  2 19:07 objects
-rw-rw---- 1 nagios   nagios    1158 Jun  4 14:42 resource.cfg
-rwxrwxr-x 1 nagios   nagios    1158 Jun  2 19:05 resource.cfg~
-rw-rw-r-- 1 apache   apache    1089 Jun  4 09:49 servicegroups.cfg
-rw-rw-r-- 1 apache   apache    2271 Jun  4 09:49 services.cfg
-rw-rw-r-- 1 apache   apache    5799 Jun  4 09:49 serviceTemplates.cfg
-rw-rw-r-- 1 apache   apache    2138 Jun  4 09:49 timeperiods.cfg
[root@nagios_app1 etc]# rm -rf *.cfg

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29500582/viewspace-1249197/,如需轉載,請註明出處,否則將追究法律責任。

相關文章