doc:appunti:linux:sa:cacti_122
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
doc:appunti:linux:sa:cacti_122 [2019/09/05 12:54] – [Controllo hostalive e IPv6] niccolo | doc:appunti:linux:sa:cacti_122 [2022/10/10 16:27] (current) – [Monitoraggio servizio CLAMD] niccolo | ||
---|---|---|---|
Line 294: | Line 294: | ||
</ | </ | ||
+ | ==== CheckCommand con parametri opzionali ==== | ||
+ | |||
+ | Si è avuto un caso particolare in cui il **server NRPE versione 2.15** (in esecuzione sull' | ||
+ | |||
+ | < | ||
+ | nrpe[9169]: Error: Could not complete SSL handshake. | ||
+ | </ | ||
+ | |||
+ | È stato necessario avviare il server NRPE con l' | ||
+ | |||
+ | < | ||
+ | object CheckCommand " | ||
+ | command = [ PluginDir + "/ | ||
+ | arguments = { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | È sufficiente definire la variabile opportuna nella sezione host: | ||
+ | |||
+ | < | ||
+ | object Host " | ||
+ | import " | ||
+ | address = " | ||
+ | vars.nrpe_swraid = " | ||
+ | vars.nrpe_no_ssl = true | ||
+ | } | ||
+ | </ | ||
===== Check passivo ===== | ===== Check passivo ===== | ||
Line 330: | Line 361: | ||
return "No check results received. Last result time: " + lastCheck | return "No check results received. Last result time: " + lastCheck | ||
}} | }} | ||
- | check_interval = 1d /* This determines the freshness of the check. */ | + | check_interval = 1d +1h /* This determines the freshness of the check. */ |
- | retry_interval = 1h /* Execute the active check if freshness is due. */ | + | retry_interval = 1h /* Execute the active check if freshness is due. */ |
- | max_check_attempts = 3 /* Retry the active check some times, before notification. */ | + | max_check_attempts = 3 |
vars.notification_interval = 1d | vars.notification_interval = 1d | ||
} | } | ||
Line 339: | Line 370: | ||
Il // | Il // | ||
- | In condizioni normali viene ricevuto un **check passivo** ogni 24 ore, quindi il check attivo giornaliero (// | + | In condizioni normali viene ricevuto un **check passivo** ogni 24 ore, quindi il check attivo giornaliero (// |
Per definire il servizio associato ad un host si aggiunge ad esempio nel file **/ | Per definire il servizio associato ad un host si aggiunge ad esempio nel file **/ | ||
Line 357: | Line 388: | ||
Il timestamp in formato Unix si può ottenere da una shell Unix con il comando **%%date +%s%%**. | Il timestamp in formato Unix si può ottenere da una shell Unix con il comando **%%date +%s%%**. | ||
+ | |||
+ | La ricezione di un check passivo viene registrata nel log **/ | ||
+ | |||
+ | < | ||
+ | [2022-02-22 02:49:04 +0100] information/ | ||
+ | Executing external command: [1645494544] PROCESS_SERVICE_CHECK_RESULT; | ||
+ | Backup Maildir; | ||
+ | rsync Maildir da Santorini a Naxos eseguito con successo. | ||
+ | </ | ||
+ | |||
+ | ==== Ricezione check passivo via REST API ==== | ||
+ | |||
+ | Si verifica che la **[[# | ||
+ | |||
+ | Nel file **/ | ||
+ | |||
+ | < | ||
+ | // Used to submit passive checks results, e.g. from backup scripts. | ||
+ | object ApiUser " | ||
+ | password = " | ||
+ | permissions = [ " | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Il client che deve inviare l' | ||
+ | |||
+ | <code bash> | ||
+ | ICINGA2_SERVER=' | ||
+ | ICINGA2_USER=' | ||
+ | ICINGA2_PASSWORD=' | ||
+ | |||
+ | SERVICE_HOST=' | ||
+ | SERVICE_NAME=" | ||
+ | EXIT_STATUS=" | ||
+ | EXIT_MESSAGE=" | ||
+ | |||
+ | curl -k -s -u " | ||
+ | -H ' | ||
+ | -X POST " | ||
+ | -d '{ " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | </ | ||
+ | |||
+ | Un servizio Icinga può essere in uno dei seguenti stati: | ||
+ | |||
+ | ^ 0 | OK | | ||
+ | ^ 1 | WARNING | ||
+ | ^ 2 | CRITICAL | ||
+ | ^ 3 | UNKNOWN | ||
==== Server NSCA ==== | ==== Server NSCA ==== | ||
+ | |||
+ | :!: **ATTENZIONE**: | ||
Nell' | Nell' | ||
Line 515: | Line 599: | ||
} | } | ||
</ | </ | ||
+ | ===== Notifica custom su Host ===== | ||
+ | |||
+ | Vediamo come predisporre le notifiche per un singolo host inviando una mail ad un determinato indirizzo. Si crea un file (ad esempio **/ | ||
+ | |||
+ | < | ||
+ | apply Notification " | ||
+ | import " | ||
+ | users = host.vars.notification.mailcustomer.users | ||
+ | times.begin = 3h | ||
+ | interval = 12h | ||
+ | assign where host.vars.notification.mailcustomer | ||
+ | } | ||
+ | |||
+ | object User " | ||
+ | import " | ||
+ | display_name = "Alert for ADSL 1" | ||
+ | email = " | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Le notifiche inizieranno solo **dopo 3 ore** che l'host ha il problema, e verranno ripetute **ogni 12 ore**. Quindi è sufficiente aggiungere una riga alla definizione dell' | ||
+ | |||
+ | < | ||
+ | object Host " | ||
+ | import " | ||
+ | address = " | ||
+ | vars.notification.mailcustomer = { users = [ " | ||
+ | } | ||
+ | </ | ||
+ | |||
===== Modifica servizi predefiniti ===== | ===== Modifica servizi predefiniti ===== | ||
Line 593: | Line 707: | ||
</ | </ | ||
+ | ===== VirtualHost con SSL ===== | ||
+ | |||
+ | Per monitorare il funzionamento basico di un server web è sufficiente definire una variabile **vars.http_vhosts** in una sezione **object Host**: | ||
+ | |||
+ | < | ||
+ | object Host " | ||
+ | import " | ||
+ | address = " | ||
+ | vars.http_vhosts[" | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Il nome tra parentesi quadre è solo una label utilizzata per identificare il servizio nell' | ||
+ | |||
+ | Per un moderno server web tuttavia è necessario verificare la scadenza del certificato SSL ed eventualmente verificare diversi **VirtualHost** che condividono lo stesso indirizzo IP, ma hanno **ServerName** e **certificati SSL** diversi. | ||
+ | |||
+ | In teoria non sarebbe possibile **verificare il certificato SSL di un VirtualHost basato su nome**, perché nella fase iniziale della negoziazione SSL il nome dell' | ||
+ | |||
+ | Ammettendo che il server web sia configurato opportunamente, | ||
+ | |||
+ | < | ||
+ | object Host " | ||
+ | import " | ||
+ | address = " | ||
+ | vars.http_vhosts[" | ||
+ | http_address = " | ||
+ | http_vhost = " | ||
+ | http_ssl = true | ||
+ | http_sni = true | ||
+ | http_certificate = " | ||
+ | } | ||
+ | vars.http_vhosts[" | ||
+ | http_address = " | ||
+ | http_vhost = " | ||
+ | http_ssl = true | ||
+ | http_sni = true | ||
+ | http_certificate = " | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Each **vars.http_vhosts** section correspond to one command invokation, of this type: | ||
+ | |||
+ | < | ||
+ | check_http -H " | ||
+ | </ | ||
+ | |||
+ | ===== Monitoraggio servizio CLAMD ===== | ||
+ | |||
+ | Il programma antivirus **[[http:// | ||
+ | |||
+ | Per impostazione predefinita clamd **non** si mette in ascolto sulla porta **TCP 3310**, è necessario aggiungere queste righe alla configurazione: | ||
+ | |||
+ | < | ||
+ | # Listen also on TCP localhost, to allow running status check. | ||
+ | TCPSocket 3310 | ||
+ | TCPAddr 127.0.0.1 | ||
+ | </ | ||
+ | |||
+ | Il binding viene fatto solo su // | ||
+ | |||
+ | < | ||
+ | command[check_clamd]=/ | ||
+ | </ | ||
+ | |||
+ | Sul server Icinga2 si deve definire il **servizio** aggiungendo in **/ | ||
+ | |||
+ | < | ||
+ | apply Service "CLAMD Service" | ||
+ | import " | ||
+ | check_command = " | ||
+ | assign where host.vars.nrpe_clamd | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Quindi si aggiunge il comando aggiungendo in **/ | ||
+ | |||
+ | < | ||
+ | object CheckCommand " | ||
+ | command = [ PluginDir + "/ | ||
+ | arguments = { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Infine nella sezione **host** relativa all' | ||
+ | |||
+ | < | ||
+ | object Host " | ||
+ | ... | ||
+ | vars.nrpe_clamd = true | ||
+ | ... | ||
+ | } | ||
+ | </ | ||
===== Riferimenti Web ===== | ===== Riferimenti Web ===== | ||
doc/appunti/linux/sa/cacti_122.1567680846.txt.gz · Last modified: 2019/09/05 12:54 by niccolo