Le module event-manger-writer est un module de la fonctionnalité bac à événements qui permet l'écriture des événements en base de donnée .
Pour que la fonctionnalité bac à événement fonctionne il faut absolument que ce module soit activé. |
|
Voici le fichier CFG de configuration présent dans : /etc/shinken/modules/event_manager_writer.cfg
#===============================================================================
# event manager
#===============================================================================
# Daemons that can load this module:
# - broker (to save events information into a mongodb database)
# This module compute and save event for event manager
#===============================================================================
define module {
# ┌─────────────────────────────────────────────────────────────────────────────────────────────────────┐ #
# │ ────────────────────────────────────── MODULE IDENTITY ────────────────────────────────────── │ #
# └─────────────────────────────────────────────────────────────────────────────────────────────────────┘ #
# ─── Module name [ Must be unique ] [ MANDATORY ] ───
module_name event-manager-writer
# ─── 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
# ─── SSH tunnel activation to secure your mongodb connection ───
# ─── That will allow all mongodb to be encrypted & authenticated with SSH ───
# ─── Enable : 1 ( enable ssh tunnel ) ───
# >>> Disable : 0 ( disable ssh tunnel ) ( Default ) ───
# 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 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. ───
# ┌─────────────────────────────────────────────────────────────────────────────────────────────────────┐ #
# │ ─────────────────────────────────── WORKERS IN THE BROKER ─────────────────────────────────── │ #
# └─────────────────────────────────────────────────────────────────────────────────────────────────────┘ #
# ─── This module will use workers in the broker, each worker will manage a shard of all hosts/checks. ───
# ─── This parameter is used by the broker to set the number of workers. ───
# ─── Each worker will use one CPU, which will balance the event processing load among CPUs. ───
# >>> Default : 1 ( worker ) ───
# broker_module_nb_workers 1
# ┌─────────────────────────────────────────────────────────────────────────────────────────────────────┐ #
# │ ────────────────────────────────────── MODULE OPTIONS ─────────────────────────────────────── │ #
# └─────────────────────────────────────────────────────────────────────────────────────────────────────┘ #
# ─── Number of day the events are keep in database ───
# >>> Default : 30 ( days ) ───
# day_keep_data 30
# ┌─────────────────────────────────────────────────────────────────────────────────────────────────────┐ #
# │ ───────────────────────────────────── 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
} |
Pour se connecter au serveur Mongo utilisé pour le stockage des données des événements, 2 méthodes sont disponibles:
Par défaut, le module event-manager-writer se connecte de manière directe au serveur Mongo pour y lire et écrire les données event-manager-writer.
Dans la configuration du module event-manager-writer, on sait que la connexion se fait de manière directe lorsque le paramètre "use_ssh_tunnel" est à 0.
define module {
...
...
...
# --- SSH tunnel activation to securize your mongodb connection ---
# --- That will allow all mongodb to be encrypted & authentificated with SSH ---
# --- Enable : 1 ( enable ssh tunnel ) ---
# >>> Disable : 0 ( disable ssh tunnel ) ( Default ) ---
# use_ssh_tunnel 0
...
...
} |
Cette méthode de connexion a pour avantage d'être facile à configurer au niveau de Shinken. Par contre, elle oblige à permettre l'accès à la base Mongo au monde extérieur, et donc s'exposer à des problèmes de sécurité.
La sécurisation de la base Mongo est bien sur toujours possible (voir Sécurisation des connexions aux bases MongoDB) mais bien plus complexe à mettre en place. La méthode de connexion par SSH est donc préférable pour des raisons pratiques et de sécurité.