ndo2db don't write anything to datadase

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
adengin
Posts: 15
Joined: Tue Feb 03, 2015 7:51 am
Location: Petrozavodsk, Russia

ndo2db don't write anything to datadase

Post by adengin »

Hello, guys!
I have been using Nagios 4.0.8 for a some time. Recently I have to install NDOUtils 2.0 to save all nagios data in database.
It have been installed without any errors. But ndo2db don't fill the database.

In the Nagios Log i see that NDOMOD starts properly:

Code: Select all

[1427869955] ndomod: NDOMOD 2.0.0 (02-28-2014) Copyright (c) 2009 Nagios Core Development Team and Community Contributors
[1427869955] ndomod: Successfully connected to data sink.  0 queued items to flush.
[1427869955] ndomod registered for process data
[1427869955] ndomod registered for timed event data
[1427869955] ndomod registered for log data'
[1427869955] ndomod registered for system command data'
[1427869955] ndomod registered for event handler data'
[1427869955] ndomod registered for notification data'
[1427869955] ndomod registered for service check data'
[1427869955] ndomod registered for host check data'
[1427869955] ndomod registered for comment data'
[1427869955] ndomod registered for downtime data'
[1427869955] ndomod registered for flapping data'
[1427869955] ndomod registered for program status data'
[1427869955] ndomod registered for host status data'
[1427869955] ndomod registered for service status data'
[1427869955] ndomod registered for adaptive program data'
[1427869955] ndomod registered for adaptive host data'
[1427869955] ndomod registered for adaptive service data'
[1427869955] ndomod registered for external command data'
[1427869955] ndomod registered for aggregated status data'
[1427869955] ndomod registered for retention data'
[1427869955] ndomod registered for contact data'
[1427869955] ndomod registered for contact notification data'
[1427869955] ndomod registered for acknowledgement data'
[1427869955] ndomod registered for contact status data'
[1427869955] ndomod registered for adaptive contact data'
[1427869955] Event broker module '/usr/local/nagios/bin/ndomod-4x.o' initialized successfully.
[1427869955] Successfully launched command file worker with pid 7527
[1427870144] ndomod: Error writing to data sink!  Some output may get lost...
[1427870144] ndomod: Please check remote ndo2db log, database connection or SSL Parameters
[1427870160] ndomod: Successfully reconnected to data sink!  0 items lost, 69 queued items to flush.
[1427870160] ndomod: Successfully flushed 69 queued items to data sink.
ndo2db is working:

Code: Select all

root@nagios:~# ps aux | grep -v grep | grep "ndo2db"
nagios    7656  0.0  0.0   6848   528 ?        Ss   09:35   0:00 /usr/local/nagios/bin/ndo2db -c /usr/local/nagios/etc/ndo2db.cfg
mysql is also working and i can connect to the nagios database with nagios credentials, but all tables is empty:

Code: Select all

root@nagios:~# mysql -u nagios -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 112
Server version: 5.5.41-0+wheezy1-log (Debian)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use nagios;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> SHOW GRANTS FOR nagios@localhost;
+---------------------------------------------------------------------------------------------------------------+
| Grants for nagios@localhost                                                                                   |
+---------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'nagios'@'localhost' IDENTIFIED BY PASSWORD '****************************' |
| GRANT ALL PRIVILEGES ON `nagios`.* TO 'nagios'@'localhost'                                                    |
+---------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

mysql> select * from nagios_instances;
Empty set (0.01 sec)
Here is my versions:
Linux version 3.2.0-4-686-pae (debian-kernel@lists.debian.org) (gcc version 4.6.3 (Debian 4.6.3-14) ) #1 SMP Debian 3.2.65-1+deb7u1
nagios-4.0.8
ndoutils-2.0.0
mysql-server 5.5.41-0
libmysqlclient-dev 5.5.41

Here is my config files:

nagios.cfg:

Code: Select all

event_broker_options=-1
broker_module=/usr/local/nagios/bin/ndomod-4x.o config_file=/usr/local/nagios/etc/ndomod.cfg
ndomod.cfg:

