| Scroll Ignore | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||
|
Concept
DescriptionLe module de type event-mangermanager-reader est un module de la fonctionnalité bac à événements qui récupéré les événements en base de donnée pour l'affichage dans l'interface de visualisation. Un check sera généré pour chaque webui présent sur le broker superviséqui permet au module WebUI ( l'Interface de Visualisation ) du Broker d'afficher le bac à é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 de type WebUI ( voir la page Module WebUI, propriété "modules" ).
| Warning |
|---|
Pour que la fonctionnalité le menu "bac à événement fonctionne " apparaisse dans l'interface, il faut absolument que ce module soit activé. |
| Info |
|---|
Si vous avez plusieurs configurations de web-ui installées sur du module WebUI présentes dans votre architecture, n'oubliez pas d'activer le module "event-manager |
Configuration .cfg
-reader" dans chaque configuration. Exemple :
|
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 )
#================================================================================
# 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 {
# ┌─────────────────────────────────────────────────────────────────────────────────────────────────────┐ #
# │ ────────────────────────────────────── MODULE IDENTITY ────────────────────────────────────── │ #
# └─────────────────────────────────────────────────────────────────────────────────────────────────────┘ #
# ─── Module name [ Must be unique ] [ MANDATORY ] ───
# ─── ───
module_name event-manager-reader
# ─── Module type [ Do not edit ] [ MANDATORY ] ───
# ─── ───
module_type event_container
# ┌─────────────────────────────────────────────────────────────────────────────────────────────────────┐ #
# │ ──────────────────────────────────── 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
# ─── 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
# ────────────── 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 ────────────────────────────────────── │ #
# └─────────────────────────────────────────────────────────────────────────────────────────────────────┘ #
# ─── 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 ───
# | .cfg#=============================================================================== # event manager #=============================================================================== # Daemons that can load this module: # - broker (to save events information into a mongodb database) # Modules that can load this module: # - WebUI (to display events data to the users) # This module compute and save event for event manager #=============================================================================== define module { #======== Module identity ========= # Module name. Must be unique module_name event-manager-reader # Module type (to load module code). Do not edit. module_type event_container #======== Database connection ========= # mongodb uri definition for connecting to the mongodb database. You can find the mongodb uri # syntax at https://docs.mongodb.com/manual/reference/connection-string/ uri mongodb://localhost/?w=1&fsync=false # If you want to securize your mongodb connection you can enable the ssh use_ssh_tunnel that will─── # allow all mongodb to be encrypted & authentificated with SSH Default : 30 #( Shouldseconds use) a SSH tunnel (Default 0=False) # use_ssh_tunnel 0 # If the SSH connection goes wrong, then retry use_ssh_retry_failure time before_shinken_inactive # Default: 1 # use_ssh_retry_failure 1 # SSH user/keyfile in order to connect to the mongodb server. # Default: shinken─── # ssh_user shinken # Default: ~shinken/.ssh/id_rsa # ssh_keyfile ~shinken/.ssh/id_rsa # Which database is used to store events data database event_container #======== Module options ========= # Number of day the events are keep in database # Default: 30 day_keep_data ─── # time_before_shinken_inactive 30 #======== 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 } 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 | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||
|