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 (comme le port d'écoute et le token).
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 your own 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
}
|
Fonctionnement
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. Le fonctionnement de l'api est tel que :
Cluster et hôte
URL/api/V1/cluster/UUID?token=TOKEN ou URL/api/V1/host/UUID?token=TOKEN
- cluster_uuid/host_uuid : text
- cluster_name/host_name : text
- cluster_display_name/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
Check attaché à un cluster et check attaché à un hôte
URL/api/V1/check-on-cluster/UUID?token=TOKEN ou URL/api/V1/check-on-host/UUID?token=TOKEN
- 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/host_uuid : text
- cluster_name/host_name : text
- cluster_display_name/host_display_name : text
URL étant l'adresse shinken sur le port 8000 par défaut (modifiable).
Test de performance
Sur une machine avec 1782 hôtes, le broker n'a aucune latence à la réception de 15 requêtes api par seconde de 10 sources différentes (150 au total) et renvoi le résultat en moins de 0.01 seconde.