yum -y install php-devel mysql-devel php-pdo php-json gd php-gd gd-devel
#1.install json
mkdir -p /data0/soft
cd !$
wget
tar jxvf php-json-ext-1.2.1.tar.bz2
cd php-json-ext-1.2.1
phpize
./configure && make && make install
echo "extension=json.so" >> /etc/php.d/json.ini
service httpd restart
#3.install ndoutils
cd /data0/soft
wget
tar -zxvf ndoutils-1.4b9.tar.gz
cd ndoutils-1.4b9
./configure --with-mysql-inc=/usr/include/mysql --with-mysql-lib=/usr/lib/mysql --enable-mysql --with-ndo2db-user=nagios --with-ndo2db-group=nagios
make
cd src/
\cp ndomod-3x.o ndo2db-3x log2ndo file2sock /usr/local/nagios/bin
#\cp ndomod-3x.o ndo2db-3x log2ndo file2sock /usr/bin
cd ../config
\cp ndo2db.cfg-sample ndo2db.cfg
\cp ndomod.cfg-sample ndomod.cfg
\cp ndo2db.cfg ndomod.cfg /usr/local/nagios/etc/
sed -i 's/db_name=nagios/db_name=cacti/g' /usr/local/nagios/etc/ndo2db.cfg
sed -i 's/db_user=ndouser/db_user=cactiuser/g' /usr/local/nagios/etc/ndo2db.cfg
sed -i 's/db_pass=ndopassword/db_pass=cactiuser/g' /usr/local/nagios/etc/ndo2db.cfg
sed -i 's/db_prefix=nagios\_/db_prefix=npc\_/g' /usr/local/nagios/etc/ndo2db.cfg
sed -i 's/debug_level=0/debug_level=1/g' /usr/local/nagios/etc/ndo2db.cfg
sed -i 's/ndo2db_group=nagios/ndo2db_group=nagcmd/g' /usr/local/nagios/etc/ndo2db.cfg
sed -i 's@^#broker_module=.*debug=0$@broker_module = /usr/local/nagios/bin/ndomod-3x.o config_file = /usr/local/nagios/etc/ndomod.cfg@g' /usr/local/nagios/etc/nagios.cfg
sed -i 's/process_performance_data=0/process_performance_data=1/g' /usr/local/nagios/etc/nagios.cfg
sed -i 's/obsess_over_hosts=0/obsess_over_hosts=1/g' /usr/local/nagios/etc/nagios.cfg
sed -i 's/obsess_over_services=0/obsess_over_services=1/g' /usr/local/nagios/etc/nagios.cfg
#4.install npc
cd /data0/soft
wget
tar -zxvf npc-2.0.4.tar.gz
[ ! -d /var/www/html/plugins/ ] && mkdir /var/www/html/plugins/
mv npc/ /var/www/html/plugins/
sed -i "s#$plugins = array();#$plugins = array();\n\$plugins[] = 'npc';#g" /var/www/html/include/global.php
#安装npc
#Console -> Plugin Management > npc > 点击 Install && Enable
mysql
use cacti
ALTER TABLE `npc_hostchecks` ADD COLUMN `long_output` varchar(8192) NOT NULL default '' AFTER `output`;
ALTER TABLE `npc_hoststatus` ADD COLUMN `long_output` varchar(8192) NOT NULL default '' AFTER `output`;
ALTER TABLE `npc_servicechecks` ADD COLUMN `long_output` varchar(8192) NOT NULL default '' AFTER `output`;
ALTER TABLE `npc_servicestatus` ADD COLUMN `long_output` varchar(8192) NOT NULL default '' AFTER `output`;
ALTER TABLE `npc_statehistory` ADD COLUMN `long_output` varchar(8192) NOT NULL default '' AFTER `output`;
ALTER TABLE `npc_eventhandlers` ADD COLUMN `long_output` varchar(8192) NOT NULL default '' AFTER `output`;
ALTER TABLE `npc_systemcommands` ADD COLUMN `long_output` varchar(8192) NOT NULL default '' AFTER `output`;
ALTER TABLE `npc_notifications` ADD COLUMN `long_output` varchar(8192) NOT NULL default '' AFTER `output`;
quit
#5.配置 npc
Console -> Settings -> npc
钩选Remote Commands
Nagios Command File Path: /usr/local/nagios/var/rw/nagios.cmd
Nagios URL:
#6.启动 nagios 与 ndo2db
chown -R nagios:nagcmd /usr/local/nagios/
chmod 755 -R /usr/local/nagios/
pgrep ndo|xargs -t -i kill -9 {}
rm -fr /usr/local/nagios/var/ndo.sock && /usr/local/nagios/bin/ndo2db-3x -c /usr/local/nagios/etc/ndo2db.cfg
service nagios restart
阅读(2029) | 评论(0) | 转发(0) |