naparuba/shinken — pull request #962 by geektophe (2013-08-06 13:53:26+00:00)
Title: Added business rules output.

This patch adds business rules based services output.

By default, business rules based services output is empty, forcing to browse service's dependency tree to see what happens.

Services now have an additionnal attribute named `business_rule_output_template`, that contains a template string, which macros are expanded with service attributes to build its output on the `manage_internal_checks` scheduler step.

The template syntax contains placeholders allowing to expand macros bound to the service attributes, or to each of its dependent items (childs).

**Macros description**
- `SERVICE_DESCRIPTION`: The service name
- `HOST_NAME`: The item name
- `FULL_NAME`: The item full name
- `STATUS`: The item status string (may be one of `OK`, `WARN`, `CRIT`, `UP`, `DOWN`)
- `SHORT_STATUS`: The item shorten status string (my be one of`O`, `W`, `C`, `U`, `D`)

**Childs output placeholder**
The code contained between the `$(` and `)$` signs is processed for each businsess rule child. Between them, the macros are bound to each child service attributes. Outside, they are bound to the father service attributes.
*Caution*: only childs with a state defferent from OK (problems) are displayed in the output.

**Example**
A business rule service

- With a `bp_rule` looking like `test_host_01,srv1 & test_host_02,srv2 & test_host_03,srv3 & test_host_04`
- With `test_host_01,srv1` in `OK` state, `test_host_02,srv2` in `WARNING` state, `test_host_03,srv3` in `CRITICAL` state, and test_host_04 in `DOWN` state.
- And a `business_rule_output_template` looking like `$STATUS$ $([$STATUS$: $FULL_NAME$] )$`

Would produce an output looking like

`CRITICAL [WARNING: test_host_02/srv2] [CRITICAL: test_host_03/srv3] [DOWN: test_host_04]`