################
Graph management
################

Graphs are handled by at least two endpoints : a
:ref:`storage endpoint <user_modules_storage>` for the global policy and
a :ref:`RRD endpoint <user_modules_rrd>` for the physical file
management. To manage graphs, you usually only need to interact with
*storage endpoints* (either through configuration variables or by
database update).

Graph creation
==============

index_data
----------

Before any graph creation, an entry in the *index_data* table must
exist. Such entry is linked to either a service or a host. Centreon
Broker does not insert data in this table, so it must exist prior to
any graph operation. If you use Centreon, don't worry : it will insert
an entry in *index_data* as soon as you create a new host or service.

metrics
-------

The *metrics* table contains the list of metrics managed by Centreon
Broker. Each entry in this table will create a physical graph. Centreon
Broker insert and update this table according to performance data
provided by check plugins. The performance data format is explained in
the Centreon Engine documentation.

data_bin
--------

This last table store all performance data. Each entry is linked to an
entry in the *metrics* table. This table is used mainly for graph
rebuild as it contains all historical data of all graphs.

Graph update
============

Every time a plugin is executed, its perfdata is provided to a storage
endpoint. This endpoint usually inserts the data in *data_bin* and then
generates an event for use by one or multiple
:ref:`RRD endpoints <user_modules_rrd>`.

Graph deletion
==============

Physical graph deletion
-----------------------

If the graph (.rrd file) has been removed from the hard drive, it will
automatically be recreated by the RRD endpoint. It will obviously be
empty (no historical data) but can be rebuild using
:ref:`the standard procedure <exploit_graph_rebuild>`.

In DB graph deletion
--------------------

Currently, Centreon Broker only handle whole host or service deletion
(*index_data*). You cannot delete only one selected metric. To delete a
host or service, flag its corresponding entry in the *index_data* table
by setting the *trashed* flag to '1'. Then make Centreon Broker aware of
this change (restart or SIGHUP). Centreon Broker will then remove
entries from *index_data*, *metrics* and *data_bin* as requested. It
will also generate deletion events for use by RRD endpoints. As a
consequence all metrology history of the host or service will be
deleted.
