https://monitoring-portal.org/index.php?thread/29283-omd-ndo2db/
Hướng dẫn đẩy dữ liệu từ OMD ra MySQL.
-
Cài đặt MariaDB :
yum install -y mariadb mariadb-server mariadb-devel
-
Các gói dịch vụ đi kèm :
yum install gcc glibc glibc-common gd gd-devel make net-snmp openssl-devel xinetd unzip httpd php php-fpm curl wget -y
-
Khởi động MariaDB :
systemctl start mariadb.service
-
Cấu hình tự khởi động cùng hệ thống :
systemctl enable mariadb.service
-
Cấu hình mật khẩu cho MariaDB :
/usr/bin/mysqladmin -u root password 'mypassword'
-
Tạo một cơ sở dữ liệu mới với tên là
nagios
:CREATE DATABASE nagios DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
-
Tajo user
monitoring
:CREATE USER 'monitoring'@'localhost' IDENTIFIED BY 'mypass';
-
Gán quyền cho user trong CSDL đó :
grant all privileges on nagios.* to 'monitoring'@localhost identified by "mypass" with grant option;
-
Nếu lỡ tay coppy toàn bộ dòng trên, thay đổi lại mật khẩu cho user vừa tạo như sau :
use mysql; set password for 'monitoring'@localhost = PASSWORD('mypass'); # mypass là password muốn đặt cho user đó. flush privileges;
-
Download bản
ndo2db
v1.5.2 :cd /tmp wget http://downloads.sourceforge.net/project/nagios/ndoutils-1.x/ndoutils-1.5.2/ndoutils-1.5.2.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fnagios%2Ffiles%2Fndoutils-1.x%2Fndoutils-1.5.2%2F&ts=1379408959&use_mirror=heanet
-
Giải nén :
tar xvf ndoutils-1.5.2.tar.gz
-
Tiến hành cài đặt :
cd ndoutils-1.5.2 ./configure --prefix=/omd/sites/monitoring/usr/local/nagios/ --enable-mysql --disable-pgsql --with-ndo2db-user=monitoring -with-ndo2db-group=monitoring --with-mysql-lib=/usr/lib/mysql
-
complie :
make make all make install-config cd /src /usr/bin/install -c -m 775 -o monitoring -g monitoring -d /omd/sites/monitoring/usr/local/nagios/bin /usr/bin/install -c -m 755 -o monitoring -g monitoring ndo2db-3x /omd/sites/monitoring/usr/local/nagios/bin/ndo2db /usr/bin/install -c -m 755 -o monitoring -g monitoring ndomod-3x.o /omd/sites/monitoring/usr/local/nagios/bin/ndomod.o /usr/bin/install -c -m 774 -o monitoring -g monitoring file2sock /omd/sites/monitoring/usr/local/nagios/bin /usr/bin/install -c -m 774 -o monitoring -g monitoring log2ndo /omd/sites/monitoring/usr/local/nagios/bin /usr/bin/install -c -m 774 -o monitoring -g monitoring sockdebug /omd/sites/monitoring/usr/local/nagios/bin
-
Initialize Database :
cd /db ./installdb -u monitoring -p mypass -h localhost -d nagios
-
Tạo các thư mục sau :
mkdir -p /omd/sites/monitoring/usr/local/nagios/var mkdir -p /omd/sites/monitoring/usr/local/nagios/bin
-
Coppy những file cấu hình đến những thư mục vừa tạo như sau :
cp /tmp/ndoutils-1.5.2/src/ndomod-3x.o /omd/sites/monitoring/usr/local/nagios/bin/ndomod.o cp /tmp/ndoutils-1.5.2/src/ndo2db-3x /omd/sites/monitoring/usr/local/nagios/bin/ndo2db
-
Coppy 2 file cấu hình sau :
cp /omd/sites/monitoring/usr/local/nagios/etc/ndo2db.cfg-sample /omd/sites/monitoring/usr/local/nagios/etc/ndo2db.cfg cp /omd/sites/monitoring/usr/local/nagios/etc/ndomod.cfg-sample /omd/sites/monitoring/usr/local/nagios/etc/ndomod.cfg
-
Mở file cấu hình
ndo2db.cfg
:vi /omd/sites/monitoring/usr/local/nagios/etc/ndo2db.cfg
-
Tìm và sửa lại các thông tin cấu hình như sau :
db_user=monitoring db_pass=mypass
-
Install deamon-init :
/usr/bin/install -c -m 755 -o root -g root -d /etc/rc.d/init.d /usr/bin/install -c -m 755 -o root -g root daemon-init /etc/rc.d/init.d/ndo2db
-
Mở file
init-daemon ndo2db
:
vi /etc/init.d/ndo2db
-
Tìm và sửa các dòng sau với nội dung :
Ndo2dbUser=monitoring Ndo2dbGroup=monitoring
-
Enable và Start ndo2db :
systemctl enable ndo2db.service systemctl start ndo2db.service
-
Thực hiện commands sau để tạo
Broker Module
:printf "\n\n# NDOUtils Broker Module\n" >> /omd/sites/monitoring/etc/nagios/nagios.cfg printf "broker_module=/omd/sites/monitoring/usr/local/nagios/bin/ndomod.o config_file=/omd/sites/monitoring/usr/local/nagios/etc/ndomod.cfg\n" >> /omd/sites/monitoring/etc/nagios/nagios.cfg
-
Restart service :
omd restart systemctl restart ndo2db.service
-
Kiểm tra log từ
/omd/sites/monitoring/var/log/nagios.log
:Caught SIGTERM, shutting down... [1510494712] Successfully shutdown... (PID=11664) [1510494712] ndomod: Shutdown complete. [1510494712] Event broker module '/omd/sites/monitoring/usr/local/nagios/bin/ndomod.o' deinitialized successfully. [1510494712] npcdmod: If you don't like me, I will go out! Bye. [1510494712] Event broker module '/omd/sites/monitoring/lib/npcdmod.o' deinitialized successfully. [1510494712] livestatus: deinitializing [1510494712] livestatus: waiting for main to terminate... [1510494713] livestatus: waiting for client threads to terminate... [1510494713] livestatus: could not join thread main [1510494713] livestatus: main thread + 20 client threads have finished [1510494713] Event broker module '/omd/sites/monitoring/lib/mk-livestatus/livestatus.o' deinitialized successfully. [1510494715] Nagios 3.5.0 starting... (PID=12062) [1510494715] Local time is Sun Nov 12 20:51:55 ICT 2017 [1510494715] LOG VERSION: 2.0 [1510494715] ndomod: NDOMOD 1.5.2 (06-08-2012) Copyright (c) 2009 Nagios Core Development Team and Community Contributors [1510494715] ndomod: Could not open data sink! I'll keep trying, but some output may get lost... [1510494715] Event broker module '/omd/sites/monitoring/usr/local/nagios/bin/ndomod.o' initialized successfully. [1510494715] npcdmod: Copyright (c) 2008-2009 Hendrik Baecker ([email protected]) - http://www.pnp4nagios.org [1510494715] npcdmod: /omd/sites/monitoring/etc/pnp4nagios/npcd.cfg initialized [1510494715] npcdmod: spool_dir = '/omd/sites/monitoring/var/pnp4nagios/spool/'. [1510494715] npcdmod: perfdata file '/omd/sites/monitoring/var/pnp4nagios/perfdata.dump'. [1510494715] npcdmod: Ready to run to have some fun! [1510494715] Event broker module '/omd/sites/monitoring/lib/npcdmod.o' initialized successfully. [1510494715] livestatus: setting number of client threads to 20 [1510494715] livestatus: Check_MK Inventory directory '/omd/sites/monitoring/var/check_mk/inventory/' not existing! [1510494715] livestatus: fl_socket_path=[/omd/sites/monitoring/tmp/run/live], fl_mkeventd_socket_path=[/omd/sites/monitoring/tmp/run/mkeventd/status] [1510494715] livestatus: Livestatus 1.4.0p16 by Mathias Kettner. Socket: '/omd/sites/monitoring/tmp/run/live' [1510494715] livestatus: Please visit us at http://mathias-kettner.de/ [1510494715] livestatus: running on OMD site monitoring, cool. [1510494715] livestatus: opened UNIX socket at /omd/sites/monitoring/tmp/run/live [1510494715] livestatus: your event_broker_options are sufficient for livestatus.. [1510494715] livestatus: finished initialization, further log messages go to /omd/sites/monitoring/var/nagios/livestatus.log [1510494715] Event broker module '/omd/sites/monitoring/lib/mk-livestatus/livestatus.o' initialized successfully. [1510494715] Finished daemonizing... (New PID=12063) [1510494715] livestatus: TIMEPERIOD TRANSITION: 24X7;-1;1 [1510494715] livestatus: logging initial states [1510494715] INITIAL HOST STATE: Client1;UP;HARD;1;OK - 10.10.10.14: rta 0.391ms, lost 0% [1510494715] INITIAL SERVICE STATE: Client1;CPU load;OK;HARD;1;OK - 15 min load 0.05 [1510494715] INITIAL SERVICE STATE: Client1;CPU utilization;OK;HARD;1;OK - user: 0.2%, system: 0.2%, wait: 0.0%, steal: 0.0%, guest: 0.0%, total: 0.3% [1510494715] INITIAL SERVICE STATE: Client1;Check_MK;OK;HARD;1;OK - Agent version 1.4.0p16, execution time 0.1 sec [1510494715] INITIAL SERVICE STATE: Client1;Check_MK Discovery;OK;HARD;1;OK - no unmonitored services found, no vanished services found [1510494715] INITIAL SERVICE STATE: Client1;Disk IO SUMMARY;OK;HARD;1;OK - Utilization: 0.0%, Read: 0.00 B/s, Write: 0.00 B/s, Average Wait: 0.00 ms, Average Read Wait: 0.00 ms, Average Write Wait: 0.00 ms, Latency: 0.00 ms, Average Queue Length: 0.00 [1510494715] INITIAL SERVICE STATE: Client1;Filesystem /;OK;HARD;1;OK - 5.8% used (1011.25 MB of 16.99 GB), trend: -305.83 kB / 24 hours [1510494715] INITIAL SERVICE STATE: Client1;Filesystem /boot;OK;HARD;1;OK - 13.6% used (138.35 of 1014.00 MB), trend: 0.00 B / 24 hours [1510494715] INITIAL SERVICE STATE: Client1;Interface 2;OK;HARD;1;OK - [ens33] (up) MAC: 00:0C:29:A9:98:21, 1 Gbit/s, in: 0.00 B/s(0.0%), out: 0.00 B/s(0.0%) [1510494715] INITIAL SERVICE STATE: Client1;Interface 3;OK;HARD;1;OK - [ens37] (up) MAC: 00:0C:29:A9:98:2B, 1 Gbit/s, in: 77.36 B/s(0.0%), out: 435.25 B/s(0.0%) [1510494715] INITIAL SERVICE STATE: Client1;Kernel Context Switches;OK;HARD;1;OK - 18/s [1510494715] INITIAL SERVICE STATE: Client1;Kernel Major Page Faults;OK;HARD;1;OK - 0/s [1510494715] INITIAL SERVICE STATE: Client1;Kernel Process Creations;OK;HARD;1;OK - 1/s [1510494715] INITIAL SERVICE STATE: Client1;Memory;OK;HARD;1;OK - RAM used: 166.63 MB of 976.50 MB, Swap used: 0.00 B of 2.00 GB, Total virtual memory used: 166.63 MB of 2.95 GB (5.5%),
-
Kiểm tra thông tin dữ liệu được đẩy ra Bảng :
echo 'select * from nagios.nagios_logentries;' | mysql -u monitoring -p'mypass'