1:下载几个包 我下载的包如下:
DBI-1.616.tar.gz |
DBD-mysql-4.018.tar.gz |
ndoutils-1.4b9.tar.gz |
[talkyun@tbe192168146060 DBI-1.616]$ cd ../DBI-1.616 [talkyun@tbe192168146060 DBI-1.616]$ perl Makefile.PL [talkyun@tbe192168146060 DBI-1.616]$ make [talkyun@tbe192168146060 DBI-1.616]$ make install |
3:安装DBD-MYSQL
[talkyun@tbe192168146060 DBI-1.616]$ cd ../DBI-1.616 [talkyun@tbe192168146060 DBD-mysql-4.018]$ perl Makefile.PL --mysql_config=/usr/lib64/mysql/mysql_config --with-mysql=/var/lib/mysql/ [talkyun@tbe192168146060 DBD-mysql-4.018]$ make
[talkyun@tbe192168146060 DBD-mysql-4.018]$ make install |
关联mysql头文件和库 [talkyun@tbe192168146060 DBD-mysql-4.018]$ ln -s /usr/lib64/mysql/* /usr/lib,注:库文件在/usr/includ/mysql下面,我就没做关联了。 [talkyun@tbe192168146060 DBD-mysql-4.018]$ cd ../ndoutils-1.4b9 [talkyun@tbe192168146060 ndoutils-1.4b9]$ ./configure --prefix=/usr/local/nagios/ --enable-mysql --disable-pgsql --with-mysql-inc=/usr/include/mysql --with-mysql-lib=/usr/lib64/mysql [talkyun@tbe192168146060 ndoutils-1.4b9]$ make [talkyun@tbe192168146060 ndoutils-1.4b9]$ cd src/ [talkyun@tbe192168146060 src]$ sudo cp ndo2db-2x ndo2db-3x file2sock log2ndo /usr/local/nagios/bin/ [talkyun@tbe192168146060 config]$ sudo cp ndo2db.cfg-sample /usr/local/nagios/etc/ndo2db.cfg [talkyun@tbe192168146060 config]$ sudo cp ndomod.cfg-sample /usr/local/nagios/etc/ndomod.cfg
[talkyun@tbe192168146060 ndoutils-1.4b9]$ cd db/
|
mysql> show tables; +----------------------------------------+ | Tables_in_ndodb | +----------------------------------------+ | nagios_acknowledgements | | nagios_commands | | nagios_commenthistory | | nagios_comments | | nagios_configfiles | | nagios_configfilevariables | | nagios_conninfo | | nagios_contact_addresses | | nagios_contact_notificationcommands | | nagios_contactgroup_members | | nagios_contactgroups | | nagios_contactnotificationmethods | | nagios_contactnotifications | | nagios_contacts | | nagios_contactstatus | | nagios_customvariables | | nagios_customvariablestatus | | nagios_dbversion | | nagios_downtimehistory | | nagios_eventhandlers | | nagios_externalcommands | | nagios_flappinghistory | | nagios_host_contactgroups | | nagios_host_contacts | | nagios_host_parenthosts | | nagios_hostchecks | | nagios_hostdependencies | | nagios_hostescalation_contactgroups | | nagios_hostescalation_contacts | | nagios_hostescalations | | nagios_hostgroup_members | | nagios_hostgroups | | nagios_hosts | | nagios_hoststatus | | nagios_instances | | nagios_logentries | | nagios_notifications | | nagios_objects | | nagios_processevents | | nagios_programstatus | | nagios_runtimevariables | | nagios_scheduleddowntime | | nagios_service_contactgroups | | nagios_service_contacts | | nagios_servicechecks | | nagios_servicedependencies | | nagios_serviceescalation_contactgroups | | nagios_serviceescalation_contacts | | nagios_serviceescalations | | nagios_servicegroup_members | | nagios_servicegroups | | nagios_services | | nagios_servicestatus | | nagios_statehistory | | nagios_systemcommands | | nagios_timedeventqueue | | nagios_timedevents | | nagios_timeperiod_timeranges | | nagios_timeperiods | +----------------------------------------+ 59 rows in set (0.00 sec) |
4.配置ndo2db.cfg文件:
[root@node3 etc]# vim /usr/local/nagios/etc/ndo2db.cfg
lock_file=/usr/local/nagios/var/ndo2db.lock
ndo2db_user=nagios
ndo2db_group=nagios
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_name=ndodb
db_prefix=nagios_
db_user=ndouser
db_pass=ndouser
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
5.配置ndomod.cfg文件
[root@node3 etc]# vim /usr/local/nagios/etc/ndomod.cfg
instance_name=node3
output_type=tcpsocket
output=127.0.0.1
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
6.配置nagios的配置文件
[root@node3 etc]# vim /usr/local/nagios/etc/nagios.cfg
添加以下两句,第二句如果没有才加上去,默认是有的。
broker_module=/usr/local/nagios/bin/ndomod-3x.o config_file=/usr/local/nagios/etc/ndomod.cfg 大概在251行。
event_broker_options=-1 大概在224行
7. 启动ndo2db守护进程
[root@node3 etc]# /usr/local/nagios/bin/ndo2db-3x -c /usr/local/nagios/etc/ndo2db.cfg
执行完以上这条命令,如果没有报错,就看看nagios.log的日志,如果出现以下提示:
nagios: ndomod: Could not open data sink! I'll keep trying, but some output may get lost...
解决方法就是:
1:查看/usr/local/nagios/etc/ndo2db.cfg文件里的ndo2db_user=nagios ndo2db_group=nagios db_user=ndouser db_pass=ndouser 这几项是否正确配置了,ndo2db_user就是你运行nagios的用户名;ndo2db_group是运行nagios的组,db_user表示的是你授权访问ndodb数据库的用户名,db_pass访问数据的密码。
2:如果1正确。则很有可能是权限问题。nagios目录下的属主不是nagios
如果在加载守护进程出现:
Failed to obtain lock on file /usr/local/nagios/var/ndo2db.lock: Permission denied : Permission denied
解决方法是:确认你在/usr/local/nagios/etc/ndo2db.cfg里ndo2db_user与ndo2db_group这两项的填写的用户是否对目录/usr/local/nagios/var/有写入的权限。
数据库创建:
mysql> create database ndodb;
Query OK, 1 row affected (0.00 sec)
mysql> grant all on ndodb.* to 'ndouser'@'localhost' identified by 'ndouser';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all on ndodb.* to 'ndouser'@'%' identified by 'ndouser';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)