• Nagios数据存储插件NDOUtils部署和测试


    1. 概述

    NDOUTILS,Nagios Data Output Utils,Nagios数据输出工具,允许用户从Nagios导出状态和事件信息到数据库中,便于以后的检索和加工
    它包括几个部分:

    • NDOMOD
    • NDO2DB
    • FILE2SOCK
    • LOG2NDO

    2. 组件介绍

    2.1 NDOMOD

    NDOMOD是事件中断模块。这个模块在Nagios进程运行时加载。
    它唯一的角色就是转存Nagios所有事件和数据到TCP套接字,或者普通文件,或者Unix域套接字。
    如果用户想实时转发数据至MySQL,可以通过转存数据至TCP套接字或者Unix域套接字。如果想延迟转发数据至MySQL数据库,可以通过转存数据至普通文件。

    2.2 NDO2DB

    NDO2DB守护进程。这是一个标准的守护进程,从TCP套接字或者Unix套接字读取输入数据(通过NDOMOD事件中断模块输出)。
    NDO2DB分析这些数据,并把他们存入一个或者多个MySQL数据中。NDO2DB具有同时处理多个客户端的连接的能力,因此用户同时可以配置多个通过TCP或者Unix套接字输出数据的NDOMOD模块实例。

    2.3 FILE2SOCK

    FILE2SOCK特性从普通的文件读取数据,将其通过TCP或者Unix套接字转存。
    这在NDOMOD模块将数据写入普通文件时,但希望将其转存至数据库的使用场景非常有用。
    如果NDOMOD模块输出的数据和NDO2DB运行进程不在同一台主机上时,用户可以通过SSH协议转发存放数据的普通文件至运行NDO2DB进程的主机上,然后通过FILE2SOCK特性转发普通文件的内容至TCP或者Unix端口(NDO2DB从这些端口中获取数据)

    2.4 LOG2NDO

    LOG2NDO特性用于将Nagios和NetSaint的历史日志归档并转发给NDO2DB进程。同样也是将一个日志文件发送至TCP或者Unix套接字完成数据转存。

    3. 编译安装

    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 all

    [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-3xmake install-2x,但是会替代。
    本篇博客编译全部模块,然后都拷贝到对应的目录下,在配置文件中指定要采用的模块的绝对路径。

    注:在当前解压目录下,无法执行make install-3x,无makefile

    截至到这里,NDOUtils已经编译安装完成。
    安装database
    这一步需要首先创建一个数据库并授权。

    本篇略此过程,具体参阅博客《MySQL数据库服务器(YUM)安装.md》,博客园地址:https://www.cnblogs.com/liwanliangblog/p/9194704.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/下,能看到三个目录,即:

    • bin目录,存放ndomod.o,ndo2db,log2ndo,file2sock,sockdebug程序或者库
    • etc目录,存放ndo2db.cfg-sample配置模板和ndomod.cfg-sample配置模板
    • var目录,可变数据存放目录

    4. Nagios配置NDOUtils

    4.1 拷贝配置文件

    /usr/local/globle/softs/monitor/nagios/ndoutils/2.1.3/etc/下,执行cp ndo2db.cfg-sample ndo2db.cfgcp ndomod.cfg-sample ndomod.cfg

    4.2 Nagios主配置文件修改

    修改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

    4.3 NDO2DB配置文件修改

    /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数据库时的数据库用户和密码

    4.4 启动

    因为在configure的过程中,已经指定了NDO2DB采用sysv模式启动进程,因此可以通过service ndo2db start启动服务
    通过ps -ef | grep ndo,可以查看到进程已经运行启动,通过lsof -p pid命令,查看到进程打开了sock文件。
    注意:此时如果没有重启或者重新加载nagios配置,那么数据库不会存在数据
    如果已经重启了nagios,但是通过数据库可视化工具未发现数据更新,可以断开连接,然后重新登陆数据库查看

    4.5 查看

    4.5.1 数据库查看

    通过数据库可视化工具,连接到MySQL查看nagios数据库是否存在数据
    确认配置信息,对象配置,报警信息等均能够正常存储

  • 相关阅读:
    获取指定扩展名的文件 分类: python 小练习 20130514 16:06 229人阅读 评论(0) 收藏
    #遍历E盘下的mp3文件 分类: python 小练习 python 20130514 18:27 303人阅读 评论(0) 收藏
    🍖Linux输出重定向
    🍖手动添加用户
    🍗文件权限管理
    🍖文件管理之打包压缩
    🍖文件处理三剑客:sed awk grep
    🍖权限管理之用户与用户组
    🍖文件管理之字符处理 sort uniq cut tr wc
    🍖文件处理之上传下载
  • 原文地址:https://www.cnblogs.com/liwanliangblog/p/9278872.html
Copyright © 2020-2023  润新知