Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1848779
  • 博文数量: 293
  • 博客积分: 10127
  • 博客等级: 上将
  • 技术积分: 3029
  • 用 户 组: 普通用户
  • 注册时间: 2010-08-12 19:05
文章分类

全部博文(293)

文章存档

2011年(11)

2010年(282)

我的朋友

分类: BSD

2010-08-24 01:27:08

1.NDOUtils安装需求:
Nagios正确安装运行,版本>=2.0安装目录:/usr/local/nagios
MySQL正确安装并运行,我用的是二进制安装包,安装目录:/usr/local/mysql
2.安装
下载安装包:
# 确认DBD-mysql包安装,如没有安装,请先安装。
# 如果DBI包没安装DBD-mysql前需要先安装DBI包
tar xzvf DBI-1.605.tar.gz
cd DBI-1.605
perl Makefile.PL
make
make install
tar xzvf DBD-mysql-3.0008.tar.gz
cd DBD-mysql-3.0008
unset LANG
perl Makefile.PL --libs="-L/usr/local/mysql/lib/mysql -lmysqlclient -L/usr/lib -lz " --cflags=-
I/usr/local/mysql/include/mysql --mysql_config=/usr/local/mysql/bin/mysql_config --testhost=127.0.0.1 --
testsocket=/usr/local/mysql/tmp/mysql.sock --testdb=nagios --testuser=root --testpassword=123456
make
make install
# 做好MySQL库文件lib和include文件的连接(这点很重要)。
ln -s /usr/local/mysql/include/* /usr/include/
mkdir /usr/include/mysql
ln -s /usr/local/mysql/include/* /usr/include/mysql/
ln -s /usr/local/mysql/lib/* /usr/lib/
mkdir /usr/lib/mysql
ln -s /usr/local/mysql/lib/* /usr/lib/mysql
tar xzvf ndoutils-1.4b7.tar.gz
cd ndoutils-1.4b7
./configure --enable-mysql --disable-pgsql --with-mysql-lib=/usr/local/mysql/lib --with-mysql-inc=/usr/local/mysql/include

# 执行完成后,注意向上看看打印出的信息,看看是否找到了MySQL的库文件和include文件。
make
cd src/
# 我的Nagios是3.0.5,所以拷贝的是ndomod-3x.o、ndo2db-3x,如果你的是2.X.x请拷贝ndomod-2x.o、ndo2db-2x
cp ndomod-3x.o ndo2db-3x log2ndo file2sock /usr/local/nagios/bin
cd ../db
# 创建数据库,使用root用户,密码是123456
/usr/local/mysql/mysqldadmin -u root -p
mysql> CREATE DATABASE nagios;
./installdb -u root -p 123456 -d nagios(这需要改下installdb脚本,指定mysql的可执行程序在哪,否则报不能发现mysql命令在哪
.)
# 拷贝配置文件
cd ../config
cp ndo* /usr/local/nagios/etc/
# 修改/usr/local/nagios/etc/ndo2db.cfg文件的数据库信息。
vi /usr/local/nagios/etc/ndo2db.cfg
vi nagios.cfg
# 复制下面内容粘贴到/usr/local/nagios/etc/nagios.cfg配置文件的#broker_module=...下面。
# Uncomment the line below if you're running Nagios 3.x
broker_module=/usr/local/nagios/bin/ndomod-3x.o config_file=/usr/local/nagios/etc/ndomod.cfg
# 修改/usr/local/nagios/etc/nagios.cfg配置文件下面参数的值为-1(一般默认如此)。
event_broker_options=-1
# 启动ndo2db
/usr/local/nagios/bin/ndo2db-3x -c /usr/local/nagios/etc/ndo2db.cfg
# 查看系统日志是否有错误信息:
tail -30 /var/log/messages
Nov 27 14:09:26 tech nagios: ndomod: NDOMOD 1.4b7 (10-31-2007) Copyright (c) 2005-2007 Ethan Galstad
()
Nov 27 14:09:26 tech nagios: ndomod: Successfully connected to data sink. 0 queued items to flush.
Nov 27 14:09:26 tech nagios: Event broker module '/usr/local/nagios/bin/ndomod-3x.o' initialized successfully.
Nov 27 14:09:26 tech nagios: Finished daemonizing... (New PID=18848)
# 重启Nagios
service nagios restart
# 查看Nagios日志,看是否正常启动。
tail -20 /usr/local/nagios/var/nagios.log
[1227766166] ndomod: NDOMOD 1.4b7 (10-31-2007) Copyright (c) 2005-2007 Ethan Galstad ()
[1227766166] ndomod: Successfully connected to data sink. 0 queued items to flush.
[1227766166] Event broker module '/usr/local/nagios/bin/ndomod-3x.o' initialized successfully.
[1227766166] Finished daemonizing... (New PID=18848)
##############这里要说明下启动ndo2db那步骤我没做,修改了ndo2db.cfg,ndomod.cfg里面的相关socket type选项及数据库相关项,
之后直接service nagios restart,如果做的话出现错误提示请看下面解决办法###########
关于启动ndo出现错误提示:
1. 如果启动后出现错误:Could not bind socket: Address already in use
解决解决办法是将/usr/local/nagios/var/ndo.sock删除,停止ndo的时候这个文件不会被删除,可以自己写个启动脚本将这个文件删
除后在启动ndo。
2. 启动ndo后在日志中出现:nagios ndo2db-3x: Error: mysql_query() failed for 'INSERT INTO nagios_configfilevariables
SET instance_id='1', configfile_id='3', varname='cfg_file', varvalue='/usr/local/nagios//etc/objects/localhost\.cfg
解决办法是使用:mysql -uroot --password="canada" -h192.168.1.97 -e "alter table nagios.nagios_configfilevariables
drop key instance_id;alter table nagios.nagios_configfilevariables add index (instance_id, configfile_id, varname);
需要修改表结构。
关于出现mysql相关(DBD,perl)错误提示:
1. 如在make 阶段出错
   (1)类、、、、make: *** [dbdimp.o] 错误 1
多半是库文件的问题,(--cflags=-I/usr/local/mysql/include/mysq 细查,少个“y"
   (2)类 LD_RUN_PATH="/usr/lib/mysql:/lib:/usr/lib" gcc
    -o blib/arch/auto/DBD/mysql/mysql.so -shared
    -L/usr/local/lib dbdimp.o mysql.o -L/usr/lib/mysql
    -lmysqlclient -lm -L/usr/lib/gcc-lib/i386-redhat-linux/2.96
    -lgcc -lz
/usr/bin/ld: cannot find[b] -lz[/b]
collect2: ld returned 1 exit status
make: *** [blib/arch/auto/DBD/mysql/mysql.so] Error 1
与压缩包有关。可用 ldconfig -p | grep libz
                     ldconfig -p | grep libgz
   查找,如有并指定路径!否则安装 libz-devel/ibgz-devel/zlib-devel/    gzlib-devel
2. 在make test 阶段出错:
(1)类: install_driver(mysql) failed: [b]Can't load[/b]
'/usr/lib/perl5/site_perl/i586-linux/auto/DBD/mysql/[b]mysql.so[/b]'
for module DBD::mysql: [b]File not found at[/b]
/usr/lib/perl5/i586-linux/5.00404/DynaLoader.pm line 166
与 /usr/lib/mysql/libmysqlclient.a有关 (cp libmysqlclient.a /us/lib)
(2)类: t/00base............install_driver(mysql) failed: [b]Can't load[/b]
'../blib/arch/auto/DBD/mysql/mysql.so' for module DBD::mysql:
../blib/arch/auto/DBD/mysql/mysql.so: [b]undefined symbol[/b]: _umoddi3
at /usr/local/perl-5.005/lib/5.005/i586-linux-thread/DynaLoader.pm
line 168.
与libgcc.a 有关 (cp /usr/lib/gcc/i386-redhat-linux/4.1.1/libgcc.a /usr/local/lib/
(3) 类:Can't load libmysqlclient.so.15 、、、、
     (cp libmysqlclient.so.15 /us/lib)
阅读(6827) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

王晓兜2013-11-14 14:58:48

Nov 14 14:34:43 Server nagios: ndomod: Still unable to connect to data sink.  64624 items lost, 5000 queued items to flush.
Nov 14 14:34:59 Server nagios: ndomod: Still unable to connect to data sink.  64706 items lost, 5000 queued items to flush.
我的日志文件 , 始终连接不上数据库阿