| Scroll Ignore | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||
|
Concept
DescriptionLe module de type event-manager-reader est un module qui permet au module WebUI ( l'interface Interface de visualisation Visualisation ) du broker Broker d'afficher le bac à événementsévénement ( voir la page Vue - Les Événements ).
- Il récupère les événements en base de donnée des événements.
- Il doit donc être listé dans la liste des modules du module de type WebUI ( cf voir la page Module WebUI, propriété "modules" ).
| Warning |
|---|
Pour que la fonctionnalité le menu "bac à événement" apparaisse dans l'interface, il faut absolument que ce module soit activé. |
| Info |
|---|
Si vous avez plusieurs configurations de web-ui présente du module WebUI présentes dans votre architecture, n'oubliez pas d'activer le module "event-manager-reader" dans chaque configuration. Exemple :
|
Configuration .cfg
Activation du module
Le module
event-manager-reader est un module qui peut être activé seulement sur le module WebUI.
- L'activation du module s'effectue en ajoutant le nom de ce module dans le fichier de configuration du module WebUI.
- Pour ce faire, il faut ouvrir le fichier de configuration du module WebUI du Broker à l'emplacement /etc/shinken/module/ma_webui.cfg, et ajouter le nom du module "
event-manager-reader".
Exemple : par défaut, est livré un module dont le nom est "event-manager-reader":
| Code Block | ||||
|---|---|---|---|---|
| ||||
define module {
[...]
modules Module 1, Module 2, Module 3, event-manager-reader
[...]
} |
Pour prendre en compte le changement de configuration, redémarrer l'Arbiter:
| Code Block | ||||
|---|---|---|---|---|
| ||||
service shinken-arbiter restart |
Configuration
La configuration du module livré par défaut se trouve dans le fichier/etc/shinken/modules/event_manager_reader.cfg
- Un fichier d'exemple est disponible ici : /etc/shinken-user-example/configuration/daemons/brokers/modules/event_manager_reader/event_manager_reader-example.cfg
Exemple de fichier de configuration
| Code Block | ||||
|---|---|---|---|---|
| ||||
# CFG_FORMAT_VERSION 1 ( SHINKEN : DON'T TOUCH THIS LINE )
#= | .cfg#=============================================================================== # event manager #=============================================================================== # Modules that can load this module: # - WebUI (to display events data to the users) # This module read event from database to show you in the WebUI #=============================================================================== define module { # ┌─────────────────────────────────────────────────────────────────────────────────────────────────────┐event #manager # │ -------------------------------------- Module identity -------------------------------------- │ # # --- Module name [ Must be unique ] #================================================================================ # Modules that can load this module: # - WebUI (to display events data to the users) # This module read event from database to show you in the WebUI #================================================================================ define module { # ┌─────────────────────────────────────────────────────────────────────────────────────────────────────┐ # # │ ────────────────────────────────────── MODULE IDENTITY ────────────────────────────────────── │ # # └─────────────────────────────────────────────────────────────────────────────────────────────────────┘ # # ─── Module name [ Must be unique ] [ MANDATORY ] --- module_name [ MANDATORY ] ─── # ─── event-manager-reader # --- Module type [ Do not edit ] [ MANDATORY ] --- module_type ─── module_name event_container # ┌─────────────────────────────────────────────────────────────────────────────────────────────────────┐ # # │ ------------------------------------ Database connection ------------------------------------ │ # # └─────────────────────────────────────────────────────────────────────────────────────────────────────┘ # # ================= MongoDB parameters ================= # --- MongoDB uri definition . You can find the mongodb uri syntax at event-manager-reader # ─── Module type [ Do not edit ] [ MANDATORY ] ─── # ─── --- # --- https://docs.mongodb.com/manual/reference/connection-string/ --- # >>> Default : mongodb://localhost/?w=1&fsync=false ─── module_type --- # uri event_container # ┌─────────────────────────────────────────────────────────────────────────────────────────────────────┐ # # │ ──────────────────────────────────── DATABASE CONNECTION ──────────────────────────────────── mongodb://localhost/?w=1&fsync=false │ # # --- Which database contains events data └─────────────────────────────────────────────────────────────────────────────────────────────────────┘ # # ───────────────── MongoDB parameters ──────────────────────────────────────────────────────────────── # # ─── MongoDB uri definition . You can find the mongodb uri syntax at ---─── # >>>─── Default : shinkenhttps://docs.mongodb.com/manual/reference/connection-string/ ─── # --- # database event_container # --- SSH tunnel activation to securize your mongodb connection ─── # Default : mongodb://localhost/?w=1&fsync=false --- # --- That will allow all mongodb to be encrypted & authentificated with SSH ─── # ─── --- # --- Enable : 1 ( enable ssh tunnel ) --- ─── # >>>uri Disable : 0 ( disable ssh tunnel ) ( Default ) mongodb://localhost/?w=1&fsync=false # ─── Which database contains events data --- # use_ssh_tunnel 0 # --- If the SSH connection goes wrong, then retry use_ssh_retry_failure time before_shinken_inactive ---─── # >>> Enable : 1 ( with ssh tunnel ) ( Default ) --- # --- Disable : 0 ( direct connection ) ─── # Default : event_container --- # use_ssh_retry_failure 1 # ---─── SSH user to connect# to─── the mongodb server. --- # >>> Default : shinken ─── # database ---event_container # ssh_user ─── username/password to authenticate to MongoDB. shinken # --- SSH keyfile to connect to the mongodb server. ─── # ─── Both parameters must be provided for authentication to function correctly. ─── # ─── --- # >>> Default : ~shinken/.ssh/id_rsa --- # --- SSH Timeout used to test if the SSH tunnel is viable or─── not, in seconds. # broker__module_webui__module_event_manager_reader__database__username # ─── --- # >>> Default : 10 ( seconds ) ---─── # ssh_tunnel_timeout broker__module_webui__module_event_manager_reader__database__password # ─── SSH tunnel activation to secure your mongodb connection 10 # ============== AutoReconnect Management ============== # --- When MongoDB require you to reconnect ( For example,─── It can occur when# a─── newThat PRIMARYwill isallow electedall mongodb to --- be encrypted & authenticated #with ---SSH in a MongoDB cluster ), it will raised the MongoDB AutoReconnect exception. ─── # --- # --- ---─── # --- How many try to reconnect before module go in error... : Enable => 1 ( enable ssh tunnel ) --- # >>> Default : 4 ( try ) ─── # Default : Disable => 0 ( disable ssh tunnel ) ─── # ─── --- # auto_reconnect_max_try 4 # --- Time between each try ─── # use_ssh_tunnel --- # >>> Default : 3 ( seconds ) 0 # ─── If the SSH connection goes wrong, then retry use_ssh_retry_failure time before_shinken_inactive ─── # --- # auto_reconnect_sleep_between_try 3 ─── # --- NOTE: Change these values only if you have a MongoDB cluster and you change the Default : 1 ( try ) --- # --- heartbeatTimeoutSecs of your MongoDB replica set ─── # ─── ─── # use_ssh_retry_failure 1 # ─── SSH user to connect to the mongodb server. ─── # ─── # Default : shinken ─── # ─── ─── # ssh_user shinken # ─── SSH keyfile to connect to the mongodb server. ─── # ─── # Default : ~shinken/.ssh/id_rsa ─── # ─── ─── # ssh_keyfile ~shinken/.ssh/id_rsa # ─── SSH Timeout used to test if the SSH tunnel is viable or not, in seconds. ─── # ─── # Default : 10 ( seconds ) ─── # ─── ─── # ssh_tunnel_timeout 10 # ────────────── AutoReconnect Management ───────────────────────────────────────────────────────────── # # ─── When MongoDB require you to reconnect ( For example, It can occur when a new PRIMARY is elected ─── # ─── in a MongoDB cluster ), it will raised the MongoDB AutoReconnect exception. ─── # ─── ─── # ─── How many try to reconnect before module go in error ─── # ─── # Default : 4 ( try ) ─── # ─── ─── # auto_reconnect_max_try 4 # ─── Time between each try ─── # ─── # Default : 3 ( seconds ) ─── # ─── ─── # auto_reconnect_sleep_between_try 3 # ─── NOTE: Change these values only if you have a MongoDB cluster and you change the ─── # ─── heartbeatTimeoutSecs of your MongoDB replica set ─── # ─── The value of auto_reconnect_max_try * auto_reconnect_sleep_between_try must be higher than ─── # ─── heartbeatTimeoutSecs in the rs.conf(); of your MongoDB replica set. ─── # ┌─────────────────────────────────────────────────────────────────────────────────────────────────────┐ # # │ ───────────────────────────────────── VISUALISATION UI ────────────────────────────────────── │ # # └─────────────────────────────────────────────────────────────────────────────────────────────────────┘ # # ─── Specify the max retries when the Visualisation UI can't communicate with the event_manager_reader ─── # ─── during the Excel export. ─── # ─── Increase this parameter when users encounter difficulties when generating the Excel export ─── # ─── of events. This will make the export more tolerant to network loss or database slowness, ─── # ─── or restart of the broker. ─── # ─── The value cannot be 0. ─── # ─── # Default : 2 ( try ) ─── # ─── ─── # broker__module_webui__module_event_manager_reader__events_export__max_retry 2 # ┌─────────────────────────────────────────────────────────────────────────────────────────────────────┐ # # │ ───────────────────────────────────── INTERNAL OPTIONS ────────────────────────────────────── │ # # └─────────────────────────────────────────────────────────────────────────────────────────────────────┘ # # ─── INTERNAL : DO NOT EDIT FOLLOWING PARAMETER WITHOUT YOUR DEDICATED SUPPORT ─── # ─── Broker idle time before considering that Shinken is inactive. ─── # ─── Use this if you have Broker loop time that exceeds 30 seconds ─── # ─── # Default : 30 ( seconds ) ─── # ─── ─── # time_before_shinken_inactive 30 } |
Détails des sections composant le fichier de configuration
Identification du module
Il est possible de définir plusieurs instances de module de type "event-manager-reader" dans l'architecture Shinken.
- Chaque instance devra avoir un nom unique.
| Scroll Title | |||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||||||
|
Accès à la base MongoDB
Cette configuration s'effectue dans le fichier de configuration du module.
Pour se connecter à la base MongoDB utilisé pour le stockage des données, deux méthodes sont disponibles :
- Connexion directe : Par défaut, mais non sécurisée.
- Tunnel SSH : Shinken se connecte à la base MongoDB au travers d'un module SSH pour plus de sécurité.
Configuration de l'URI de connexion et de l'authentification par mot de passe
| Code Block | ||||
|---|---|---|---|---|
| ||||
# ┌─────────────────────────────────────────────────────────────────────────────────────────────────────┐ #
# │ ──────────────────────────────────── DATABASE CONNECTION ──────────────────────────────────── │ #
# └─────────────────────────────────────────────────────────────────────────────────────────────────────┘ #
# ───────────────── MongoDB parameters ──────────────────────────────────────────────────────────────── #
# ─── MongoDB uri definition . You can find the mongodb uri syntax at ───
# ─── https://docs.mongodb.com/manual/reference/connection-string/ ───
# ───
# Default : mongodb://localhost/?w=1&fsync=false ───
# ─── ───
# uri mongodb://localhost/?w=1&fsync=false
# ─── Which database contains events data ───
# ───
# Default : event_container ───
# ─── ───
# database event_container
# ─── username/password to authenticate to MongoDB. ───
# ─── Both parameters must be provided for authentication to function correctly. ───
# ─── ───
# broker__module_webui__module_event_manager_reader__database__username
# ─── ───
# broker__module_webui__module_event_manager_reader__database__password |
| Scroll Title | |||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||||||||||||||||||||
|
Connexion directe au serveur MongoDB
Par défaut, le module se connecte de manière directe à la base MongoDB pour y lire et écrire les données.
Dans la configuration du module, ceci correspond au paramètre "use_ssh_tunnel" à 0.
C'est la méthode de connexion par défaut lorsque la base est sur la même machine que le démon ( quand l'URL de la base est localhost ).
Si la base est sur une autre machine, il faudra alors se connecter à la base via un tunnel SSH. Cela permet à la base distance de rester en écoute réseau sur l'interface réseau local, ce qui la sécurise des accès extérieurs ( voir la pageSécurisation des connexions aux bases MongoDB ).
Connexion par SSH au serveur MongoDB
| Code Block | ||||
|---|---|---|---|---|
| ||||
# ─── SSH tunnel activation to secure your mongodb connection ───
# ─── That will allow all mongodb to be encrypted & authenticated with SSH ───
# ───
# ... : Enable => 1 ( enable ssh tunnel ) ───
# Default : Disable => 0 ( disable ssh tunnel ) ───
# ───
# use_ssh_tunnel 0
# ─── If the SSH connection goes wrong, then retry use_ssh_retry_failure time before_shinken_inactive ───
# ───
# Default : 1 ( try ) ───
# ───
# use_ssh_retry_failure 1
# ─── SSH user to connect to the mongodb server. ───
# ───
# Default : shinken ───
# ───
# ssh_user shinken
# ─── SSH keyfile to connect to the mongodb server. ───
# ───
# Default : ~shinken/.ssh/id_rsa ───
# ───
# ssh_keyfile ~shinken/.ssh/id_rsa
# ─── SSH Timeout used to test if the SSH tunnel is viable or not, in seconds. ───
# ───
# Default : 10 ( seconds ) ───
# ───
# ssh_tunnel_timeout 10 |
| Scroll Title | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||||||||||||||||||||||
|
Gestion de l'auto reconnexion avec un cluster MongoDB
| Code Block | ||||
|---|---|---|---|---|
| ||||
# ────────────── AutoReconnect Management ───────────────────────────────────────────────────────────────
# ─── When MongoDB require you to reconnect ( For example, It can occur when a new PRIMARY is elected ───
# ─── in a MongoDB cluster ), it will raised the MongoDB AutoReconnect exception. ───
# ─── ───
# ─── How many try to reconnect before module go in error ───
# ───
# Default : 4 ( try ) ───
# ───
# auto_reconnect_max_try 4
# ─── Time between each try ───
# ───
# Default : 3 ( seconds ) ───
# ───
# auto_reconnect_sleep_between_try 3
# ─── NOTE: Change these values only if you have a MongoDB cluster and you change the ───
# ─── heartbeatTimeoutSecs of your MongoDB replica set ───
# ─── The value of auto_reconnect_max_try * auto_reconnect_sleep_between_try must be higher than ───
# ─── heartbeatTimeoutSecs in the rs.conf(); of your MongoDB replica set. |
| Info | ||
|---|---|---|
| ||
( voir la page Haute disponibilité de la base MongoDB (mise en place d'un cluster) ) |
Dans le cas de l'utilisation d'un cluster MongoDB, lorsque le membre Primaire devient inaccessible, une nouvelle élection est déclenchée, ce qui provoque une coupure temporaire de l'accès à la base.
Dans le but de ne pas interrompre le service, le module "event-manager-reader" va se reconnecter automatiquement au cluster MongoDB.
Pour ce faire, il va faire un nombre d'essais égaux au paramètre "auto_reconnect_max_try " avec une pause de X secondes entre chaque essai ( correspondant au paramètre "auto_reconnect_sleep_between_try" ).
Par défaut pour MongoDB le temps maximum avant qu'un membre Primaire soit considéré comme indisponible et qu'une nouvelle élection ait lieu est de 10 secondes.
Voir : "heartbeatTimeoutSecs" donné par la commande rs.conf(); dans un shell de MongoDB.
| Scroll Title | |||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||||||
|
Les valeurs par défauts du fichier laissent 12 secondes, ce qui est amplement suffisant avec la configuration par défaut de MongoDB.
| Warning |
|---|
Il est conseillé de ne pas modifier ces valeurs. |
Configuration pour l'interface de visualisation
| Code Block | ||||
|---|---|---|---|---|
| ||||
# ┌─────────────────────────────────────────────────────────────────────────────────────────────────────┐ #
# │ ───────────────────────────────────── VISUALISATION UI ────────────────────────────────────── │ #
# └─────────────────────────────────────────────────────────────────────────────────────────────────────┘ #
# ─── Specify the max retries when the Visualisation UI can't communicate with the event_manager_reader ───
# ─── during the Excel export. ───
# ─── Increase this parameter when users encounter difficulties when generating the Excel export ───
# ─── of events. This will make the export more tolerant to network loss or database slowness, ───
# ─── or restart of the broker. ───
# ─── The value cannot be 0. ───
# ───
# Default : 2 ( try ) ───
# ───
# broker__module_webui__module_event_manager_reader__events_export__max_retry 2 |
Le paramètre "broker__module_webui__module_event_manager_reader__events_export__max_retry" permet de configurer le nombre maximal de tentatives lorsque l'interface de visualisation ne peut pas communiquer avec le module event_manager_reader pendant l'export des données vers Excel.
Cela rendra les exports plus tolérants aux pertes de réseau ou aux lenteurs de la base de données, ou aux redémarrages du Broker.
| Scroll Title | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||
|
Options Internes
| Code Block | ||||
|---|---|---|---|---|
| ||||
# ┌─────────────────────────────────────────────────────────────────────────────────────────────────────┐ # # │ ───────────────────────────────────── INTERNAL OPTIONS ────────────────────────────────────── │ ---# # ---└─────────────────────────────────────────────────────────────────────────────────────────────────────┘ The value of auto_reconnect_max_try * auto_reconnect_sleep_between_try must be higher than ---# # ---─── INTERNAL : DO NOT EDIT FOLLOWING heartbeatTimeoutSecsPARAMETER inWITHOUT the rs.conf(); of your MongoDB replica set.YOUR DEDICATED SUPPORT ---─── # ┌─────────────────────────────────────────────────────────────────────────────────────────────────────┐ # # │ ------------------------------------- Visualisation UI -------------------------------------- │ # # --- Specify the max retries when the Visualisation UI can't communicate with─── Broker idle time before considering that Shinken is inactive. ─── # ─── Use this if you have Broker loop time that --- exceeds 30 seconds # --- the event_manager_reader during export. ─── # --- # --- The value cannot be 0. ─── # --- # >>> Default : 230 ( tryseconds ) ─── # --- # broker__module_webui__module_event_manager_reader__events_export__max_retry 2 # ┌─────────────────────────────────────────────────────────────────────────────────────────────────────┐ # # │ ------------------------------------- INTERNAL options -------------------------------------- │ # # --- INTERNAL : DO NOT EDIT FOLLOWING PARAMETER WITHOUT YOUR DEDICATED SUPPORT ---─── # --- time of inactivation of the broker before considering that shinken is inactive (in sec)time_before_shinken_inactive --- # 30 |
| Warning |
|---|
Ces paramètres sont dédiés au fonctionnement interne au module, il est fortement recommandé de ne pas les modifier sans votre support dédié. |
| Scroll Title | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||
|