| Scroll Ignore | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||
|
Rôle
Le démon broker exporte et gère les données du Scheduler. Sa gestion ne peut se faire qu'à travers des modules. Plusieurs modules de gestion peuvent être activés en même temps.
Exemples de modules du Broker :
- Module pour centraliser les logs Shinken : Simple-log (flat file)
- Module pour exporter les données: Graphite-Perfdata
- Module pour l'API Livestatus
- Module pour l'affichage de l'interface de visualisation : WebUI
Données
Le Broker reçoit toutes les données des Schedulers. Il garde également en mémoire les données des hôtes et des checks.
Enfin, il sauvegarde les résultats des checks dans une base mongodb (si possible, cette base doit être installée sur le même serveur que le broker).
Données de métrologie
Les données de métrologie sont sauvegardées sur le serveur du broker dans l'application graphite.
Cette application écoute le port 2003, et cette connexion se fait sans authentification.
Cette application doit donc écouter exclusivement sur l'interface réseau locale (loopback) du serveur du broker.
Logique interne du Broker
Résumé des connexions du Broker
| Source | Destination | Port | Protocole | Note |
|---|---|---|---|---|
| Broker | Scheduler | 7768 | HTTP/HTTPS | |
| Broker | Poller | 7771 | HTTP/HTTPS | |
| Broker | Reactionner | 7769 | HTTP/HTTPS | |
| Broker | Receiver | 7773 | HTTP/HTTPS | |
| Broker | Broker (local) | 2003 | TCP | interface localhost uniquement |
Description des variables
| Propriété | Défaut | Description |
|---|---|---|
broker_name | N/A | Cette variable est utilisée pour identifier le *nom réduit* du Broker auquel les données sont associées. |
address | N/A | Cette directive est utilisée pour définir l'adresse permettant de joindre ce Broker. Par défaut "localhost", changez-le par un nom DNS ou une adresse IP. |
port | 7772 | Cette directive est utilisée pour définir le port TCP utilisé par le démon. |
use_ssl | 0 | Cette variable est utilisée pour définir si le Broker doit être contacté en HTTPS (*1*) ou HTTP (*0*). La valeur par défaut est *0* (HTTP). |
spare | 0 | Cette variable est utilisée pour définir si le broker peut être géré comme un spare (prendra uniquement la configuration si le maître échoue). La valeur par défaut est *0* (maître). |
| spare_daemon | N/A | Nom du démon spare qui sera utilisé pour reprendre le travail de ce démon s'il vient à ne plus être disponible |
timeout | 3 | Cette variable est utilisée pour définir le temps en secondes avant que l'Arbiter ne considère ce démon comme à l'arrêt. Si ce démon est joignable en HTTPS (use_ssl à 1) avec une latence élevée, nous vous conseillons alors d'augmenter cette valeur de timeout (l'Arbiter aura besoin de plus d'allers/retours pour le contacter). |
data_timeout | 120 | Cette variable est utilisée pour définir le temps en secondes avant de considérer un transfert de configuration ou de données comme échoué. |
max_check_attempts | 3 | Si le ping permettant de détecter la disponibilité réseau du nœud est en échec N fois ou plus, alors le nœud est considéré comme mort. (par défaut, 3 tentatives) |
check_interval | 60 | Intervalle de Ping toutes les N secondes. |
modules | N/A | Cette variable est utilisée pour définir les modules chargés par le broker. |
realm | N/A | Cette variable est utilisée pour définir le royaume où le broker doit être. Si aucun n'est sélectionné, celui par défaut lui sera assigné. |
manage_sub_realms | 1 | Cette variable est utilisée pour définir si le broker prendra des tâches des Schedulers des sous-royaumes . |
manage_arbiters | 1 | Prends les données de l'Arbiter. Il ne devrait y avoir qu'un seul broker pour l'Arbiter. |
satellitemap | N/A | Cette variable est utilisée pour définir, pour des environnements NATés, les différents satellites comme vus depuis ce broker. |
broks_packet_size | 204800 | Si présent, les demandes vers les schedulers vont avoir comme limite haute de taille de paquet cette valeur (en Ko). Par défaut les envois sont illimités. |
broker__manage_brok__enable_sub_processes_memory_usage_protection | 1 | Si activé, le broker va vérifier qu'il y a assez de RAM disponible sur le système avant de lancer ses processus workers qui poussent les broks vers les modules externes (comme WebUI) |
broker__manage_brok__sub_process_memory_usage_system_reserved_memory | 0 | Dans le cas de la protection de mémoire, on peut réserver un pourcentage de RAM pour le système qui ne sera pas considérée comme disponible par le démon |
broker__manage_brok__sub_processes_memory_usage_protection_max_retry_time | 5 | Dans le cas de la protection mémoire, pendant combien de temps le broker va attendre (en secondes) avant de considérer qu'il n'a pas assez de mémoire, ce qui aura comme conséquence de tuer le module externe concerné. |
broker__manage_brok__sub_process_broks_pusher_min_execution_timeout | 5 | Temps (en seconde) que le broker va laisser aux workers qui poussent les broks vers les modules externes pour s'exécuter. |
broker__manage_brok__sub_process_broks_pusher_security_ratio | 5 | Le broker va estimer le temps d'exécution des workers qui poussent les broks en se basant sur leur moyenne passée, et va appliquer ce ratio multiplicateur comme timeout d'exécution. |
broker__manage_brok__sub_process_broks_pusher_max_execution_timeout | 240 | Temps (en secondes) que le broker va laisser aux workers qui poussent les broks vers les modules externes pour s'exécuter. |
broker__manage_brok__sub_process_broks_pusher_max_retry | 3 | Nombre de tentatives où le broker va relancer les workers qui poussent les broks avant d’arrêter et tuer le module lié. |
enabled | N/A | Cette variable est utilisée pour définir si le broker est activé ou non. |
Définition - exemple
Dans le répertoire /etc/shinken/brokers/, voici un exemple de définition qui permet la définition du Broker (à placer dans un fichier CFG) :
Il est conseillé d'éditer les fichiers .cfg avec l'encodage utf-8
broker__manage_brok_module_broks_getter_early_lock | 0 | Autorise la prise du lock dès la récupération d'un premier broks set (la récupération des broks en retard, et la dé-sérialisation se font alors dans la session critique (Locké) pour disposer d'un maximum de temps CPU) |
broker__manage_brok_module_broks_getter_late_sets_allowed | 10 | Nombre de sets en attente tolérés. Au dessus de ce nombre, les sets sont immédiatement récupérés pour être traités maintenant
|
broker__manage_brok_module_broks_getter_max_late_broks_managed | 200000 | Nombre maximal de broks en retard qu'on peut récupérer pour le traitement actuel
|
broker__manage_brok_module_broks_getter_loop_on_late_broks | 0 | Après traitement des broks, on vérifie s'il reste encore des broks set en retard, si leur nombre dépasse broker_manage_brok_module_broks_getter_late_sets_allowed on garde le lock et on continue l'absorption des broks en retard |
enabled | N/A |
Définition - exemple
Dans le répertoire /etc/shinken/brokers/, voici un exemple de définition qui permet la définition du Broker (à placer dans un fichier CFG) :
Il est conseillé d'éditer les fichiers .cfg avec l'encodage utf-8
| Code Block | ||
|---|---|---|
| ||
#======================= | ||
| Code Block | ||
| ||
#=============================================================================== # BROKER #=============================================================================== # Description: The broker is responsible for: # - Exporting centralized logs of all Shinken daemon processes # - Exporting status data # - Exporting performance data # - Exposing Shinken APIs: # - Status data # - Performance data # - Command interface #======================================================== # BROKER #======================= define broker { #======== Daemon name and address ========= # Daemon name. Must be unique broker_name broker-master # IP/fqdn of this daemon (note: you MUST change it by the real ip/fqdn of this server) address localhost # Port (HTTP/HTTPS) exposed by this daemon port 7772 # 0 = use HTTP, 1 = use HTTPS use_ssl ============================================================== # Description: The broker is responsible for: # - Exporting centralized logs of all Shinken daemon processes # - Exporting status data # - Exporting performance data # - Exposing Shinken APIs: # - Status data # - Performance data # - Command interface #=============================================================================== define broker { #======== Daemon name and address ========= # Daemon name. Must be unique broker_name broker-master # IP/fqdn of this daemon (note: you MUST change it by the real ip/fqdn of this server) address localhost # Port (HTTP/HTTPS) exposed by this daemon port 7772 # 0 = use HTTP, 1 = use HTTPS use_ssl 0 #======== Master or spare selection ========= # 1 = is a spare, 0 = is not a spare spare 0 # spare_daemon: name of the daemon that will take this daemon job if it dies # IMPORTANT: # * a spare_daemon can only be the spare of 1 (and only one) master daemon # * a spare_daemon cannot have a spare_daemon # * the spare must have modules with the same module_type as the master # Example: spare_daemon broker-spare spare_daemon #======== Daemon connection timeout and down state limit ========= # timeout: how many seconds to consider a node don't answer timeout 3 # data_timeout: how many second to consider a configuration transfert to be failed # because the network brandwith is too small. data_timeout 0120 #======== Master or spare selection ========= # 1 = is a spare, 0 = is not a spare max_check_attempts: how many fail check to consider this daemon as DEAD max_check_attempts 3 spare# Check this daemon every X seconds check_interval 060 # spare_daemon: name of the daemon that will take======== Modules to enable for this daemon job if it dies========= # IMPORTANTAvailable: # - Simple-log * a spare_daemon can only be the spare of 1 (and only: one)save masterall daemon logs # * a spare_daemon cannot have a spare_daemoninto a common file # - WebUI * the spare must have modules with the same module_type as the master # Example: spare_daemonvisualisation interface # - Graphite-Perfdata : broker-spare spare_daemon save all metrics into a graphite database #======== Daemon connection timeout and down state limit ========= - sla # timeout: how many seconds to: considersave asla nodeinto don'ta answerdatabase timeout# - Livestatus : TCP API to 3 # data_timeout: how many second to consider a configuration transfert to be failed query element state, used by nagios external tools like NagVis or Thruk modules # because the network brandwith is too small. data_timeout Simple-log, WebUI, Graphite-Perfdata, sla, event-manager-writer 120 # max_check_attempts: how many fail check to consider this daemon as DEAD max_check_attempts#======== Realm and architecture settings ========= # Realm to set this daemon into realm 3 # Check this daemon every X secondsAll check_interval# 1 = take data from the daemon realm and its sub 60realms #======= 0 = Modulestake todata enableonly forfrom thisthe daemon =========realm # Available: manage_sub_realms # - Simple-log 1 # In NATted environments, you declare each satellite ip[: save all logs into a common file # - WebUI port] as seen by # *this* broker (if port not set, the port declared by satellite itself # is used) #satellitemap scheduler-1=1.2.3.4: visualisation interface7768, poller-1=1.2.3.5:7771 # Exchange between brokers <- Graphite-Perfdata : save all metrics into a graphite database # - sla schedulers can be limited by packet size (in kB) # Note: as compression is automatic, this is a higher limit, and in real case the # packets :will savebe slalower intothan athis databasevalue # - Livestatus broks_packet_size 1024 #======== Memory protection ========= : TCP API# toAre querythe elementdaemon state,module usedprocess byand nagiosworker externalprocess toolsare likewaiting NagVisfor or Thrukenough modules# memory to be available before being launch. Default: 1 (enabled) broker__manage_brok__enable_sub_processes_memory_usage_protection Simple-log, WebUI, Graphite-Perfdata, sla, event-manager-writer #======== Realm and architecture settings ========= 1 # The sub process memory usage protection can have a system reserved memory # Realmthat towon't setbe thisused daemonby into theses sub process when realmlaunched # By default: 0 (no reserved memory) # Example: 10 (means 10% All of the total memory #is 1reserved =for takethe datasystem) from the daemon realm and its sub realms broker__manage_brok__sub_process_memory_usage_system_reserved_memory 0 # 0If =a takesub dataprocess onlycannot frombe thestarted daemonbecause realm of the protection, how manage_sub_realms many seconds # 1 # In NATted environments, you declare each satellite ip[:port] as seen byit will be retry and wait that the system memory is freed until it fail to start # *this* broker (if port not set, the port declared by satellite itselfBy default: 5 (seconds) broker__manage_brok__sub_processes_memory_usage_protection_max_retry_time 5 # is used) #satellitemap scheduler-1=1.2.3.4:7768, poller-1=1.2.3.5:7771 ======== Brok pusher worker ========= # ExchangeThe broker betweenspawn brokersbroks <-pusher schedulerssub canprocess beto limitedpush byto packetexternal sizemodules (inlike kBWebUI) # Note:the asbroker compressionwill islook automatic,at this isworker aexecution higher limittime, and inwill kill realif caseit thetimeout # The broker will compute the packetsaverage willexecution betime lowerof thanprevious thisworkers valueto # broks_packet_size 1024 #======== Memory protection ========= decide about how many time this worker will take based on: # Arenumber theof daemonbroks module processto andsend worker/ processpast areaverage waitingsend for enoughspeed (broks/s) # memoryIf tothis betime availableis beforereach, beingit launch.means Default:that 1 (enabled) broker__manage_brok__enable_sub_processes_memory_usage_protection 1the pusher process is killed # The sub process memory usage protection can have a system reserved memory For small amount of broks to send, it should lead to ridicusly small allowed execution time # thatand won'tthe befac usedto byspawn thesesthe sub process whencan launched be higher than # By default: 0 (no reserved memory) # Example: 10 (means 10% of the total memory is reserved for the systemthis value, so we are using a minimal # execution timeout # Default: 5 (second) broker__manage_brok__sub_process_memorybroks_usagepusher_systemmin_reserved_memoryexecution_timeout 05 # If a sub process cannot be started because of the protection, how many secondsIn order to manage the fact that the server can slow down during this send, you can setup a # itratio that will be retryused andto waitincrease that the systemallowed memorytimeout isby freed untilmultiply it fail to start # By defaultDefault: 5 (seconds) broker__manage_brok__sub_processes_memory_usage_protection_max_retry_timeprocess_broks_pusher_security_ratio 5 #======== Brok pusher worker ========= # The broker spawn broks pusher sub process to push to external modules (like WebUI At the broker start without stats, this valud will be used for the timeout # Default: 240 (seconds) # the broker will look at this worker execution time, and will kill if it timeout # The broker will compute the average execution time of previous workers tobroker__manage_brok__sub_process_broks_pusher_max_execution_timeout 240 # If a sub process reach a timeout, it will be killed and relaunched. After max retry, # decidethe aboutattached howmodule manywill timebe thisrestarted worker will take based# onDefault: 3 # number of broks to send / past average send speed (broks/s) broker__manage_brok__sub_process_broks_pusher_max_retry # If this time is reach, it means that the pusher process is killed3 # For small amount of broks to send, it should lead to ridicusly small allowed execution time # and the fac to spawn the sub process can be higher than this value, so we are using a minimal======== Brok getter in modules ========= # These parameters allow some internal tuning in broks management in modules # Take the lock as soon as reader thread has some broks to manage # executionin timeout order to attempt to # Default: 5 (second)reduce concurrent usage of CPU # broker__manage_brok__sub_processmodule_broks_pushergetter_min_execution_timeoutearly_lock 5 # In order to manage the fact that the server1 can slow down during this# send,Take youextra canbroks setupsets a to manage if more #than ratiothis thatparameter willsets beare usedwaiting to increase the allowed# timeout by0 multiplyspecial it value disable managing of #late Default:broks 5sets # broker__manage_brok_module_subbroks_processgetter_brokslate_pusher_security_ratiosets_allowed 510 # AtWhen theenabled brokerwith startprevious withoutparameter, stats,stop thistaking valudextra willbroks besets usedwhen forwe thealready timeouthave # Default: 240 (seconds) this parameter broks to manage # broker__manage_brok__submodule_process_broks_pushergetter_max_late_executionbroks_timeoutmanaged 240 # If200000 a sub process reach a# timeout,After itwe will be killed and relaunched. After max retry, # the attached module will be restarted # Default: 3 have managed some broks, if more than broker__manage_brok_module_broks_getter_late_sets_allowed # broks sets are waiting, continue late sets managing # broker__manage_brok_module_subbroks_processgetter_broksloop_pusheron_maxlate_retrybroks 30 #======== Enable or not this daemon ========= # 1 = is enabled, 0 = is disabled enabled 1 } |