Code: Select all

instance_name=default
output_type=tcpsocket
output=127.0.0.1
tcp_port=5668
use_ssl=0
output_buffer_items=5000
buffer_file=/usr/local/nagios/var/ndomod.tmp
file_rotation_interval=14400
file_rotation_timeout=60
reconnect_interval=15
reconnect_warning_interval=15
acknowledgement_data=1
adaptive_contact_data=1
adaptive_host_data=1
adaptive_program_data=1
adaptive_service_data=1
aggregated_status_data=1
comment_data=1
contact_status_data=1
downtime_data=1
event_handler_data=1
external_command_data=1
flapping_data=1
host_check_data=1
host_status_data=1
log_data=1
main_config_data=1
notification_data=1
object_config_data=0
process_data=1
program_status_data=1
retention_data=1
service_check_data=1
service_status_data=1
statechange_data=1
system_command_data=1
timed_event_data=1
config_output_options=1
ndo2db.cfg:

Code: Select all

lock_file=/usr/local/nagios/var/ndo2db.lock
ndo2db_user=nagios
ndo2db_group=*****
socket_type=tcp
tcp_port=5668
use_ssl=0
db_servertype=mysql
db_host=127.0.0.1
db_port=3306
db_name=nagios
db_prefix=nagios_
db_user=nagios
db_pass=******
max_timedevents_age=1440
max_systemcommands_age=10080
max_servicechecks_age=10080
max_hostchecks_age=10080
max_eventhandlers_age=44640
max_externalcommands_age=44640
max_notifications_age=44640
max_contactnotifications=44640
max_contactnotificationmethods=44640
max_logentries_age=129600
max_acknowledgements_age=44640
debug_level=-1
debug_verbosity=2
debug_file=/usr/local/nagios/var/ndo2db.debug
max_debug_file_size=1000000
Also I want to add that ndo2db.debug file is empty.
If i start tcpdump i see a traffic flow in tcp:5668 socket, but nothing in tcp:3306 socket.

Here is the file permissions:

Code: Select all

root@nagios:~# ls -ls /usr/local/nagios/etc/
total 88
12 -rw-rw-r-- 1 nagios nagios 11945 Feb 13 12:26 cgi.cfg
 4 -rw-r--r-- 1 nagios nagcmd    50 Feb  2 17:22 htpasswd.users
48 -rw-rw-r-- 1 nagios nagios 45222 Mar 31 16:37 nagios.cfg
 8 -rwxrwxrwx 1 nagios nagios  4829 Apr  1 09:31 ndo2db.cfg
 8 -rw------- 1 nagios nagios  5104 Mar 31 20:15 ndomod.cfg
 4 drwxrwsr-x 2 nagios nagios  4096 Mar 31 20:17 objects
 4 -rw-rw---- 1 nagios nagios  1312 Feb  2 17:19 resource.cfg
root@nagios:~# ls -ls /usr/local/nagios/var/
total 1164
  4 drwxrwsr-x 2 nagios nagios   4096 Mar 31 23:59 archives
  4 -rw-r--r-- 1 nagios nagios   1527 Apr  1 09:32 nagios.configtest
  4 -rw-r--r-- 1 nagios nagios      5 Apr  1 09:32 nagios.lock
 40 -rw-r--r-- 1 nagios nagios  40193 Apr  1 09:51 nagios.log
  0 -rwxrwxrwx 1 nagios nagios      0 Mar 31 14:52 ndo2db.debug
  4 -rw-r--r-- 1 nagios nagios      5 Apr  1 09:35 ndo2db.lock
  4 -rw-r--r-- 1 nagios nagios      6 Mar 31 20:13 ndo2db.run
  0 -rw-r--r-- 1 nagios nagios      0 Apr  1 09:32 ndomod.tmp
