| Scroll Ignore | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||
|
Voir la mise en place de la configuration du module : Module named-pipe
Script interpréteur des traps
Le script va se charger d’interpréter les futurs traps SNMP reçus pour les envoyer à Shinken.
Pour un hôte
Ajouter le script suivant que l’on appellera submit_host_result_to_receiver dans le dossier des plugins Shinken (/var/lib/shinken-user/libexec/):
| Code Block |
|---|
#!/bin/bash # Arguments: # ${1} = host_name (Short name of host that the service is associated with) # ${3} = return_code (An integer that determines the state of the service check, 0=OK, 1=WARNING, 2=CRITICAL,3=UNKNOWN). # ${4} = plugin_output (A text string that should be used as the plugin output for the service check) # Ensuring we use the correct commands by using their full absolute path echocmd="/bin/echo" commandfile="/var/lib/shinken/shinken.cmd" # get the current date/time in seconds since UNIX epoch datetime="$(date +%s)" # create the command line to add to the command file cmdline="[${datetime}] PROCESS_HOST_CHECK_RESULT;${1};${2};${3}" # append the command to the end of the command file ${echocmd} "${cmdline}" >> "${commandfile}" |
On le rend exécutable et on le donne à l’utilisateur Shinken
| Code Block |
|---|
chown shinken:shinken /var/lib/shinken-user/libexec/submit_host_result_to_receiver
chmod +x /var/lib/shinken-user/libexec/submit_host_result_to_receiver |
Pour tester le script et simuler une réception d'un trap translaté au format Shinken, il suffit d’exécuter la commande suivante qui va faire passer l'hôte en état critique :
| Code Block |
|---|
/var/lib/shinken-user/libexec/submit_host_result_to_receiver HÔTE 2 "test envoi trap - CRITIQUE" |
| Info |
|---|
Les arguments sont :
|
Le résultat court de l'hôte devrait passer en critique, et si au bout de la période du seuil de fraîcheur, aucun nouveau trap n'a été reçu, alors la commande check-host-alive fera repasser le check à OK ( si bien sûr l'hôte est accessible via le réseau ).
Pour un check
Ajouter le script suivant que l’on appellera submit_check_result_to_receiver dans le dossier des plugins Shinken (/var/lib/shinken-user/libexec/):
| Code Block |
|---|
#!/bin/bash
# Arguments:
# ${1} = host_name (Short name of host that the service is associated with)
# ${2} = svc_description (Description of the service)
# ${3} = return_code (An integer that determines the state of the service check, 0=OK, 1=WARNING, 2=CRITICAL,3=UNKNOWN).
# ${4} = plugin_output (A text string that should be used as the plugin output for the service check)
# Ensuring we use the correct commands by using their full absolute path
echocmd="/bin/echo" commandfile="/var/lib/shinken/shinken.cmd"
# get the current date/time in seconds since UNIX epoch
datetime="$(date +%s)"
# create the command line to add to the command file
cmdline="[${datetime}] PROCESS_SERVICE_CHECK_RESULT;${1};${2};${3};${4}"
# append the command to the end of the command file
${echocmd} "${cmdline}" >> "${commandfile}" |
On le rend exécutable et on le donne à l’utilisateur Shinken
| Code Block |
|---|
chown shinken:shinken /var/lib/shinken-user/libexec/submit_check_result_to_receiver chmod +x /var/lib/shinken-user/libexec/submit_check_result_to_receiver |
Pour tester le script et simuler une réception d'un trap translaté au format Shinken, il suffit d’exécuter la commande suivante qui va faire passer le service en état critique :
| Code Block |
|---|
/var/lib/shinken-user/libexec/submit_check_result_to_receiver TRAPHÔTE CHECK 2 "test envoi trap - CRITIQUE" |
| Info |
|---|
Les arguments sont :
|
Le check devrait passer en critique, et si au bout de la période du seuil de fraîcheur, aucun nouveau trap n'a été reçu, alors la commande check-host-alive fera repasser le check à OK ( si bien sûr l'hôte est accessible via le réseau ).