Explication
Le module broker-module-livedata permet d'envoyer des requêtes API afin de recevoir des informations sur un hôte, un cluster, un check attaché à un hôte ou un check attaché à un cluster. Il est possible de modifier certains paramètres dans la configuration.
Configuration
Voici le fichier CFG de configuration présent dans : /etc/shinken/modules/broker-module-livedata.cfg
| Code Block | ||
|---|---|---|
| ||
#=============================================================================== # broker module livedata #=============================================================================== # Daemons that can load this module: # - broker # This module is an api getting information from the broker #=============================================================================== define module { #======== Module identity ========= # Module name. Must be unique module_name broker-module-livedata # Module type (to load module code). Do not edit. module_type broker_module_livedata #======== Listening address ========= # host: IP address to listen to. # note: 0.0.0.0 = all interfaces. host 0.0.0.0 # port to listen port 8000 # HTTPs part, enable if you want to set the visualisation interface listen in HTTPs mode # disabled by default. Set your own certificates. Set Changeyour theown token, it is usefull to get access to the API use_ssl 0 ssl_cert /etc/shinken/certs/server.cert ssl_key /etc/shinken/certs/server.key token ak5zv6t5s25r6g4 #======== Security ========= # auth_secret: secret key used to crypt cookie. # note: must be the same as the configuration UI auth_secret THIS SHOULD BE CHANGED BEFORE PRODUCTION # Maximum output length for plugin output, 0=no limit max_output_length 0 #======== Extended configuration ======== } |
Fonctionnement
Le module broker-module-livedata permet la récupération via une api de certaines informations des éléments supervisé par Shinken. L'accès à cette API est restreinte aux détenteurs d'un token généré dans la configuration (modifiable par l'utilisateur) du module. Il se présente par défaut sous la forme d'une suite aléatoire de X chiffres/lettres. Le fonctionnement de l'api est tel que :
URL/V1/cluster/UUID?token=TOKEN
- Retourne
- cluster_uuid : text
- cluster_name : text
- cluster_display_name : text
- status : text
- OK
- WARNING
- CRITICAL
- UNKNOWN
- MISSING-DATA
- SHINKEN-INACTIVE
- status_since : epoch (en secondes)
- context : text
- NOTHING
- ACKNOWLEDGED
- PARTIAL-ACKNOWLEDGED
- INHERITED-ACKNOWLEDGED
- DOWNTIME
- PARTIAL-DOWNTIME
- INHERITED-DOWNTIME
- FLAPPING
- PARTIAL-FLAPPING
- DISABLED
- business_impact : 0, 1, 2, 3, 4, 5
- output : text
- long_output : text
- URL/V1/check-on-cluster/UUID?token=TOKEN
- Retourne
- check_uuid : text
- check_name : text
- check_display_name : text
- status : text
- OK
- WARNING
- CRITICAL
- UNKNOWN
- MISSING-DATA
- SHINKEN-INACTIVE
- status_since : epoch (en secondes)
- context : text
- NOTHING
- ACKNOWLEDGED
- PARTIAL-ACKNOWLEDGED
- INHERITED-ACKNOWLEDGED
- DOWNTIME
- PARTIAL-DOWNTIME
- INHERITED-DOWNTIME
- FLAPPING
- PARTIAL-FLAPPING
- DISABLED
- output : text
- business_impact : 0, 1, 2, 3, 4, 5
- long_output : text
- host_uuid : text
- host_name : text
- host_display_name : text
- business_impact : 0, 1, 2, 3, 4, 5
- status_since : epoch (en secondes)
- Retourne
- URL/V1/host/UUID?token=TOKEN
- Retourne
- host_uuid : text
- host_name : text
- host_display_name : text
- status : text
- OK
- WARNING
- CRITICAL
- UNKNOWN
- MISSING-DATA
- SHINKEN-INACTIVE
- status_since : epoch (en secondes)
- context : text
- NOTHING
- ACKNOWLEDGED
- PARTIAL-ACKNOWLEDGED
- INHERITED-ACKNOWLEDGED
- DOWNTIME
- PARTIAL-DOWNTIME
- INHERITED-DOWNTIME
- FLAPPING
- PARTIAL-FLAPPING
- DISABLED
- business_impact : 0, 1, 2, 3, 4, 5
- output : text
- long_output : text
- Retourne
- URL/V1/check-on-host/UUID?token=TOKEN
- Retourne
- check_uuid : text
- check_name : text
- check_display_name : text
- status : text
- OK
- WARNING
- CRITICAL
- UNKNOWN
- MISSING-DATA
- SHINKEN-INACTIVE
- status_since : epoch (en secondes)
- context : text
- NOTHING
- ACKNOWLEDGED
- PARTIAL-ACKNOWLEDGED
- INHERITED-ACKNOWLEDGED
- DOWNTIME
- PARTIAL-DOWNTIME
- INHERITED-DOWNTIME
- FLAPPING
- PARTIAL-FLAPPING
- DISABLED
- output : text
- business_impact : 0, 1, 2, 3, 4, 5
- long_output : text
- cluster_uuid : text
- cluster_name : text
- cluster_display_name : text
- business_impact : 0, 1, 2, 3, 4, 5
- status_since : epoch (en secondes)
- Retourne
URL étant l'adresse shinken sur le port 8000 (modifiable).
Essayer d'accéder à une API sans le token renverra une erreur.
Accéder à un hôte ou à un cluster inconnu renverra un champ unique (en plus de l'UUID) vous confirmant que l'hôte/cluster est introuvable.
Accéder à un check inexistant renverra une erreur. De même si vous essayez d'accéder à un check qui n'est pas rattaché à un hôte (dans le cas d'un check-on-host) ou à un cluster (dans le cas d'un check-on-clusterpar défaut (modifiable).