212 -rw-r--r-- 1 nagios nagios 214522 Apr  1 09:32 objects.cache
212 -rw-r--r-- 1 nagios nagios 214522 Apr  1 09:32 objects.precache
336 -rw------- 1 nagios nagios 343342 Apr  1 09:32 retention.dat
  4 drwxrwsr-x 2 nagios nagcmd   4096 Apr  1 09:32 rw
  4 drwxrwsr-x 3 root   nagios   4096 Feb  2 17:19 spool
336 -rw-rw-r-- 1 nagios nagios 342232 Apr  1 09:53 status.dat
root@nagios:~# ls -la /usr/local/nagios/bin/
total 1612
drwxrwsr-x  2 nagios nagios   4096 Mar 31 17:45 .
drwxr-sr-x 11 root   staff    4096 Mar 25 17:18 ..
-rwxrwxr--  1 nagios nagios  38295 Mar 31 17:45 file2sock
-rwxrwxr--  1 nagios nagios  40359 Mar 31 17:45 log2ndo
-rwxrwxr--  1 nagios nagios 684440 Mar 23 12:14 nagios
-rwxrwxr--  1 nagios nagios  36876 Mar 23 12:14 nagiostats
-rwxr-xr-x  1 nagios nagios 276780 Mar 31 17:45 ndo2db
-rwxr-xr-x  1 nagios nagios 180239 Mar 30 18:16 ndomod-4x.o
-rwxr-xr-x  1 nagios nagios 180239 Mar 31 17:45 ndomod.o
-rwxrwxr-x  1 nagios nagios 143564 Mar  4 16:19 nrpe
-rwxrwxr--  1 nagios nagios  35383 Mar 31 17:45 sockdebug
I have no idea what to do next and how to solve this problem.
I would be grateful for any help!
Thank you!
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: ndo2db don't write anything to datadase

Post by jdalrymple »

Any reason you're using:

Code: Select all

socket_type=tcp
instead of

Code: Select all

socket_type=unix
And if so - is mysql definitely listening on 3306?

Code: Select all

[jdalrymple@localhost etc]$ netstat -an | grep 3306
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN
adengin
Posts: 15
Joined: Tue Feb 03, 2015 7:51 am
Location: Petrozavodsk, Russia

Re: ndo2db don't write anything to datadase

Post by adengin »

jdalrymple, thank you for your reply!
The reason i'm using tcp socket is just a test. I didn't know how to capture data flow in unix socket, so i decided to switch it to tcp. So I made sure that the ndomod transmits data to the ndo2db.
Mysql is working on tcp:3306

Code: Select all

root@nagios:~# netstat -apn | grep 3306
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      2864/mysqld
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: ndo2db don't write anything to datadase

Post by jdalrymple »

It's a reach, but let's make sure that you can connect using mysql client to the TCP port:

Code: Select all

[jdalrymple@localhost ~]$ echo "SHOW GRANTS;"  | mysql -u ndoutils -pPASSWORD nagios  --protocol=tcp --host=127.0.0.1 --port=3306
Grants for ndoutils@localhost
GRANT USAGE ON *.* TO 'ndoutils'@'localhost' IDENTIFIED BY PASSWORD 'XXXX'
GRANT ALL PRIVILEGES ON `nagios`.* TO 'ndoutils'@'localhost' WITH GRANT OPTION
Of course you'll have nagios where I have ndoutils.
adengin
Posts: 15
Joined: Tue Feb 03, 2015 7:51 am
Location: Petrozavodsk, Russia

Re: ndo2db don't write anything to datadase

Post by adengin »

jdalrymple, sure!

Code: Select all

root@nagios:~# echo "SHOW GRANTS;"  | mysql -u nagios -p************** nagios  --protocol=tcp --host=127.0.0.1 --port=3306
Grants for nagios@localhost
GRANT USAGE ON *.* TO 'nagios'@'localhost' IDENTIFIED BY PASSWORD '*82802C50A7A5CDFDEA2653A1503FC4B8939C4047'
GRANT ALL PRIVILEGES ON `nagios`.* TO 'nagios'@'localhost'
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: ndo2db don't write anything to datadase

Post by tgriep »

