Nagios插件NDOUtils安装

1.DBI的安装
# wget http://www.cpan.org/modules/by-module/DBI/DBI-1.608.tar.gz
# tar zxvf DBI-1.608.tar.gz
# cd DBI-1.608
# perl Makefile.PL
# make
# make test
# make install
2.DBD的安装
# wget http://www.cpan.org/modules/by-module/DBD/DBD-mysql-4.011.tar.gz
# tar -zxvf DBD-mysql-4.011.tar.gz
# cd DBD-mysql-4.011
# perl Makefile.PL --mysql_config=/usr/local/mysql/bin/mysql_config --libs=-L/usr/local/mysql/lib-static -lmysqlclient
# make
# make install


3.关联mysql头文件和库
# ln -s /usr/local/mysql/lib/mysql/* /usr/lib
# ln -s /usr/local/mysql/include/mysql/* /usr/include
# ldconfig -v

4.编译安装NDOUtils
# tar zxf ndoutils-1.4b9.tar.gz
# cd ndoutils-1.4b9
# ./configure --prefix=/usr/local/nagios --enable-mysql --disable-pgsql LDFLAGS=-L/usr/local/mysql/lib --with-mysql-inc=/usr/local/mysql/include/mysql --with-mysql-lib=/usr/local/mysql/lib/mysql

# cp ./src/ndomod-3x.o /usr/local/nagios/bin
# cp ./src/ndo2db-3x /usr/local/nagios/bin
# cp ./src/log2ndo /usr/local/nagios/bin
# cp ./src/file2sock /usr/local/nagios/bin
# chown nagios:nagios /usr/local/nagios/bin/*

# cp ./config/ndo* /usr/local/nagios/etc/
# chown nagios:nagios /usr/local/nagios/etc/*

5.为NDOUtils创建数据库
# mysql -uroot -p
mysql> create database ndodb;
mysql> GRANT SELECT,INSERT,UPDATE,DELETE ON nagios.* TO nagios@localhost IDENTIFIED BY '123456';
mysql> flush privileges;
mysql> \q
生成ndoutils所需要的数据库
# cd db
# ./installdb -u n root -p 123456 -h localhost -d ndodb
也可这样:# /opt/mysql/bin/mysql -u root -p -D nagios -h localhost < ./db/mysql.sql

6.编辑配置文件
# vi /usr/local/nagios/etc/ndo2db.cfg
db_user=nagios
db_pass=123456
# vi /usr/local/nagios/etc/nagios.cfg
# 复制下面内容粘贴到#broker_module=...下面。
broker_module=/usr/local/nagios/bin/ndomod-3x.o config_file=/usr/local/nagios/etc/ndomod.cfg
此外,请确保您的/usr/local/nagios/etc/nagios.cfg中有如下行出现,否则,请自行添加:
event_broker_options=-1 //为Nagios开启event broker

7启动ndo2db
# /usr/local/nagios/bin/ndo2db-3x -c /usr/local/nagios/etc/ndo2db.cfg
# echo '/usr/local/nagios/bin/ndo2db-3x -c /usr/local/nagios/etc/ndo2db.cfg' >> /etc/rc.local

8.重启动nagios
# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
# service nagios restart
检查安装
tail -20 /usr/local/nagios/var/nagios.log


遇到问题:
1.执行 # /usr/local/nagios/bin/ndo2db-3x -c /usr/local/nagios/etc/ndo2db.cfg
提示错误:Could not bind socket: Address already in use
解决:ps aux|grep ndo2db #没有
查看套接字文件是否存在,删除之
ll /usr/local/nagios/var/ndo.sock
rm /usr/local/nagios/var/ndo.sock
2.#ndo2db数据不能导入到数据库
原因:编译时没有LDFLAGS=-L/opt/mysql/lib
解决:重新编译ndoutils并加上 LDFLAGS=-L/opt/mysql/lib
# ./configure --prefix=/usr/local/nagios --enable-mysql --disable-pgsql LDFLAGS=-L/usr/local/mysql/lib --with-mysql-inc=/usr/local/mysql/include/mysql --with-mysql-lib=/usr/local/mysql/lib/mysql
# make
#再执行一下安装过程后,通过

你可能感兴趣的:(职场,插件,nagios,休闲,ndoutils)