###########################
NDOUtils to Centreon Broker
###########################

Centreon Broker allows to store Engine events in a database like
NDOUtils. So it is possible to replace NDOUtils by Centreon Broker. This
document will explain how to modify them.

Prerequisites
=============

This migration is based on an architecture with one central and one
poller. The central is defined into Centreon by the name *central* and IP
*10.30.2.62*, the poller is defined by the name *poller* and IP
*10.30.2.30*. If we have more than one poller we need to repeat the
poller step. And if we have just one central, bypass the poller step. We
suppose we have a MySQL database on *10.30.2.62* with the user *centreon*
and the password *centreon*.

Centreon Broker is assumed to have been properly installed.

.. warning::
   When you change NDO to Centreon-Broker you loose your ack/downtimes
   history and the metrics name are now store into the database with
   their real name (no character replacement).

Add Centreon Broker informations
--------------------------------

Connect to the Centreon interface and go to *Configuration*.

.. image:: /_static/images/exploitation/conf_pollers_list.png
   :align: center

For each poller and the central, edit the *Centreon Broker* information.

.. image:: /_static/images/exploitation/conf_poller_broker_path.png
   :align: center

================================== ===========================================
Information                        Value
================================== ===========================================
Centreon Broker configuration path ``/etc/centreon-broker``
Centreon Broker modules path       ``/usr/share/centreon/lib/centreon-broker``
================================== ===========================================

Add Centreon Broker configurations
----------------------------------

Select *Centreon-Broker Configuration* to *Add* a new configuration.

.. image:: /_static/images/exploitation/conf_add_broker.png
   :align: center

CBD configuration
^^^^^^^^^^^^^^^^^

*Add* a new configuration and set the following information:

General
"""""""

Set the following information and keep the default value.

.. image:: /_static/images/exploitation/conf_add_broker_general.png
   :align: center

==================== ==================
Information          Value
==================== ==================
Name                 central-broker
Config file name     central-broker.xml
Requester            central
Event queue max size 100000
==================== ==================