In your ndomod.cfg file, add the following to it

Code: Select all

data_processing_options=-1
Change

Code: Select all

config_output_options=1
to

Code: Select all

config_output_options=2
Restart Nagios and see if the data populates the MYSQL database.
Be sure to check out our Knowledgebase for helpful articles and solutions!
adengin
Posts: 15
Joined: Tue Feb 03, 2015 7:51 am
Location: Petrozavodsk, Russia

Re: ndo2db don't write anything to datadase

Post by adengin »

tgriep, thank you for reply!
I have been done it, but the database is still empty. ndo2db.debug is empty too.

Code: Select all

root@nagios:/usr/local/nagios/etc# grep data_processing_options ndomod.cfg
data_processing_options=-1
root@nagios:/usr/local/nagios/etc# grep config_output_options ndomod.cfg
config_output_options=2

Code: Select all

[1428009242] ndomod: NDOMOD 2.0.0 (02-28-2014) Copyright (c) 2009 Nagios Core Development Team and Community Contributors
[1428009242] ndomod: Successfully connected to data sink.  0 queued items to flush.
[1428009242] ndomod registered for timed event data
[1428009242] ndomod registered for log data'
[1428009242] ndomod registered for system command data'
[1428009242] ndomod registered for event handler data'
[1428009242] ndomod registered for notification data'
[1428009242] ndomod registered for service check data'
[1428009242] ndomod registered for host check data'
[1428009242] ndomod registered for comment data'
[1428009242] ndomod registered for downtime data'
[1428009242] ndomod registered for flapping data'
[1428009242] ndomod registered for program status data'
[1428009242] ndomod registered for host status data'
[1428009242] ndomod registered for service status data'
[1428009242] ndomod registered for adaptive program data'
[1428009242] ndomod registered for adaptive host data'
[1428009242] ndomod registered for adaptive service data'
[1428009242] ndomod registered for external command data'
[1428009242] ndomod registered for aggregated status data'
[1428009242] ndomod registered for retention data'
[1428009242] ndomod registered for contact data'
[1428009242] ndomod registered for contact notification data'
[1428009242] ndomod registered for acknowledgement data'
[1428009242] ndomod registered for contact status data'
[1428009242] ndomod registered for adaptive contact data'
[1428009242] Event broker module '/usr/local/nagios/bin/ndomod-4x.o' initialized successfully.

Code: Select all

mysql> select * from nagios_instances;
Empty set (0.00 sec)
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: ndo2db don't write anything to datadase

Post by jdalrymple »

In your post above it looked like 69 items got queued then flushed and nothing showed up - and that was weird.

Code: Select all

[1427869955] Event broker module '/usr/local/nagios/bin/ndomod-4x.o' initialized successfully.
[1427869955] Successfully launched command file worker with pid 7527
[1427870144] ndomod: Error writing to data sink!  Some output may get lost...
[1427870144] ndomod: Please check remote ndo2db log, database connection or SSL Parameters
[1427870160] ndomod: Successfully reconnected to data sink!  0 items lost, 69 queued items to flush.
[1427870160] ndomod: Successfully flushed 69 queued items to data sink.
Now things appear different in that it appears nothing is queued?

Code: Select all

[1428009242] ndomod: NDOMOD 2.0.0 (02-28-2014) Copyright (c) 2009 Nagios Core Development Team and Community Contributors
[1428009242] ndomod: Successfully connected to data sink.  0 queued items to flush.
Anything going on with Nagios - is it running?
adengin
Posts: 15
Joined: Tue Feb 03, 2015 7:51 am
Location: Petrozavodsk, Russia

Re: ndo2db don't write anything to datadase

Post by adengin »

Any other ideas?
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: ndo2db don't write anything to datadase

Post by ssax »

Please post the output of the following commands:

Code: Select all

ls -l /usr/local/nagios/bin/ndo*
ls -l /usr/local/nagios/etc/nd*
service nagios restart
Then post the last 100 or so lines of your /usr/local/nagios/var/nagios.log file (in code tags).
Locked