cacti+nagios 之cacti整合nagios(四)
一、原理
整合cacti和nagios是利用了cacti的一個外掛nagios for cacti;它的原理是將nagios的資料透過ndo2db匯入到mysql資料庫(cacti)的庫中;然後cacti讀取資料庫資訊將nagios展現出來;
一、安裝cacti擴充套件模組
Cacti擴充套件模組需要下載安裝cacti-plugin,cacti-0.8.8a及以後版本已經整合不需要安裝(但是我使用的0.8.8b還需要安裝很鬱悶,如果使用的是老版本cacti,擴充套件模組安裝如下:
Cd /root/cactinagios
Wget
Mv cacti-plugin-0.8.7h-PA-v3.0.tar.gz cacti-plugin-arch.tar.gz
Tar -xf cacti-plugin-arch.tar.gz
Cp cacti-plugin-arch/* /var/www/html/cacti/
Cd /var/www/html/cacti/
Mysql -u cacti –p ‘cacti’
cacti
Patch -p1 –N
安裝Ndoutils
cd /root/cactinagios
wget tar zxvf ndoutils-2.0.0.tar.gz
cd ndoutils-2.0.0
./configure –prefix=/var/www/html/nagios/ –with-mysql-inc=/usr/include/mysql –with-mysql-lib=/usr/lib64/mysql –enable-mysql –disable-pgsql –with-ndo2db-user=nagios –with-ndo2db-group=nagios
make
2、準備配置檔案
cd db
./installdb -u cactier -p 123456 -h localhost -d cactidb
cd ..
[root@nagios ndoutils-2.0.0]# cp src/{ndomod-4x.o,ndo2db-4x,log2ndo,file2sock} /usr/local/nagios/bin
#nagios是4.x版本的就使用ndomod-4x.o和ndo2db-4x,如果是3.x版本就複製對應的3x檔案
[root@nagios ndoutils-2.0.0]# cp config/ndomod.cfg-sample /var/www/html/nagios/etc/ndomod.cfg
[root@nagios ndoutils-2.0.0]# cp config/ndo2db.cfg-sample /var/www/html/nagios/etc/ndo2db.cfg
[root@nagios ndoutils-2.0.0]# cd /var/www/html/nagios/etc/
[root@nagios etc]# chown nagios:nagios ndo2db.cfg ndomod.cfg
[root@nagios etc]# chmod 664 ndo2db.cfg ndomod.cfg
[root@nagios etc]# cd /var/www/html/nagios/bin
[root@nagios bin]# mv ndo2db-4x ndo2db
[root@nagios bin]# mv ndomod-4x.o ndomod.o
[root@nagios bin]# chown nagios:nagios *
3、修改配置檔案
[root@nagios bin]# vi /usr/local/nagios/etc/nagios.cfg
#注意,broker_module和config_file放在一行 broker_module=/var/www/html/nagios/bin/ndomod.o config_file=/var/www/html/nagios/etc/ndomod.cfgevent_broker_options=-1
process_performance_data=1
[root@nagios bin]# vi /var/www/html/nagios/etc/ndo2db.cfg
socket_type=tcp
db_servertype=mysql
db_host=localhost
db_port=3306
db_name=cactidb
db_prefix=npc_
db_user=cactier
db_pass=123456
[root@nagios bin]# vi /var/www/html/nagios/etc/ndomod.cfg
output_type=tcpsocket
output=127.0.0.1
4、啟動守護程式
[root@nagios bin]# /var/www/html/nagios/bin/ndo2db -c /var/www/html/etc/ndo2db.cfg
[root@nagios bin]# cd /root/cactinagios/ndoutils-2.0.0
[root@nagios ndoutils-2.0.0]# cp ./daemon-init /etc/init.d/ndo2db
[root@nagios ndoutils-2.0.0]# chmod +x /etc/init.d/ndo2db
[root@nagios ndoutils-2.0.0]# service ndo2db status
[root@nagios ndoutils-2.0.0]# chkconfig –add ndo2db
[root@nagios ndoutils-2.0.0]# chkconfig ndo2db on
四、安裝NPC外掛
介紹:全稱Nagios Plugin for Cacti,將nagios的資料透過ndo2db匯入到mysql資料庫(前面設定的npc_開頭的表),然後cacti讀取資料庫資訊將nagios的結果透過NPC展示出來。
1、安裝npc
[root@nagios ndoutils-2.0.0]# cd /root/cactinagios
[root@nagios nagios]# wget [root@nagios nagios]# tar zxvf npc-2.0.4.tar.gz
[root@nagios nagios]# mv npc /var/www/html/cacti/plugins/
[root@nagios nagios]# vi /var/www/html/cacti/include/config.php
$plugins[] = ‘npc’;
2、頁面設定npc
(1)user management–>admin–>勾上Plugin Management
(2)Plugin Management–>點選install圖示、點選enable圖示
(3)settings–>NPC–>如下所示:
Remote Commands:
/var/www/html/nagios/var/rw/nagios.cmd
http://192.168.10.16/nagios
3、安裝json:支援npc
JSON(JavaScript Object Notation) 是一種輕量級的資料交換格式。易於人閱讀和編寫。同時也易於機器解析和生成。
注意:先執行第4步的php -m檢視是否載入了json,有則跳過3、4步我這裡有;
[root@nagios json-1.2.1]# php -m
修改資料庫:
mysql>use cacti;
mysql>ALTER TABLE npc_eventhandlers ADD long_output TEXT NOT NULL DEFAULT ” AFTER output;
mysql>ALTER TABLE npc_hostchecks ADD long_output TEXT NOT NULL DEFAULT ” AFTER output;
mysql>ALTER TABLE npc_hoststatus ADD long_output TEXT NOT NULL DEFAULT ” AFTER output;
mysql>ALTER TABLE npc_notifications ADD long_output TEXT NOT NULL DEFAULT ” AFTER output;
mysql>ALTER TABLE npc_servicechecks ADD long_output TEXT NOT NULL DEFAULT ” AFTER output;
mysql>ALTER TABLE npc_servicestatus ADD long_output TEXT NOT NULL DEFAULT ” AFTER output;
mysql>ALTER TABLE npc_statehistory ADD long_output TEXT NOT NULL DEFAULT ” AFTER output;
mysql>ALTER TABLE npc_systemcommands ADD long_output TEXT NOT NULL DEFAULT ” AFTER output;
mysql>ALTER TABLE npc_services ADD importance smallint(6) NOT NULL DEFAULT ’0′; mysql>ALTER TABLE npc_hosts ADD importance smallint(6) NOT NULL DEFAULT ’0′;
mysql>ALTER TABLE npc_contacts ADD minimum_importance smallint(6) NOT NULL DEFAULT ’0′;
mysql>quit
6、重啟服務
[root@nagios ~]# service mysqld restart
[root@nagios ~]# service httpd restart
[root@nagios ~]# service ndo2db restart
[root@nagios ~]# service nagios restart
7、觀察日誌
[root@nagios ~]# tail /var/log/html/nagios/var/nagios.log
[root@nagios ~]# tail /var/www/html/cacti/log/cacti.log
[root@nagios ~]# tail /var/log/mysqld.log
[root@nagios ~]# tail /var/log/messages
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/30129545/viewspace-1434568/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- cacti+nagios 之cacti的搭建(-)iOS
- cacti+nagios之cacti的簡單使用(=)iOS
- cacti+nagios之nagios的搭建(三)iOS
- Cacti+Nagios監控平臺完美整合iOS
- cacti+nagios 之cacti外掛安裝monitor和ntop(五)iOS
- Nagios+Cacti監控平臺完美整合部署iOS
- cacti+nagios_巨菜版薦iOS
- Nagios Plugin for Cacti 安裝使用篇(zt)iOSPlugin
- 利用Rpmforge更新centosyum源快速安裝nagios與cactiCentOSiOS
- debian下LAMP+nginx代理+awstats+cacti+nagios(一)LAMPNginxiOS
- linux之cacti使用Linux
- zabbix、cacti、nagios,伺服器監控還有更好的選擇嗎?iOS伺服器
- Cacti的安裝之CentOSCentOS
- CentOS5.5整合cacti+monitor+told+ntop部署CentOS
- Nagios整合pnp繪製效能分析圖表iOS
- 開源監控解決方案nagios+pnp4nagios+nconf+ndoutils整合部署iOS
- Nagios備忘之基本配置iOS
- Nagios備忘之安裝iOS
- SSH整合之四(頁面邏輯的實現)
- 搭建cacti
- linux下cacti的搭建之詳細過程!Linux
- 搭建Cacti監控
- cacti監控mysqlMySql
- cacti安裝備忘
- Cacti的優化優化
- cacti-不出圖形,cacti.log中出“ERROR: SQL Assoc Failed!ErrorSQLAI
- 配置CACTI監控MySQL資料庫狀態(4)配置cactiMySql資料庫
- Vuex之整合Vue
- Spring筆記(四)整合MybatisSpring筆記MyBatis
- nagios 搭建iOS
- ML《整合學習(四)Boosting之迴歸樹、提升樹和GBDT》
- cacti安裝紀實
- cacti監控lighttpdhttpd
- cacti監控tcpconnectionTCP
- cacti批量新增監控
- SSM整合之CRUD環境搭建整合SSM
- 轉載 使用Cacti監控你的網路(二)- Cacti的安裝
- 微服務之整合微服務