How to install ndoutils on centos
How to Install Ndoutils on nagios version 3 above
==================================================
Install Ndoutils pre-requists
-----------------------------
# yum -y install mysql mysql-server mysql-client gcc-c++ libdbi-dbd-mysql
# /etc/init.d/mysqld start
# /sbin/chkconfig mysqld on
# /usr/bin/mysqladmin -u root password your_password
Create database for nagios
---------------------------
# mysql -u root -pyourpassword
mysql> create database nagios;
mysql> grant all privileges on nagios.* to 'nagios'@'localhost' identified by 'nagios' with grant option;
mysql> flush privileges;
mysql> quit
Download ndoutils
-----------------
# mkdir /opt/downloads
# cd /opt/downloads
# wget
# cd /opt/downloads/ndoutils-1.4b9
Installing ndoutils
--------------------
./configure --prefix=/usr/local/nagios/ --enable-mysql --with-ndo2db-user=nagios --with-ndo2db-group=nagcmd
make
Manual install ( NO MAKE INSTALL )
-----------------------------------
# db/installdb -u nagios -p nagios -h localhost -d nagios
(cd ./db; ./installdb -u nagios -p nagios -h localhost -d nagios)
# cp ./src/ndomod-3x.o /usr/local/nagios/bin/ndomod.o
# cp ./src/ndo2db-3x /usr/local/nagios/bin/ndo2db
# cp ./config/ndo2db.cfg-sample /usr/local/nagios/etc/ndo2db.cfg
# cp ./config/ndomod.cfg-sample /usr/local/nagios/etc/ndomod.cfg
# chmod 774 /usr/local/nagios/bin/ndo*
# chown nagios:nagios /usr/local/nagios/bin/ndo*
Install the init script
------------------------
# cp ./daemon-init /etc/init.d/ndo2db
# chmod +x /etc/init.d/ndo2db
# chkconfig --add ndo2db
Edit nagios.cfg and verify or add the following lines
------------------------------------------------------
# vim /usr/local/nagios/etc/nagios.cfg
event_broker_options=-1
broker_module=/usr/local/nagios/bin/ndomod.o config_file=/usr/local/nagios/etc/ndomod.cfg
Make necessary modifications in ndo2db.cfg file ( My Sample cfg file )
----------------------------------------------------------------------
# vim /usr/local/nagios/etc/ndo2db.cfg
lock_file=/usr/local/nagios/var/ndo2db.lock
ndo2db_user=nagios
ndo2db_group=nagios
socket_type=unix
#socket_type=tcp
socket_name=/usr/local/nagios/var/ndo.sock
tcp_port=5668
use_ssl=0
db_servertype=mysql
db_host=localhost
db_port=3306
db_prefix=nagios_
db_user=nagios
db_pass=nagios
max_timedevents_age=1440
max_systemcommands_age=10080
max_servicechecks_age=10080
max_hostchecks_age=10080
max_eventhandlers_age=44640
max_externalcommands_age=44640
debug_level=0
debug_verbosity=1
debug_file=/usr/local/nagios/var/ndo2db.debug
max_debug_file_size=1000000
# vim /usr/local/nagios/etc/ndomod.cfg
instance_name=default
#output_type=tcpsocket
output_type=unixsocket
output=/usr/local/nagios/var/ndo.sock
tcp_port=5668
use_ssl=0
output_buffer_items=5000
buffer_file=/usr/local/nagios/var/ndomod.tmp
file_rotation_interval=14400
file_rotation_timeout=60
reconnect_interval=15
reconnect_warning_interval=15
data_processing_options=-1
config_output_options=2
Start the ndo2db init script and restart the nagios
----------------------------------------------------
# /etc/init.d/ndo2db start
# /etc/init.d/nagios restart
You will get the log report like this
# tail -f /usr/local/nagios/var/nagios.log
[1296905045] LOG VERSION: 2.0
[1296905045] ndomod: NDOMOD 1.4b9 (10-27-2009) Copyright (c) 2009 Nagios Core Development Team and Community Contributors
[1296905045] ndomod: Successfully connected to data sink. 0 queued items to flush.
[1296905045] Event broker module '/usr/local/nagios/bin/ndomod.o' initialized successfully.
[1296905045] Finished daemonizing... (New PID=7529)
================================================================
问题修复:
============ NDO2DB 数据库中没有数据 ==========
message log 中有如下内容:
Jul 16 11:56:48 cndaldmz01vl ndo2db: Error: queue init error.
Jul 16 11:56:48 cndaldmz01vl ndo2db: Error: queue recv error.
Jul 16 11:56:48 cndaldmz01vl ndo2db: Error: queue recv error.
Jul 16 11:56:48 cndaldmz01vl ndo2db: Error: queue send error.
Jul 16 11:56:48 cndaldmz01vl ndo2db: Error: queue recv error.
Jul 16 12:10:47 cndaldmz01vl ndo2db: Warning: Retrying message send. This can occur because you have too few messages allowed or too few total bytes allowed in message queues. You are currently using 64 of 65536000 messages and 65536 of 65536 bytes in the queue. See README for kernel tuning options.
solution:
默认 queue 太小
修改系统内核参数,就正常了。
[root@cndaldmz01vl log]#vi /etc/sysctl.conf
#the maximum size of a single message in a message queue
kernel.msgmax = 65536000
#the total number of bytes allow in all messages in any one message queue
kernel.msgmnb = 65536000
#the maximum size of a single message in a message queue
kernel.msgmni = 65536
[root@cndaldmz01vl log]#sysctl -p
restart ndo2db nagios
It is recomended to remove all message queues owned by user nagios before ndoutils startup.
This can be achieved by script:
for i in `ipcs -q | grep nagios |awk '{print $2}'`; do ipcrm -q $i; done
============== 编译时提示找不到 MySQL library =========
Install mysql-devel if got this prompt "*** MySQL library could not be located... *** "
阅读(2418) | 评论(0) | 转发(0) |