官方的一些简介:
NDOUtils est un addon pour . Il permet de stocker dans une base de données ou dans un fichier plat :
· La configuration des serveurs supervisés
· Les évènements
· Les états des éléments supervisés
ndoutils软件主要是用于将Naigos数据存数据库,然后又可读取出来.
下载地址:
- # wget
- # tar zxvf ndoutils-1.5.2.tar.gz //以下是源码安装
- # cd ndoutils-1.5.2
- #./configure --with-mysql-inc=/usr/local/mysql/include/ --with-mysql-lib=/usr/local/mysql/lib/ --with-mysql=/usr/local/mysql/ --enable-mysql --disable-pgsql --with-ndo2db-user=nagios --with-ndo2db-group=nagios
- # make
手动将一些二进制文件和库文件copy到nagios目录
- # cp ./src/ndomod-3x.o /usr/local/nagios/bin/
- # 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*
创建或修改启动脚本,软件包里的脚本停止服务有些问题,修改下:
- #cp ./daemon-init /etc/init.d/ndo2db
- #chmod 775 /etc/init.d/ndo2db
- # chkconfig --add ndo2db
- # chkconfig --level 35 ndo2db on
- //创建数据库且导入库内容
- mysql> create database nagios;
- ./installdb -u root -p -h localhost -d nagios
- 或者:
- # cd ndoutils-1.5.2/db
- # mysql -uroot -p nagios<./mysql.sql
安装ndoutils-1.4b9时报以下错
# ./configure --enable-mysql --with-mysql=/usr/local/mysql
# make
cd ./src && make
make[1]: Entering directory `/root/nagiosddd/ndoutils-1.4b9/src'
gcc -fPIC -g -O2 -I/usr/local/mysql/include/mysql -DHAVE_CONFIG_H -c -o io.o io.c
In file included from io.c:11:
../include/config.h:261:25: error: mysql/mysql.h: No such file or directory
../include/config.h:262:26: error: mysql/errmsg.h: No such file or directory
make[1]: *** [io.o] Error 1
make[1]: Leaving directory `/root/nagiosddd/ndoutils-1.4b9/src'
make: *** [all] Error 2
解决方法
# vi include/config.h
将
#include
#include
修改为
#include
#include /errmsg.h>
配置
# vim /usr/local/nagios/etc/nagios.cfg
# 复制下面内容粘贴到#broker_module=...下面。
broker_module=/usr/local/nagios/bin/ndomod-3x.o config_file=/usr/local/nagios/etc/ndomod.cfg
此外,请确保您的/usr/local/nagios/etc/nagios.cfg中有如下行出现,否则,请自行添加:
event_broker_options=-1 //为Nagios开启event broker
备注:以上内容是一行连接的,中间使用空格隔开的
授权数据库帐号:
mysql> grant all privileges on nagios.* to 'ndouser'@'localhost' identified by '123456';
配置数据库连接信息:
- # vim /usr/local/nagios/etc/ndo2db.cfg
- socket_type=tcp
- #socket_name=/usr/local/nagios/var/ndo.sock
- db_user=ndouser
- db_pass=123456
- # vim /usr/local/nagios/etc/ndomod.cfg
- output=127.0.0.1
- #output=/usr/local/nagios/var/ndo.sock
- output_type=tcpsocket
- #output=/usr/local/nagios/var/ndo.sock
- //测试启动否
- # /etc/init.d/ndo2db start
或者如下测试:
# /usr/local/nagios/bin/ndo2db-3x -c /usr/local/nagios/etc/ndo2db.cfg
# netstat -antup |grep 5668 //查看端口是否打开
tcp 0 0 0.0.0.0:5668 0.0.0.0:* LISTEN 28099/ndo2db-3x
#service nagios restart
如果报错:
[1353555768] ndomod: NDOMOD 1.5.2 (06-08-2012) Copyright (c) 2009 Nagios Core Development Team and Community Contributors
[1353555768] ndomod: Could not open data sink! I'll keep trying, but some output may get lost...
[1353555768] Event broker module '/usr/local/nagios/bin/ndomod-3x.o' initialized successfully.
[1353555768] Finished daemonizing... (New PID=30920)
解决方法:
检查 /nagios/etc目录的权限是否足够的大
确保/usr/local/nagios/etc/nagios.cfg中有如下行出现,否则,请自行添加:
event_broker_options=-1
检查ndo2db.cfg中的配置,确保使用tcp连接
socket_type=tcp
检查ndomod.cfg中的配置,确保使用tcp套接字
output_type=tcpsocket
NDO to PNP
可以查看官网资料:
The aim of this script is to import your ndo database directly into PNP4nagios. To do so, we use an exporter (ndo2pnp.pl) that can connect throught MySQL database and export contents into the same format as perfdata expected from nagios. Then we plug this into pnp4nagios using bulk option.
脚本地址:
#cd /usr/local/nagios/libexec/
#chmod +x ndo2pnp.pl
详细使用参数:
- $ ./ndo2pnp.pl --help
- Usage :
- -h --help Display this message.
- --version Display version then exit.
- -v --verbose Verbose run.
- -u --user
Log on to database with (default root). - -p --pass
Use to logon (default gbu2kfe). - -t --type
Change database type (default mysql). - --host
Use (default localhost). - --dbname
Use for ndo database name (default ndoutils). - --list-machine Display machine definition in ndo database.
- --list-service Show services defined.
- --export-as-pnp Export ndo content as a bulk file used by process_perfdata.pl
显示列表:
- $./ndo2pnp.pl --user
-p --list-service - Hostname | Service
- -------------------------------+-------------------
- gateway | PING
- localhost | Current Load
- localhost | Current Users
- localhost | Disk Space
- localhost | HTTP
- localhost | SSH
- localhost | Total Processes
$ ./ndo2pnp.pl --user
测试结果:
- /usr/local/nagios/libexec/ndo2pnp.pl --host 127.0.0.1 -u ndouser -p 123456 --dbname nagios --list-service
- Hostname | Service
- -------------------------------+-------------------
- 192.168.15.178 | CPU
- 192.168.15.178 | Current Load
- 192.168.15.178 | Current Users
- 192.168.15.178 | HTTP
- 192.168.15.178 | PING
- 192.168.15.178 | Qcache_free
- 192.168.15.178 | Root Partition
- 192.168.15.178 | SSH
- 192.168.15.178 | system swap
- 192.168.15.178 | Total Processes
- localhost | CPU