My linux world » Nagios / NDOutils

Nagios / NDOutils


Centreon can link with multiple Nagios.
They speak throw NDOutils.
The following configuration shows how to configure Nagios and NDOutils to communicate with a local Centreon.

Contents

Nagios

Prerequiste

I assume that you have a Centos installation.

Installation

You can copy/paste this script and use it to configure automatically your server.

  1. #!/bin/bash
  2.  
  3. echo "install tools nagios"
  4. dnf -y install nagios nagios-devel nagios-plugins*
  5.  
  6. echo "enable start nagios on boot"
  7. systemctl enable nagios.service
  8.  
  9. echo "set config owner"
  10. chown nagios:nagios /etc/nagios/ -R
  11. service nagios reload
  12.  
  13. echo "check_http get a 403 'forbidden' if index.html is missing. so we create it"
  14. touch /var/www/html/index.html
  15.  
  16. myip=`hostname -I`
  17. echo "Now meet you here: http://$myip/nagios/"
  18. echo "Note, login/passord is nagiosadmin/nagiosadmin"
  19.  

That’s all 🙂
Administration – Nagios

NDOutils

Install NDOutils:

  1. #!/bin/bash
  2.  
  3. dnf -y install ndoutils ndoutils-mysql
  4.  
  5. echo "update /etc/nagios/ndomod.cfg"
  6. sed -i "s/^\(instance_name=\).*/\1Central/g" /etc/nagios/ndomod.cfg
  7. sed -i "s/^\(output_type=\).*/\1tcpsocket/g" /etc/nagios/ndomod.cfg
  8. sed -i "s/^\(output=\).*/\1localhost/g" /etc/nagios/ndomod.cfg
  9. sed -i "s/^\(tcp_port=\).*/\15668/g" /etc/nagios/ndomod.cfg
  10. sed -i "s/^\(output_buffer_items=\).*/\15000/g" /etc/nagios/ndomod.cfg
  11.  
  12. echo "update /etc/nagios/ndo2db.cfg"
  13. ln -s /var/run/ndoutils/ndoutils.sock /var/run/ndo.sock
  14. sed -i "s/^\(ndo2db_user=\).*/\1nagios/g" /etc/nagios/ndo2db.cfg
  15. sed -i "s/^\(ndo2db_group=\).*/\1nagios/g" /etc/nagios/ndo2db.cfg
  16.  
  17. sed -i "s/^\(socket_type=\).*/\1tcp/g" /etc/nagios/ndo2db.cfg
  18. sed -i "s/^\(socket_name=\).*/\1\/var\/run\/ndo.sock/g" /etc/nagios/ndo2db.cfg
  19. sed -i "s/^\(tcp_port=\).*/\15668/g" /etc/nagios/ndo2db.cfg
  20.  
  21. sed -i "s/^\(db_servertype=\).*/\1mysql/g" /etc/nagios/ndo2db.cfg
  22. sed -i "s/^\(db_host=\).*/\1localhost/g" /etc/nagios/ndo2db.cfg
  23. sed -i "s/^\(db_port=\).*/\13306/g" /etc/nagios/ndo2db.cfg
  24. sed -i "s/^\(db_name=\).*/\1centreon_status/g" /etc/nagios/ndo2db.cfg
  25. sed -i "s/^\(db_prefix=\).*/\1nagios_/g" /etc/nagios/ndo2db.cfg
  26. sed -i "s/^\(db_user=\).*/\1centreon/g" /etc/nagios/ndo2db.cfg
  27. sed -i "s/^\(db_pass=\).*/\1centreon/g" /etc/nagios/ndo2db.cfg
  28.  
  29. echo "update /etc/nagios/nagios.cfg"
  30. sed -i "s/event_broker_options=-1/event_broker_options=-1/g" /etc/nagios/nagios.cfg
  31. sed -i "s/#broker_module=\/somewhere\/module1.o/broker_module=\/usr\/lib64\/nagios\/brokers\/ndomod.so config_file=\/etc\/nagios\/ndomod.cfg/g" /etc/nagios/nagios.cfg
  32.  
  33. chown nagios:nagios /etc/nagios/ -R
  34.  
  35. echo "activate ndo2db at startup and start it"
  36. systemctl enable ndo2db.service
  37. systemctl stop ndo2db.service
  38. systemctl start ndo2db.service
  39.  
  40. systemctl restart nagios.service
  41.  

Link with centreon

In /etc/nagios/ndomod.cfg, check you have theses parameters

instance_name=Central
output_type=tcpsocket
output=localhost
tcp_port=5668
output_buffer_items=5000

And check you have the same values in Centreon : Configuration -> Centreon -> ndomod.cfg

In /etc/nagios/ndo2db.cfg, check you have theses parameters

ndo2db_user=nagios
ndo2db_group=nagios
 
socket_type=tcp
socket_name=/var/run/ndo.sock
tcp_port=5668
 
db_servertype=mysql
db_host=localhost
db_name=centreon_status
db_port=3306
db_prefix=nagios_
db_user=centreon
db_pass=centreon

And check you have the same values in Centreon : Configuration -> Centreon -> ndo2db.cfg

In /etc/nagios/nagios.cfg, configure blockers:

event_broker_options=-1
broker_module=/usr/lib64/nagios/brokers/ndomod.so config_file=/etc/nagios/ndomod.cfg

And check you have the same values in Centreon : Configuration -> Monitoring Engines -> main.cfg (tab Data)

Now restart services:

/etc/init.d/ndo2db start
/etc/init.d/nagios restart

Troubleshooting

ndomod: Still unable to reconnect to data sink

ndo2db process do not manage to access to ndo2db.cgf file. Execute the following command:

chown apache:apache /etc/nagios/ -R

Copyright © 2023 My linux world - by Marc RABAHI
Design by Marc RABAHI and encelades.

Fork me on GitHub