官网的解释是:
NDOUtils allows you to export current and historical data from one or more Nagios instances to a MySQL database. Several community addons use this as one of their data sources. NDOUtils consists of a standalone daemon, a Nagios event broker, and several helper utilities.
NDOUtils允许您将当前和历史数据从一个或多个Nagios实例导出到MySQL数据库。 几个社区插件使用它作为他们的数据源之一。 NDOUtils包括一个独立的守护进程,一个Nagios事件代理和几个帮助实用程序。
环境需求:
安装数据库
一 安装cmake
#yum install mysql-devel perl-DB-MySQL mysql-server
#tar zxvf cmake-2.8.10.2.tar.gz
#cd cmake-2.8.10.2
#./bootstrap
#gmake
#gmake isntall
二 安装数据库
#tar zxvf mysql-5.6.16.tar.gz
#cd mysql-5.6.16.tar.gz
#groupadd mysql
#useradd -r -g mysql mysql
#rm CMakeCache.txt
#cmake -DCMAKE_INSTALL_PREFIX=/usr/monitor-program/mysql -DMYSQL_DATADIR=/data/mysqldb -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
出现错误提示需要安装插件
#yum install ncurses-devel -y 之后再次编译
#make
#make install
初始化数据库
#scripts/mysql_install_db --user=mysql --datadir=/data/mysqldb
#cp /usr/monitor-program/mysql/support-files/my-default.cnf /etc/my.cnf
添加至启动项
#cp /usr/monitor-program/mysql/support-files/mysql.server /etc/init.d/mysqld
#vim /etc/profile
PATH=/usr/monitor-program/mysql/bin:/usr/monitor-program/mysql/lib:$PATH
export PATH#source /etc/profile
#service mysqld start
#chkconfig --level 35 mysqld on
验证
netstat -anputl | grep 3306
登录
#mysql
到这里mysql就安装完了
安装的过程当中要卸载原先的mysql
#yum remove mysql
可能需要安装
#yum install mysql-server -y
三 安装ndoutils
下载ndoutils软件
# wget http://nchc.dl.sourceforge.net/project/nagios/ndoutils-2.x/ndoutils-2.0.0/ndoutils-2.0.0.tar.gz
编译ndoutils工具
安装之前要安装DBI DBD-mysql
安装之前需要关联下面这两项:
安装DBI
#tar zxvf DBI-1.630.tar.gz
#cd DBI-1.630
#perl Makefile.PL
#make
#make test
#make install
如果上边的安装出现问题,可以采用如下方式进行安装:
#perl Makefile.PL
span> install DBI
安装DBD
#tar zxvf DBD-mysql-4.022.tar.gz
#cd DBD-mysql-4.022
#perl Makefile.PL --libs="-L/usr/monitor-program/mysql/lib -lmysqlclient -L/usr/lib -lz " --cflags=-I/usr/monitor-program/mysql/include --mysql_config=/usr/local/mysql/bin/mysql_config --testhost=127.0.0.1--testsocket=/tmp/mysql.sock --testdb=test --testuser=abc --testpassword=abc
#make
#make test
#make install
安装DBD-mysql的时候make test不成功,选择上边的方式编译就能成功了 。
#ln -s /usr/monitor-program/mysql/include/* /usr/include/
# ln -s /usr/monitor-program/mysql/lib/* /usr/lib
# echo '/usr/lib' >> /etc/ld.so.conf
#ldconfig -v
编译安装ndoutils
#tar zxvf ndoutils-2.0.0.tar.gz
#cd ndoutils-2.0.0
#./configure --prefix=/usr/monitor-program/nagios --enable-mysql --disable-pgsql LDFLAGS=-L/usr/monitor-program/mysql/lib --with-mysql-inc=/usr/monitor-program/mysql/include/mysql --with-mysql-lib=/usr/monitor-program/mysql/lib/mysql
#make
#make install
这里make的时候出现如下错误的解决方法:
make[1]: Entering directory `/root/nagiosddd/ndoutils-1.4b9/src’
gcc -fPIC -g -O2 -I/usr/local/mysql/include/mysql -DHAVE_CONFIG_H -c -o io.o io.c In file included from io.c:11: ../include/config.h:261:25: error: mysql/mysql.h: No such file or directory ../include/config.h:262:26: error: mysql/errmsg.h: No such file or directory make[1]: *** [io.o] Error 1 make[1]: Leaving directory `/root/nagiosddd/ndoutils-1.4b9/src’ make: *** [all] Error 2加入启动项
#cp daemon-init /etc/init.d/ndo2db
#chmod 755 /etc/init.d/ndo2db
#cp config/ndo2db.cfg-sample /usr/monitor-program//nagios/etc/ndo2db.cfg
#cp config/ndomod.cfg-sample /usr/monitor-program/nagios/etc/ndomod.cfg
#chown nagios:nagcmd /usr/monitor-program/nagios/etc/ndo*
#chmod 664 /usr/monitor-program/nagios/etc/ndo*
建立数据库和账户
#yum install mysql-devel mysql-server
#mysql
mysql> create database nagios;
mysql> create user nagios@localhost identified by 'nagios';
mysql> grant all on nagios.* to nagios@localhost;
mysql> flush privileges;
mysql> quit
导入表结构
#cd db (此处是是工具内)
# ./installdb -u userdb -p 123456 -h localhost -d nagios
可能会出现以下三个错误:
ndo2db配置数据库连接
# cd /usr/monitor-program/nagios/etc
#vim ndo2db.cfg 修改如下内容
ndo2db_user=nagios
ndo2db_group=nagcmd
db_name=nagios
db_user=nagios
db_pass=nagios
设置nagios与ndoutils通信
#vi nagios.cfg
broker_module=/usr/monitor-program/nagios/bin/ndomod.3x.o config_file=/usr/monitor-program/nagios/etc/ndomod.cfg
# /etc/init.d/ndo2db start
#service nagios restart