现在的位置: 首页 > 运维管理 > 监控 > 正文
Nagios监控平台之六:安装NDOUtils保存Nagios数据到mysql数据库
2013年05月08日 监控, 运维管理 ⁄ 共 2486字 Nagios监控平台之六:安装NDOUtils保存Nagios数据到mysql数据库已关闭评论 ⁄ 被围观 56,698 views+

Nagios系列文章:

Nagios监控平台之一:在Centos上安装Nagios服务

Nagios监控平台之二:nrpe监控远程Linux主机

Nagios监控平台之三:MRTG监控交换机流量

Nagios监控平台之四:监控Linux服务器CPU温度

Nagios监控平台之五:监控Windows服务器

Nagios监控平台之六:安装NDOUtils保存Nagios数据到mysql数据库

Nagios监控平台之七:Nagios监控HP-UX

1.DBI的安装

# wget http://www.cpan.org/modules/by-module/DBI/DBI-1.625.tar.gz
# tar zxvf DBI-1.625.tar.gz
# cd DBI-1.625
# perl Makefile.PL
# make
# make test
# make install

2.DBD的安装

# wget http://www.cpan.org/modules/by-module/DBD/DBD-mysql-4.023.tar.gz
# tar -zxvf DBD-mysql-4.023.tar.gz
# cd DBD-mysql-4.023
# perl Makefile.PL --mysql_config=/usr/local/mysql/bin/mysql_config --libs=-L/usr/local/mysql/lib-static -lmysqlclient
# make
# make install

3.编译安装NDOUtils

# tar zxf ndoutils-1.5.2.tar.gz
# cd ndoutils-1.5.2
# ./configure --prefix=/usr/local/nagios --enable-mysql --disable-pgsql
# 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/*

4.为NDOUtils创建数据库

# mysql -uroot -p
mysql> create database nagios;
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 nagios
也可这样:# /opt/mysql/bin/mysql -u root -p -D nagios -h localhost < ./db/mysql.sql

5.编辑配置文件

# 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

6.启动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

7.重启动nagios

# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
# service nagios restart

检查安装

# tail -20 /usr/local/nagios/var/nagios.log

8、遇到问题:

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
#再执行一下安装过程后,通过

抱歉!评论已关闭.

×