NDOUTILS,Nagios Data Output Utils,Nagios数据输出工具,容许用户从Nagios导出状态和事件信息到数据库中,便于之后的检索和加工
它包括几个部分:html
NDOMOD是事件中断模块。这个模块在Nagios进程运行时加载。
它惟一的角色就是转存Nagios全部事件和数据到TCP套接字,或者普通文件,或者Unix域套接字。
若是用户想实时转发数据至MySQL,能够经过转存数据至TCP套接字或者Unix域套接字。若是想延迟转发数据至MySQL数据库,能够经过转存数据至普通文件。mysql
NDO2DB守护进程。这是一个标准的守护进程,从TCP套接字或者Unix套接字读取输入数据(经过NDOMOD事件中断模块输出)。
NDO2DB分析这些数据,并把他们存入一个或者多个MySQL数据中。NDO2DB具备同时处理多个客户端的链接的能力,所以用户同时能够配置多个经过TCP或者Unix套接字输出数据的NDOMOD模块实例。linux
FILE2SOCK特性从普通的文件读取数据,将其经过TCP或者Unix套接字转存。
这在NDOMOD模块将数据写入普通文件时,但但愿将其转存至数据库的使用场景很是有用。
若是NDOMOD模块输出的数据和NDO2DB运行进程不在同一台主机上时,用户能够经过SSH协议转发存放数据的普通文件至运行NDO2DB进程的主机上,而后经过FILE2SOCK特性转发普通文件的内容至TCP或者Unix端口(NDO2DB从这些端口中获取数据)ios
LOG2NDO特性用于将Nagios和NetSaint的历史日志归档并转发给NDO2DB进程。一样也是将一个日志文件发送至TCP或者Unix套接字完成数据转存。sql
configure数据库
./configure \ --prefix=/usr/local/globle/softs/monitor/nagios/ndoutils/2.1.3 \ --sysconfdir=/usr/local/globle/softs/monitor/nagios/ndoutils/2.1.3/etc \ --localstatedir=/var \ --enable-mysql \ --with-opsys=linux \ --with-dist-type=rh \ --with-init-type=sysv \ --with-inetd-type=xinetd \ --with-mysql-lib=/usr/lib64/mysql \ --with-ndo2db-user=nagios \ --with-ndo2db-group=nagios
注:--with-mysql-lib的选项提示没法识别,可是能够正确配置MySQL库;可是以--with-mysql选项配置时,实际没法生效服务器
make
直接执行make,提示选择make的选项,这里选择make alldom
[root@console ndoutils-2.1.3]# make Please enter make [option] where [option] is one of: all builds the NDO Utilities ndo2db builds the ndo2db daemon ndomod builds the ndomod nagios module file2sock builds the file2sock utility log2ndo builds the log2ndo utility sockdebug builds the sockdebug utility install-groups-users add the user and group if they do not exist install installs the module and programs install-config installs the sample configuration files install-inetd install the startup files for inetd, launchd, etc. install-init install the startup files for init, systemd, etc. fullinstall runs install-groups-users, install,install-config and install-init
make install
执行make install
以后,提示安装了适配Nagios v4.x的模块。按照文档说明,若是须要安装Nagios v3.x 和v2.x的模块,还须要执行make install-3x
和make install-2x
,可是会替代。
本篇博客编译所有模块,而后都拷贝到对应的目录下,在配置文件中指定要采用的模块的绝对路径。tcp
注:在当前解压目录下,没法执行make install-3x,无makefile工具
截至到这里,NDOUtils已经编译安装完成。
安装database
这一步须要首先建立一个数据库并受权。
本篇略此过程,具体参阅博客《MySQL数据库服务器(YUM)安装.md》,博客园地址:http://www.javashuo.com/article/p-bjccruua-bu.html
而后进入到db目录下,执行./installdb
脚本,结果如图
执行make install-init,安装启动脚本
执行make install-inetd,安装超级进程配置文件
这一步须要将5668端口添加至/etc/services,即在/etc/services最后一行添加:
ndo2db 5668/tcp # ndo2db
执行make install-config,安装ndo2db.cfg配置文件
至此,在安装路径/usr/local/globle/softs/monitor/nagios/ndoutils/2.1.3/
下,能看到三个目录,即:
在/usr/local/globle/softs/monitor/nagios/ndoutils/2.1.3/etc/
下,执行cp ndo2db.cfg-sample ndo2db.cfg
和cp ndomod.cfg-sample ndomod.cfg
修改Nagios主配置文件,以下:
event_broker_options=1 broker_module=/usr/local/globle/softs/monitor/nagios/ndoutils/2.1.3/bin/ndomod-4x.o config_file=/usr/local/globle/softs/monitor/nagios/ndoutils/2.1.3/etc/ ndomod.cfg
在/usr/local/globle/softs/monitor/nagios/ndoutils/2.1.3/etc/
下,ndomod.cfg为NDOMOD模块配置文件,该文件不用修改便可使用。修改ndo2db.cfg配置文件内容:
db_user=nagios db_pass=liwanliang
注:这里的db_user和db_pass是建立nagios数据库时的数据库用户和密码
由于在configure的过程当中,已经指定了NDO2DB采用sysv模式启动进程,所以能够经过service ndo2db start
启动服务
经过ps -ef | grep ndo
,能够查看到进程已经运行启动,经过lsof -p pid
命令,查看到进程打开了sock文件。
注意:此时若是没有重启或者从新加载nagios配置,那么数据库不会存在数据
若是已经重启了nagios,可是经过数据库可视化工具未发现数据更新,能够断开链接,而后从新登录数据库查看
经过数据库可视化工具,链接到MySQL查看nagios数据库是否存在数据 确认配置信息,对象配置,报警信息等均可以正常存储