User Tools

Site Tools


doc:appunti:linux:sa:cacti_122

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
doc:appunti:linux:sa:cacti_122 [2022/03/14 18:00] – [Server NSCA] niccolodoc:appunti:linux:sa:cacti_122 [2022/03/14 18:23] – [Server NSCA] niccolo
Line 397: Line 397:
     rsync Maildir da Santorini a Naxos eseguito con successo.     rsync Maildir da Santorini a Naxos eseguito con successo.
 </code> </code>
 +
 +==== Ricezione check passivo via REST API ====
 +
 +Si verifica che la **[[#rest_api_interface|REST API interface]]** sia attiva (è la stessa che viene usata dal modulo **Icinga Web 2**). Dovrebbe essere in ascolto sulla porta **TCP/5665**.
 +
 +Nel file **/etc/icinga2/conf.d/api-users.conf** si definisce un utente con password che abbia l'autorizzazione ad inviare i risultati dei check. L'unico permesso richiesto è **actions/process-check-result**:
 +
 +<file>
 +// Used to submit passive checks results, e.g. from backup scripts.
 +object ApiUser "passive-check" {
 +  password = "MyUserSecret"
 +  permissions = [ "actions/process-check-result" ]
 +}
 +</file>
 +
 +Il client che deve inviare l'esito del check passivo può utilizzare ad esempio **curl**, con autenticazione su protocollo https:
 +
 +<code bash>
 +ICINGA2_SERVER='icinga2.rigacci.org'
 +ICINGA2_USER='passive-check'
 +ICINGA2_PASSWORD='MyUserSecret'
 +
 +SERVICE_HOST='Naxos'
 +SERVICE_NAME="Backup Remote Rsync"
 +EXIT_STATUS="0"
 +EXIT_MESSAGE="[OK] Rsync to remote storage"
 +
 +curl -k -s -u "${ICINGA2_USER}:${ICINGA2_PASSWORD}" \
 +    -H 'Accept: application/json' \
 +    -X POST "https://${ICINGA2_SERVER}:5665/v1/actions/process-check-result" \
 +    -d '{ "type": "Service",
 +          "filter": "host.name==\"'"$SERVICE_HOST"'\" && service.name==\"'"$SERVICE_NAME"'\"",
 +          "exit_status": '"$EXIT_STATUS"',
 +          "plugin_output": "'"$EXIT_MESSAGE"'" }' > /dev/null
 +</code>
 +
 +Un servizio Icinga può essere in uno dei seguenti stati:
 +
 +^  0 | OK        |
 +^  1 | WARNING   |
 +^  2 | CRITICAL  |
 +^  3 | UNKNOWN   |
  
 ==== Server NSCA ==== ==== Server NSCA ====
doc/appunti/linux/sa/cacti_122.txt · Last modified: 2022/10/10 16:27 by niccolo