First, the principle
integrating cacti and Nagios is a plugin of cacti, nagios for cacti, which works by importing Nagios data through ndo2db into the MySQL database (the cacti library). Then cacti reads the database information and displays the results of Nagios.
Second, cacti expansion module
Cacti extension modules need to download installation Cacti-plugin,cacti-0.8.8a and later versions are integrated this extension does not need to be installed separately, if you are using an older version of cacti, the expansion module is installed as follows:
Cd/root/download
wget http://www.cacti.net/downloads/pia/cacti-plugin-0.8.7h-PA-v3.0.tar.gz
Tar xvf cacti-plugin-0.8.7h-pa-v3.0.tar.gz
Cp-r cacti-plugin-arch/*/var/www/html/cacti/
cd/var/www/html/cacti/
Mysql-u cactier-p 123456 Cactidb < Pa.sql
Patch-p1-n < Cacti-plugin-0.8.7h-pa-v3.0.diff
Vim include/config.php
$url _path = "/cacti/";
Enter cacti from the web, enable cacti plugin extension
Third, install Ndoutils plug-in
1, installation ndoutils
Cd/root/download
wget http://jaist.dl.sourceforge.net/project/nagios/ndoutils-2.x/ndoutils-2.0.0/ndoutils-2.0.0.tar.gz
Tar zxvf ndoutils-2.0.0.tar.gz
CD ndoutils-2.0.0
./configure--prefix=/usr/local/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. Prepare the configuration file
CD DB
./installdb-u cactier-p 123456-h localhost-d cactidb
Cd..
CP Src/{ndomod-4x.o,ndo2db-4x,log2ndo,file2sock}/usr/local/nagios/bin
Nagios is a 4.x version of the NDOMOD-4X.O and ndo2db-4x, if the 3.x version copies the corresponding 3x file
CP Config/ndomod.cfg-sample/usr/local/nagios/etc/ndomod.cfg
CP Config/ndo2db.cfg-sample/usr/local/nagios/etc/ndo2db.cfg
cd/usr/local/nagios/etc/
Chown Nagios:nagios ndo2db.cfg ndomod.cfg
chmod 664 Ndo2db.cfg ndomod.cfg
Cd/usr/local/nagios/bin
MV Ndo2db-4x ndo2db
MV NDOMOD-4X.O NDOMOD.O
Chown Nagios:nagios *
3. Modify the configuration file
vi/usr/local/nagios/etc/nagios.cfg
#注意, Broker_module and config_file on one line
BROKER_MODULE=/USR/LOCAL/NAGIOS/BIN/NDOMOD.O config_file=/usr/local/nagios/etc/ndomod.cfg event_broker_options=- 1
Process_performance_data=1
vi/usr/local/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
vi/usr/local/nagios/etc/ndomod.cfg
Output_type=tcpsocket
output=127.0.0.1
4. Start the daemon process
/usr/local/nagios/bin/ndo2db-c/usr/local/nagios/etc/ndo2db.cfg
cd/root/download/ndoutils-2.0.0
CP./daemon-init/etc/init.d/ndo2db
chmod +x/etc/init.d/ndo2db
Service NDO2DB Status
Chkconfig--add ndo2db
Chkconfig ndo2db on
Iv. Installation of NPC Plugin
Description: The full name Nagios Plugin for Cacti, which imports Nagios data through ndo2db to the MySQL database (the table at the beginning of the previous set of Npc_), and then Cacti reads the database information to show the results of Nagios through NPCs.
1. Install NPC
Cd/root/download
wget http://down.drv5.cn/www.drv5.cn/npc-2.0.4.tar.gz
Tar zxvf npc-2.0.4.tar.gz
MV npc/var/www/html/cacti/plugins/
vi/var/www/html/cacti/include/config.php
$plugins [] = ' NPC ';
2. Page Setup NPC
User management-->admin--> hook up plugin Management
Plugin management--> Click the Install icon, click the Enable icon
Settings-->npc--> settings are as follows
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/42/30/wKioL1PXEz_z_eDtAAA3soVYYoM649.jpg "title=" image (7). PNG "alt=" wkiol1pxez_z_edtaaa3sovyyom649.jpg "/>
3. Install JSON: Support NPC
JSON (JavaScript Object Notation) is a lightweight data interchange format. Easy for people to read and write. It is also easy for machine parsing and generation.
Note: Perform the 4th step of Php-m to see if the JSON is loaded, or skip 3 or 4 steps,
Cd/root/download
wget http://pkgs.fedoraproject.org/repo/pkgs/php-pecl-json/json-1.2.1.tgz/d8904d2f004ceec85eeacf524cd25539/ Json-1.2.1.tgz
Tar zxvf json-1.2.1.tgz
CD json-1.2.1
VI json_parser.c
#define ZVAL_DELREF z_delref_p
phpize
./configure
Make && make install
4. Configure PHP to support JSON
Vi/etc/php.d/json.ini
extension=json.so
Service httpd Restart
See if any JSON is loaded
php-m
See if you have import information
php-i | grep php.ini
5. Modify the database (missing individual fields)
tail/var/log/messages
ndo2db:mysql_error: ' Unknown column ' long_output ' in ' Field List '
mysql-ucactier-p123456
Use CACTIDB;
ALTER TABLE npc_eventhandlers ADD long_output TEXT not NULL DEFAULT "after output;
ALTER TABLE npc_hostchecks ADD long_output TEXT not NULL DEFAULT "after output;
ALTER TABLE npc_hoststatus ADD long_output TEXT not NULL DEFAULT "after output;
ALTER TABLE npc_notifications ADD long_output TEXT not NULL DEFAULT "after output;
ALTER TABLE npc_servicechecks ADD long_output TEXT not NULL DEFAULT "after output;
ALTER TABLE npc_servicestatus ADD long_output TEXT not NULL DEFAULT "after output;
ALTER TABLE npc_statehistory ADD long_output TEXT not NULL DEFAULT "after output;
ALTER TABLE npc_systemcommands ADD long_output TEXT not NULL DEFAULT "after output;
ALTER TABLE npc_services ADD importance smallint (6) Not NULL DEFAULT ' 0 ';
ALTER TABLE npc_hosts ADD importance smallint (6) Not NULL DEFAULT ' 0 ';
ALTER TABLE npc_contacts ADD minimum_importance smallint (6) Not NULL DEFAULT ' 0 ';
quit
6. Restart Service
Service mysqld Restart
Service httpd Restart
Service ndo2db Restart
Service Nagios Restart
7. Observation Log
Tail/usr/local/nagios/var/nagios.log
Tail/var/www/html/cacti/log/cacti.log
Tail/var/log/mysqld.log
Tail/var/log/messages
V. Problems encountered
1,the NPC page shows that Nagios is off
Error:
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/42/31/wKioL1PXFaDC_rpsAAA7_nODoNk432.jpg "title=" image (8). PNG "alt=" wkiol1pxfadc_rpsaaa7_nodonk432.jpg "/>
Tail/usr/local/nagios/var/nagios.log
ndomod:could not Open Data sink! I ' ll keep trying, but the some output may get lost ...
Solve:
cd/usr/local/nagios/etc/
Chown Nagios:nagios ndo2db.cfg ndomod.cfg
chmod 664 Ndo2db.cfg ndomod.cfg
Service ndo2db Restart
Service Nagios Restart
2. NDO2DB Service failed to start
Error:
Could not bind socket:address already on use
Solve:
PS aux|grep ndo2db See multiple ndo2db processes
kill-9 Process ID kill process and run again
sudo/usr/local/nagios/bin/ndo2db-c/usr/local/nagios/etc/ndo2db.cfg
3. message failed to send
Error:
Tail/var/log/message
ndo2db:Warning:queue send error, retrying ... ndo2db:message sent to queue.
Solve:
Vi/etc/sysctl.conf
Kernel.msgmax = 131072000
kernel.msgmnb = 131072000
Kernel.msgmni = 65536000
This article is from the "Moon Ching Xing Fei" blog, please be sure to keep this source http://ywzhou.blog.51cto.com/2785388/1532061