Nagios下的NDOUtils插件

NDOUtils插件是用于Nagios中的事件和配置信息数据导入数据库用于在数据库中记录其相关的关联关系,在以前有使用NagiosQL()有些类似,不过不同的是在NagiosQL中是已经有用php文件写好的前端页面以及和定义的配置文件与数据库交互,而在NDOUtils中仅仅是把Nagios中事件和配置信息记录于数据库中,这使得可以根据存入数据库中的记录状态用于监控或者做其他触发等等,在这里就简单的说一说NDOUtils的安装部署,NDOUtils安装部署还是比较简单的,在这里使用的数据库建议MySQL,NDOUtils可以在Nagios的社区中下载最新稳定版https://exchange.nagios.org/directory/Addons/Database-Backends/NDOUtils/details

[root@localhost ndoutils-2.1.3]# yum -y install perl-DBD-MySQL perl-DBI
[root@localhost ndoutils-2.1.3]# tar -zxvf ndoutils-2.1.3.tar.gz && cd ndoutils-2.1.3
[root@localhost ndoutils-2.1.3]# ./configure --enable-mysql --with-mysql=/usr/local/mysql --with-ndo2db-user=nagios -with-ndo2db-group=nagios
[root@localhost ndoutils-2.1.3]# make all && make fullinstall
[root@localhost ndoutils-2.1.3]# cp -arp startup/default-init /etc/init.d/ndo2db
[root@localhost ndoutils-2.1.3]# chmod +x /etc/init.d/ndo2db
[root@localhost ndoutils-2.1.3]# cd db/
#建库导入数据
mysql> CREATE DATABASE nagios;
mysql> GRANT ALL ON `nagios`.* TO nagios@'localhost' IDENTIFIED BY "youpassword";
mysql> use nagios;
mysql> source mysql.sql
[root@localhost db]# cd /usr/local/nagios/etc/
[root@localhost etc]# mv ndo2db.cfg-sample ndo2db.cfg && mv ndomod.cfg-sample ndomod.cfg
#ndo2db.cfg是用于连接数据库的相关配置,根据实际数据库用户密码连接
#ndomod.cfg使用于配置相关日志及使用相关模式的配置文件
[root@localhost db]# vim nagios.cfg
…略…
broker_module=/usr/local/nagios/bin/ndomod.o config_file=/usr/local/nagios/etc/ndomod.cfg
event_broker_options=-1
[root@localhost etc]# /etc/init.d/ndo2db start

在这里需要注意的是在安装的MySQL下需要定义好MySQL的lib文件导入系统目录后用ldconfig,还有在不同版本中的NDOUtils编译参数都不太相同,在编译前可以./configure --help查看,这里需要注意的是在每次添加修改重启Nagios后都需要重启ndo2db重新把配置信息及事件记录于数据库中

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/0e7c9a412bfafd1debc1b36f048f1302.html