vim /data/www/wwwroot/nagios/etc/ndomod.cfg
=============================begin==========================
output_type=tcpsocket
output=127.0.0.1
buffer_file=/data/www/wwwroot/nagios/var/ndomod.tmp
================================end================================
启动 /data/www/wwwroot/nagios/bin/ndo2db-3x -c /data/www/wwwroot/nagios/etc/ndo2db.cfg
service nagios restart
tail /var/log/message
================出现类似内容===================================================
Mar 2 15:52:28 localhost nagios: Nagios 3.3.1 starting... (PID=20779)
Mar 2 15:52:28 localhost nagios: Local time is Fri Mar 02 15:52:28 CST 2012
Mar 2 15:52:28 localhost nagios: LOG VERSION: 2.0
Mar 2 15:52:28 localhost nagios: ndomod: NDOMOD 1.4b9 (10-27-2009) Copyright (c) 2009 Nagios Core Development Team and Community Contributors
Mar 2 15:52:28 localhost nagios: ndomod: Successfully connected to data sink. 5000 queued items to flush.
Mar 2 15:52:28 localhost nagios: ndomod: Successfully flushed 5000 queued items to data sink.
Mar 2 15:52:28 localhost nagios: Event broker module '/data/www/wwwroot/nagios/bin/ndomod-3x.o' initialized successfully.
Mar 2 15:52:29 localhost nagios: Finished daemonizing... (New PID=20781)
============================ok成功==========================================================
cp /usr/local/src/ndoutils-1.4b9/daemon-init /etc/init.d/ndo2db
chmod +x /etc/init.d/ndo2db
vim /etc/init.d/ndo2db
=======================修改下面内容===========================
servicename=ndo2db
prefix=/data/www/wwwroot/nagios
exec_prefix=/data/www/wwwroot/nagios
Ndo2dbBin=/data/www/wwwroot/nagios/bin/ndo2db-3x
Ndo2dbCfgFile=/data/www/wwwroot/nagios/etc/ndo2db.cfg
Ndo2dbVarDir=/data/www/wwwroot/nagios/var
Ndo2dbRunFile=$Ndo2dbVarDir/ndo2db.lock
Ndo2dbLockDir=/var/lock/subsys
Ndo2dbLockFile=ndo2db
==========================end======================
chkconfig --add ndo2db
chkconfig ndo2db on
service ndo2db start
service nagios start
2、安装ncp,以在Cacti中展现Nagios
cd /usr/local/src
wget http://www.cacti.net/downloads/pia/cacti-plugin-0.8.7h-PA-v3.0.tar.gz
tar xzvf cacti-plugin-0.8.7h-PA-v3.0.tar.gz
cp -R cacti-plugin-arch/* /data/www/wwwroot/cacti
cd /data/www/wwwroot/cacti
mysql -ucacti -pzzzzzzz cacti < pa.sql
patch -p1 -N < cacti-plugin-0.8.7h-PA-v3.0.diff
vim include/config.php
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "cacti";
$database_port = "3306";
$database_ssl = false;
$url_path = "/cacti/"; 注:此路径根据cacti 在apache中的设置而定
用浏览器打开cacti 点击 User Management>admin>最下面勾选Plugin Management>save
npc 包 见附件
tar xzvf npc-2.0.4.tar.gz
mv npc /data/www/wwwroot/cacti/plugins/
vim /data/www/wwwroot/cacti/include/config.php
$plugins[] = 'npc';
wget http://pkgs.fedoraproject.org/repo/pkgs/php-pecl-json/json-1.2.1.tgz/d8904d2f004ceec85eeacf524cd25539/json-1.2.1.tgz
tar xvf json-1.2.1.tgz
cd json-1.2.1
/usr/local/php-5.2.17/bin/phpize
./configure --with-php-config=/usr/local/php-5.2.17/bin/php-config --enable-shared --enable-static --with-json
make&&make install
vim /usr/local/php-5.2.17/etc/php.ini
extension_dir = "/usr/local/php-5.2.17/lib/php/extensions/no-debug-non-zts-20060613/"
extension = "json.so"
访问cacti
Configuration -> Plugin Management -> Actions -> 箭头点击安装 -> 右击绿色箭头启用,这时页面就有NPC选项
mysql -u cacti -pzzzzzzz
use cacti;
Database changed
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> \q
在Settings->npc中 ,勾上Remote Commands
Nagios Command File Path=/data/www/wwwroot/nagios/var/rw/nagios.cmd
Nagios URL=http://localhost/nagios/
点击 npc 只出图不出数据,检查是否安装了pdo-mysql,编译安装方法如下(路径根据实际情况):
cd /usr/local/src/php-5.2.17/ext/pdo_mysql
/usr/local/php-5.2.17/bin/phpize
./configure --with-php-config=/usr/local/php-5.2.17/bin/php-config --with-pdo-mysql=/usr/local/mysql-5.1.56/
make && make install
vim /usr/local/local/php-5.2.17/etc/php.ini
===================最后加入============================
extension_dir = "/usr/local/php-5.2.17/lib/php/extensions/no-debug-non-zts-20060613/"
extension = "pdo_mysql.so"
============================END=====================================
四、Nconf的安装与配置
[root@rhel ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 49
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> create database nconf; (创建nconf数据库)
Query OK, 1 row affected (0.02 sec)
mysql> grant all privileges on nconf.* to nconf@localhost identified by 'zzzzzzz'; (创建nconf用户并赋权)
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges; (刷新特权表)
Query OK, 0 rows affected (0.00 sec
wget http://sourceforge.net/projects/nconf/files/nconf/1.2.6-0/nconf-1.2.6-0.tgz
tar xvf nconf-1.2.6-0.tgz
mv nconf /data/www/wwwroot/cacti
chown -R nagios:nagios /data/www/wwwroot/nconf
访问 http://ip/nconf
DBHOST localhost
DBNAME nconf
DBUSER nconf
DBPASS nconf
rm -rf INSTALL INSTALL.php UPDATE UPDATE.php
ln -s /data/www/wwwroot/nagios/bin/nagios /data/www/wwwroot/nconf/bin/nagios
chmod +x /data/www/wwwroot/nconf/bin/*
chmod +x /data/www/wwwroot/nagios/bin/nagios
chmod +x /data/www/wwwroot/nconf/ADD-ONS/deploy_local.sh
vim /data/www/wwwroot/nconf/ADD-ONS/deploy_local.sh
OUTPUT_DIR="/data/www/wwwroot/nconf/output/"
NAGIOS_DIR="/data/www/wwwroot/nagios/etc/"
/data/www/wwwroot/nconf/ADD-ONS/deploy_local.sh
五、补充 cacti插件
montor
安装monitor
1、下载及解压monitor
[root@localhost home]# wget http://docs.cacti.net/_media/plugin:monitor-v1.2-1.tgz
mv plugin\:monitor-v1.2-1.tgz monitor.tgz
tar xvf monitor.tgz
mv monitor/ /data/www/wwwroot/cacti/plugins/
cd /data/www/wwwroot/cacti/plugins/monitor/
mysql -h localhost -u cacti -p cacti < /data/www/wwwroot/cacti/plugins/monitor/monitor.sql
Enter password:
2、启用monitor
点击plugin management 进入启用monitor即可
3、设置monitor