Input
"""""

Add a *TCP - IPv4* input. Set the following information and keep the
default value.

.. image:: /_static/images/exploitation/conf_add_broker_input.png
   :align: center

====================== ====================
Information            Value
====================== ====================
Name                   central-broker-input
Connection port        5669
====================== ====================

Logger
""""""

Add a *Core - File* logger. Set the following information and keep the
default value.

.. image:: /_static/images/exploitation/conf_add_broker_logger.png
   :align: center

================== ===============================================
Information        Value
================== ===============================================
Name of the logger ``/var/log/centreon-broker/central-broker.log``
================== ===============================================

Output
""""""

Add a *SQL - Broker SQL Database* output. Set the following information
and keep the default value.

.. image:: /_static/images/exploitation/conf_add_broker_output_sql.png
   :align: center

============= =======================
Information   Value
============= =======================
Name          central-broker-sql
DB type       MySQL
Failover Name central-broker-failover
DB host       10.30.2.62
DB Port       3306
DB user       centreon
DB password   centreon
DB name       centreon_storage
============= =======================

Add a *file - File* output. Set the following information and keep the
default value.

.. image:: /_static/images/exploitation/conf_add_broker_output_sql_file.png
   :align: center

======================= ====================================================
Information             Value
======================= ====================================================
Name                    central-broker-failover
File path               ``/var/log/centreon-broker/central-broker.failover``
======================= ====================================================

CBMod central configuration
^^^^^^^^^^^^^^^^^^^^^^^^^^^

Add a new configuration and set the following information.

General
"""""""

Set the following information and keep the default value.

.. image:: /_static/images/exploitation/conf_add_cbmod_general.png
   :align: center

==================== ==================
Information          Value
==================== ==================
Name                 central-module
Config file name     central-module.xml
Requester            central
Event queue max size 100000
==================== ==================

Logger
""""""

Add a *Core - File* logger. Set the following information and keep the
default value.

.. image:: /_static/images/exploitation/conf_add_cbmod_logger.png
   :align: center

================== ===============================================
Information        Value
================== ===============================================
Name of the logger ``/var/log/centreon-broker/central-module.log``
================== ===============================================

Output
""""""

Add a *TCP - IPv4* output. Set the following information and keep the
default value.

.. image:: /_static/images/exploitation/conf_add_cbmod_output_tcp.png
   :align: center

======================= =======================
Information             Value
======================= =======================
Name                    central-module-output
Connection port         5669
Host to connect to      10.30.2.62
Failover Name           central-module-failover
======================= =======================

Add a *file - File* output. Set the following information and keep the
default value.

.. image:: /_static/images/exploitation/conf_add_cbmod_output_tcp_file.png
   :align: center

======================= ====================================================
Information             Value
======================= ====================================================
Name                    central-module-failover
File path               ``/var/log/centreon-broker/central-module.failover``
======================= ====================================================

CBMod poller configuration
^^^^^^^^^^^^^^^^^^^^^^^^^^

Add new configuration and set the following information.

General
"""""""

Set the following information and keep the default value.

.. image:: /_static/images/exploitation/conf_add_cbmod_poller_general.png
   :align: center

==================== =================
Information          Value
==================== =================
Name                 poller-module
Config file name     poller-module.xml
Requester            poller
Event queue max size 100000
==================== =================

Logger
""""""

Add a *Core - File* logger. Set the following information and keep the
default value.

.. image:: /_static/images/exploitation/conf_add_cbmod_poller_logger.png
   :align: center

================== ==============================================
Information        Value
================== ==============================================
Name of the logger ``/var/log/centreon-broker/poller-module.log``
================== ==============================================

Output
""""""

Add a *TCP - IPv4* output. Set the following information and keep the
default value.

.. image:: /_static/images/exploitation/conf_add_cbmod_poller_output_tcp.png
   :align: center

======================= ======================
Information             Value
======================= ======================
Name                    poller-module-output
Connection port         5669
Host to connect to      10.30.2.62
Failover Name           poller-module-failover
======================= ======================

Add a *file - File* output. Set the following information and keep the
default value.

.. image:: /_static/images/exploitation/conf_add_cbmod_poller_output_tcp_file.png
   :align: center

======================= ===================================================
Information             Value
======================= ===================================================
Name                    poller-module-failover
File path               ``/var/log/centreon-broker/poller-module.failover``
======================= ===================================================

Modify Engine configuration
---------------------------

Select the *Monitoring Engine Configuration*.

.. image:: /_static/images/exploitation/conf_modif_engine.png
   :align: center

Engine central configuration
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Select the *central* main configuration, go to the *Data* tab and
within the *Multiple Broker Module* section, delete the NDO module
line.

Now you must to *Add a new broker module*.

.. image:: /_static/images/exploitation/conf_modif_engine_broker.png
   :align: center

====================== ====================================================================
Information            Value
====================== ====================================================================
Multiple Broker Module ``/usr/lib/nagios/cbmod.so /etc/centreon-broker/central-module.xml``
====================== ====================================================================

Engine poller configuration
^^^^^^^^^^^^^^^^^^^^^^^^^^^

Select the *poller* engine configuration, go to the *Data* tab and
within the *Multiple Broker Module* section, delete the NDO module
line.

Now you must to *Add a new broker module*.

.. image:: /_static/images/exploitation/conf_modif_engine_poller_broker.png
   :align: center

====================== ===================================================================
Information            Value
====================== ===================================================================
Multiple Broker Module ``/usr/lib/nagios/cbmod.so /etc/centreon-broker/poller-module.xml``
====================== ===================================================================

Update Centreon options
-----------------------

Go to *Administration > Options*, click on *Options* and select
*Monitoring*. Within the *Monitoring database layer* selection, update
the *Broker engine used by Centreon* option.

.. image:: /_static/images/exploitation/conf_modif_centreon_storage.png
   :align: center

============================== ===============
Information                    Value
============================== ===============
Broker engine used by Centreon Centreon Broker
============================== ===============

Disable ndomod
--------------

Connect to the Centreon interface and go to *Configuration >
Centreon*, select *ndomod.cfg* on the *NDOUtils* menu.

Select your central-mod and poller-mod configurations and disable them.

Rebuild configuraions
---------------------

Connect to the Centreon interface and go to *Configuration >
Monitoring Engine*, select *Generate* on the *Monitoring Engine* menu.

Select *All Engine Servers* into the *Engine Server* section. After
that, select *Generate Configuration Files* and *Run Engine debug (-v)*
into the *Actions* section, and *Export* the configuration.

If all are OK, you can push the configuration, select *Move Export
Files* and *Export* it.

Stop ndo2db
-----------

You need to stop nod2db to release the port 5668. Execute the following
command::

  $ /etc/init.d/ndo2db stop

Start CBD
---------

You need to connect on your central server using SSH and to execute
the following command::

  $ /etc/init.d/cbd start

Restart Engine
--------------

Now you need to restart all engines. Connect to the Centreon interface
and go to *Configuration > Monitoring Engine*, select *Generate* on
the *Engine* menu.

Select *All Engine Servers* into the *Engine Server* section. After
that, select *Move Export Files* and *Restart Engine* section, and
*Export* the configuration.

Move event logs
---------------

Execute the Centreon migration tool named ``logsMigration.pl``. You
will find this tool inside the centreon installation directory. The
path looks like
``/usr/share/centreon/www/__INSTALL__/tools/migration/logsMigration.pl``.

Patch centstorage
-----------------

This paragraphe only apply if you have a Centreon released prior to the
2.4.0 version.

Execute the Centreon migration patch for centstorage (`patch
<http://forge.centreon.com/issues/3265>`_). Then leave centstorage
running for at least a full day (24 hours) before migrating to Centreon
Broker.

Disable ndo2db
--------------

Connect to the Centreon interface and go to *Configuration >
Centreon*, select *ndo2db.cfg* on the *NDOUtils* menu.

Select your central-ndo configuration and disable it.

If you don't want ndo2db to start automatically, don't forget to
remove or disable ndo2db.

CentOS/RedHat
^^^^^^^^^^^^^

Disable ndo2db::

  $ chkconfig --del ndo2db

Remove ndo2db::

  $ yum remove ndoutils

Debian/Ubuntu
^^^^^^^^^^^^^

Disable ndo2db::

  $ update-rc.d ndo2db disable

Remove ndo2db::

  $ apt-get remove ndoutils-common
