Explication
Le module SLA permet de calculer les valeurs de SLA (Service Level Agreement) des éléments supervisés et les stocker dans la base de données Mongodb définie dans le fichier de configuration ci dessous. Il est également possible, via ce fichier, de modifier la méthode de calcul des SLA (par exemple, choisir de considérer un Warning comme une période positive de SLA, ou encore d'exclure les périodes de maintenance dans le calcul).
Shinken Inactif
Mécanisme des données manquantes / Shinken Inactif
| Info |
|---|
Voir : Détermination de l'état de l'hôte ( pour plus d'information sur les cas particuliers ) |
Lorsque Le Broker n'est pas démarré les hôtes et les checks prennent ce le statut Shinken Inactif.
Ce statut est calculé à partir du pouls (heartbeat) du Broker c'est à dire à chaque boucle du Broker on écrit un battement dans la base si il n'y a plus de battement pendant un période on considère que le Broker n'est plus actif.
Configuration
Voici le fichier CFG de configuration présent dans : /etc/shinken/modules/sla.cfg
| Code Block | ||
|---|---|---|
| ||
#===============================================================================
# sla
#===============================================================================
# Daemons that can load this module:
# - broker (to save sla information into a mongodb database)
# Modules that can load this module:
# - WebUI (to display sla data to the users)
# This module compute and save SLA values into a mongodb database
#===============================================================================
define module {
# Shinken Enterprise. Lines added by import core. Do not remove it, it's used by Shinken Enterprise to update your objects if you re-import them.
_SE_UUID core-module-d05cd3505adb11e5884b080027f08538
_SE_UUID_HASH 05d3d1d1cce1f5e03b43936aad25e68f
# End of Shinken Enterprise part
#======== Module identity =========
# Module name. Must be unique
module_name sla
# Module type (to load module code). Do not edit.
module_type sla
#======== 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
# Should 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
# SSH Timeout in order to establish a connection used to test if the SSH tunnel is viable or not, in seconds
# Default: 105
# ssh_tunnel_timeout 5
# Timeout in order to establish a connection, in seconds
# Default: 10
# mongo_timeout 10
# Which database is used to store sla data
database shinken
#======== Module options =========
# Raw SLA can be kept during X days. In case of issue, these data will be used to re-perform SLA computation.
# The drawback of this feature is that it takes more disk space.
#keep_raw_sla_day 7 ;optional, defaults to 7
# Duration in day to keep SLA info,
# Default value is -1. It mean SLA are keep forever, in this case to mongo database will grow endlessly.
# Minimal value is 7 day
#nb_stored_days -1
# SLATime areof computedday onthe aSLA dailyarchive basis.cleanup SLAis ofperformed
the current day are# alwaysDefault recomputedvalue, afterif aunset, configuration change. SLA from days before are by default not recomputed.
# If 1, old SLA will be recomputed with current settings.is 03:02
# Daily cleanup is done at requested time when nb_stored_days is set
# format is HH:MM with
# If 0, old SLA will not be recalculated [default] - HH is the hour of the day (an integer between 0 and 23)
# recompute_old_sla 0
- MM are the minutes (an integer between 0 and 59)
#======== SLA calculation ======== time_when_delete_old_SLA 03:02
# SomeSLA statusare cancomputed impacton positivelya (counteddaily as OK/UP), negatively (counted as CRITICAL/DOWN) or not impact the SLA
# (is not counted, meaning the period of study is reduced by the period that is not counted)basis. SLA of the current day are always recomputed after a configuration change. SLA from days before are by default not recomputed.
# ThisIf configuration1, aimsold atSLA givingwill Shinkenbe administratorsrecomputed awith way to configure how the SLA are calculated.
current settings.
# If 10, Warningold countsSLA aswill UP
not be # If 0, Warning counts as DOWN recalculated [default]
# warningrecompute_counts_as_okold_sla 0
# ======== UnknownSLA periods calculation ========
# Some status can -impact include:positively (counted Only status is considered. "Unknown" status is counted negatively in the SLA. [default]as OK/UP), negatively (counted as CRITICAL/DOWN) or not impact the SLA
# (is not counted, meaning the period -of exclude:study is Unknownreduced areby notthe countedperiod fromthat SLAis considerednot periodcounted).
# This configuration aims -at ok:giving Shinken administrators a way to configure Unknownhow arethe consideredSLA as UP periodsare calculated.
# unknown_periodIf 1, Warning counts as UP
include
# If 0, Warning #counts as == No_data periods ("Missing data" and "Shinken inactive" status) ==DOWN [default]
# warning_counts_as_ok 0
# == Unknown - periods ==
# - include: Only status is considered. "Missing dataUnknown" and "Shinken inactive" status areis counted negatively in the SLA. [default]
# - exclude: No_dataUnknown are not counted from SLA considered period
# - ok: No_dataUnknown are considered as UP periods
# nounknown_data_period include
# == DowntimeNo_data periods ("Missing data" and "Shinken inactive" status) ==
# - include: Only status is considered. [default]
"Missing data" and "Shinken inactive" status are counted negatively in the SLA. [default]
# - exclude: DowntimesNo_data are not counted from SLA considered period
# - ok: DowntimesNo_data are considered as UP periods
# no_data_period - critical: Downtimes are considered as DOWN periods include
# downtime_period == Downtime periods include
==
#======== INTERNAL options =========
#INTERNAL : DO NOT EDIT FOLLOWING PARAMETRE WITHOUT YOUR DEDICATED SUPPORT
# == time of inactivation of the broker before considering that shinken is inactive (in sec) ==
#time_before_shinken_inactive 30
# == maximum number of elements archived in one bulk pass ==
#size_chunk_to_archive 10 000
# == time between two chunk to archive ==
#time_between_two_chunks 0.1 - include: Only status is considered. [default]
# - exclude: Downtimes are not counted from SLA considered period
# - ok: Downtimes are considered as UP periods
# - critical: Downtimes are considered as DOWN periods
# downtime_period include
#======== INTERNAL options =========
#INTERNAL : DO NOT EDIT FOLLOWING PARAMETRE WITHOUT YOUR DEDICATED SUPPORT
# == defaulttime of valueinactivation of the interval check broker before considering that shinken is inactive (in minutessec) ==
#default#time_before_checkshinken_intervalinactive 30
# == maximum number of elements 5
archived in one bulk #pass == delay before the creation of missing data period (in check intervale)
#size_chunk_to_archive 10 000
# == time between two chunk to archive ==
#margin#time_createbetween_newtwo_rangechunks 0.1.5
# == maxdefault delayvalue beforeof creatingthe missinginterval datacheck period (in minutes) ==
#margin#default_create_new_range_maxcheck_interval 10
# Explanatory example of the property margin_create_new_range 5
# For an element with a check interval at 1min and margin == delay before the creation of missing data period (in check intervale) ==
#margin_create_new_range at 1.5 which equals 1min30s of time delay1.5
# If== themax intervaldelay checkbefore iscreating atmissing 1hdata theperiod delay(in would be at 1h30 but the delay is limited by marginminutes) ==
#margin_create_new_range_max which limits the delay to 10min. 10
#
Explanatory example of # An OK status is given by the scheduler at 12h30
# A new OK status is given by the scheduler at 12h40the property margin_create_new_range
# For an element with a check interval at 1min and margin_create_new_range at 1.5 which equals 1min30s of time delay.
# TheIf schedulerthe shouldinterval havecheck givenis a new statusat 1h the delay would be at 12h311h30 but itthe delay gaveis itlimited at 12h40by margin_create_new_range_max which islimits 9minthe ofdelay timeto delay10min.
#
So that 9min > 1min30s a missing data period is created.
} |
Configurer l'accès à la base MongoDB
Cette configuration s'effectue dans le fichier de configuration du module SLA
| Code Block | ||
|---|---|---|
| ||
define module{ ... ... ... #======== Database connection ========= # An OK status is given by the scheduler at 12h30 # A new OK status is given by the scheduler at 12h40 # mongodbThe urischeduler definitionshould forhave connectinggiven toa thenew mongodbstatus database.at You12h31 canbut findit thegave mongodbit uri at 12h40 which is #9min syntaxof at https://docs.mongodb.com/manual/reference/connection-string/time delay. uri# So that 9min > 1min30s a missing data period is created. } |
Configurer l'accès à la base MongoDB
Cette configuration s'effectue dans le fichier de configuration du module SLA
| Code Block | ||
|---|---|---|
| ||
define module{ ... ... ... #======== Database mongodb://localhost/?w=1&fsync=false connection ========= # mongodb Ifuri definition youfor wantconnecting to securizethe your mongodb connectiondatabase. youYou can enablefind the ssh use_ssh_tunnel that willmongodb uri # allowsyntax all mongodb to be encrypted & authentificated with SSH at https://docs.mongodb.com/manual/reference/connection-string/ uri # Should use a SSH tunnel (Default 0=False) mongodb://localhost/?w=1&fsync=false # use_ssh_tunnelIf you want to securize your mongodb connection you can 0 enable the ssh use_ssh_tunnel #that Ifwill the SSH connection goes wrong, then retry use_ssh_retry_failure time before_shinken_inactive# allow all mongodb to be encrypted & authentificated with SSH # Default: 1Should use a SSH tunnel (Default 0=False) # use_ssh_retry_failuretunnel 1 # SSH user/keyfile in order to connect to 0 # If the mongodb server.SSH connection goes wrong, then retry use_ssh_retry_failure time before_shinken_inactive # Default: shinken1 # use_ssh_userretry_failure 1 # SSH user/keyfile in order to connect to the mongodb shinken server. # Default: ~shinken/.ssh/id_rsashinken # ssh_keyfileuser ~shinken/.ssh/id_rsashinken # Timeout in order to establish a connection, in seconds Default: ~shinken/.ssh/id_rsa # ssh_keyfile # Default: 10 # mongo_timeout 10 ~shinken/.ssh/id_rsa # WhichSSH database isTimeout used to storetest slaif data the SSH tunnel is databaseviable or not, in seconds # Default: 5 shinken ... ... ... # ssh_tunnel_timeout 5 # Timeout in order to establish a connection, in seconds # Default: 10 # mongo_timeout 10 # Which database is used to store sla data database shinken ... ... ... } |
Les données SLA sont stockées dans la base Mongo locale au Broker
Pour se connecter au serveur Mongo utilisé pour le stockage des données SLA, 2 méthodes sont disponibles:
- Connexion directe: Par défaut, mais non sécurisée.
- Tunnel SSH: Shinken se connecte au serveur Mongo au travers d'un module SSH pour plus de sécurité
Connexion directe au serveur Mongo
Par défaut, le module SLA se connecte de manière directe au serveur Mongo pour y lire et écrire les données SLA.
Dans la configuration du module SLA, on sait que la connexion se fait de manière directe lorsque le paramètre "use_ssh_tunnel" est à 0.
| Code Block | ||||
|---|---|---|---|---|
| ||||
define module {
...
... ...
#======== Module identity =========
# Module name. Must be unique
module_name sla
...
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 voir la page 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é.
Connexion par SSH au serveur Mongo
Le module SLA peut également se connecter par tunnel SSH au serveur Mongo, pour des raisons de sécurité.
- En effet, le paramétrage de mongoDB permet de définir sur quel adresse ce dernier écoute les requêtes.
- En n'autorisant seulement l'adresse 127.0.0.1, cela évite d'ouvrir la base au monde extérieur.
- Dans la configuration du serveur Mongo (/etc/mongod.conf), assurez-vous que le paramètre "bind_ip" est positionné pour n'écouter que sur l'interface locale:
bind_ip=127.0.0.1
- Dans la configuration du serveur Mongo (/etc/mongod.conf), assurez-vous que le paramètre "bind_ip" est positionné pour n'écouter que sur l'interface locale:
- En n'autorisant seulement l'adresse 127.0.0.1, cela évite d'ouvrir la base au monde extérieur.
- Dans cette configuration, pour que le module mongoDB se connecte, il faut activer les options suivantes :
| Nom du paramètre | Description |
|---|---|
mongodb_use_ssh_tunnel | Activation du tunnel ou non (0 ou 1 ). Par défaut, il n'est pas activé ( à 1 ) |
mongodb_use_ssh_retry_failure | Spécifie le nombre supplémentaire de tentatives lors de l'établissement du tunnel SSH si ce dernier n'arrive pas à être établi |
mongodbssh_ssh_user | L'utilisateur avec lequel le tunnel sera établit |
mongodb_ssh_keyfile | une clé ssh privée présent sur le serveur Shinken (par défaut ~/.ssh/id_rsa) qui sera utilisé pour établir le tunnel. |
| ssh_tunnel_timeout | Spécifie le timeout de la vérification du tunnel SSH avant que la connexion vers mongo soit effectuée |
- Le tunnel SSH va permettre au module de se connecter comme si ses requêtes étaient local au serveur mongo ( en 127.0.0.1 )
- Connectez-vous avec le user lançant le démon sur le serveur Shinken
- Générez la paire de clés SSH si nécessaire
- Copiez la clé publique sur le serveur mongo
root@serveur_shinken # su - shinkenshinken@serveur_shinken $ ssh-keygenshinken@serveur_shinken $ ssh-copy-id user_distant@serveur_mongo[...]shinken@serveur_shinken $ ssh user_distant@serveur_mongo
user_distant@serveur_mongo $
[...]shinken@serveur_shinken $ ssh user_distant@serveur_mongouser_distant@serveur_mongo $
- Cette manipulation est aussi nécessaire dans le cas ou la base mongoDB est sur le même serveur que le module SLA, meme si le tunnel est ouvert localement.
Suppression des anciennes entrées dans la base d'archives du module SLA
Les entrées dans la base d'archives du module SLA sont supprimées toutes les 24h.
| Nom du paramètre | Description | Valeur par défaut |
|---|---|---|
| nb_stored_days | Détermine le nombre de jours à garder dans la base d'archives du module SLA. La valeur minimale acceptée correspond à 7 jours. La valeur -1 signifie qu'on veut garder toutes les entrées dans la base d'archives du module SLA, et il n'y a pas de suppression quotidienne. | -1 |
| time_when_delete_old_SLA | Heure de la journée à laquelle les entrées dans la base d'archives du module SLA seront supprimées. Les données gardées correspondent aux jours définis par la valeur de la propriété nb_stored_days | 03:02 |
| Info |
|---|
Si le Broker est éteint et que la suppression n'est pas faite depuis plus de 24 h, elle se fera automatiquement au démarrage du Broker. |
| Info |
|---|
S'il n'y a aucune trace du dernier nettoyage de la base d'archives du module SLA, le nettoyage s'exécutera. |