Monitoraggio dello SLA dei servizi controllati di Centreon

Qualcosa di curioso e che a seconda delle circostanze può tornare utile potrebbe essere quello di conoscere lo SLA di qualsiasi servizio che stiamo attualmente monitorando nei nostri centri. Può anche essere progettato per quando monitoriamo a livello aziendale, per dare visibilità alla tua disponibilità.

Come sappiamo, Centreon almacena sus métricas y estados en una BD de MariaDB, podemos sencillamente mediante queries de MySQL sacar en tiempo o en % el estado de un Servicio monitorado en Centreon. Podremos saber cuánto tiempo (o porcentaje) ha estado en estado OK, Avvertimento, Critico, Unknown o en Mantenimiento. Per cosa? Bene, de todos es sabido que podemos conocer el SLA de cualquier Host o Servicio en Centreon, pero otra cosa es monitorarlo para alertarnos de quando este no se cumple, o per esempio para visualizarlos en nuestro Servicio de Negocios via NagVis.

Non male, para comenzar sarebbe interessante che si no stai monitorando query de MySQL, eches un vistazo a Questo post. quando tengas già lo script che permette di fare consultas a BBDD de MySQL, podremo creare i Comandos che necesitamos y ogni uno con il suo tipo di consulta. Ya que unos comandos nos servirán para monitorizar el SLA de Hosts, otros de Servicios, otros nos darán el resultado en tiempo y otros en %, así que dependiendo lo que necesites te dejo aquí ciertas posibilidades:

  • SLA de Servicios OK en %:
$CENTREONPLUGINS$/Nagios-Plugins/check_mysql_query.pl -q "SELEZIONA ROUND((SOMMA(OKTimeScheduled)/($ARG1$ * 86400))*100,2) as porcentaje FROM log_archive_service, services  WHERE log_archive_service.service_id = services.service_id AND description = '$ARG2$' AND from_unixtime(date_end) > date_sub(ora(), INTERVALLO $ARG 1$ giorno) order BY log_id DESC" -H 127.0.0.1 -d centreon_storage -u centreon -p CONTRASEÑA_USUARIO_CENTREON -t 60 --no-querytime -T -g -l 'SLA' -U %

  • SLA de Servicios OK en Tiempo:
$CENTREONPLUGINS$/Nagios-Plugins/check_mysql_query.pl -q "SELEZIONA CONCAT(PAVIMENTO(ORA(sec_to_time(SOMMA(OKTimeScheduled))) / 24), 'd_', MOD(ORA(sec_to_time(SOMMA(OKTimeScheduled))), 24), 'h_', MINUTO(sec_to_time(SOMMA(OKTimeScheduled))), 'm') AS Tiempo FROM log_archive_service, services  WHERE log_archive_service.service_id = services.service_id AND description = '$ARG2$' AND from_unixtime(date_end) > date_sub(ora(), INTERVALLO $ARG 1$ giorno) order BY log_id DESC" -H 127.0.0.1 -d centreon_storage -u centreon -p CONTRASEÑA_USUARIO_CENTREON -t 60 --no-querytime -T -g -l 'SLA'

  • SLA de Servicios Warning en %:
$CENTREONPLUGINS$/Nagios-Plugins/check_mysql_query.pl -q "SELEZIONA ROUND((SOMMA(WARNINGTimeScheduled)/($ARG1$ * 86400))*100,2) as porcentaje FROM log_archive_service, services  WHERE log_archive_service.service_id = services.service_id AND description = '$ARG2$' AND from_unixtime(date_end) > date_sub(ora(), INTERVALLO $ARG 1$ giorno) order BY log_id DESC" -H 127.0.0.1 -d centreon_storage -u centreon -p CONTRASEÑA_USUARIO_CENTREON -t 60 --no-querytime -T -g -l 'SLA' -U %

  • SLA de Servicios Warning en Tiempo:
$CENTREONPLUGINS$/Nagios-Plugins/check_mysql_query.pl -q "SELEZIONA CONCAT(PAVIMENTO(ORA(sec_to_time(SOMMA(WARNINGTimeScheduled))) / 24), 'd_', MOD(ORA(sec_to_time(SOMMA(WARNINGTimeScheduled))), 24), 'h_', MINUTO(sec_to_time(SOMMA(WARNINGTimeScheduled))), 'm') AS Tiempo FROM log_archive_service, services  WHERE log_archive_service.service_id = services.service_id AND description = '$ARG2$' AND from_unixtime(date_end) > date_sub(ora(), INTERVALLO $ARG 1$ giorno) order BY log_id DESC" -H 127.0.0.1 -d centreon_storage -u centreon -p CONTRASEÑA_USUARIO_CENTREON -t 60 --no-querytime -T -g -l 'SLA'

  • SLA de Servicios Critical en %:
$CENTREONPLUGINS$/Nagios-Plugins/check_mysql_query.pl -q "SELEZIONA ROUND((SOMMA(CRITICALTimeScheduled)/($ARG1$ * 86400))*100,2) as porcentaje FROM log_archive_service, services  WHERE log_archive_service.service_id = services.service_id AND description = '$ARG2$' AND from_unixtime(date_end) > date_sub(ora(), INTERVALLO $ARG 1$ giorno) order BY log_id DESC" -H 127.0.0.1 -d centreon_storage -u centreon -p CONTRASEÑA_USUARIO_CENTREON -t 60 --no-querytime -T -g -l 'SLA' -U %

  • SLA de Servicios Critical en Tiempo:
$CENTREONPLUGINS$/Nagios-Plugins/check_mysql_query.pl -q "SELEZIONA CONCAT(PAVIMENTO(ORA(sec_to_time(SOMMA(CRITICALTimeScheduled))) / 24), 'd_', MOD(ORA(sec_to_time(SOMMA(CRITICALTimeScheduled))), 24), 'h_', MINUTO(sec_to_time(SOMMA(CRITICALTimeScheduled))), 'm') AS Tiempo FROM log_archive_service, services  WHERE log_archive_service.service_id = services.service_id AND description = '$ARG2$' AND from_unixtime(date_end) > date_sub(ora(), INTERVALLO $ARG 1$ giorno) order BY log_id DESC" -H 127.0.0.1 -d centreon_storage -u centreon -p CONTRASEÑA_USUARIO_CENTREON -t 60 --no-querytime -T -g -l 'SLA'

  • SLA de Hosts Uptime en %:
$CENTREONPLUGINS$/Nagios-Plugins/check_mysql_query.pl -q "SELEZIONA ROUND((SOMMA(UPTimeProgrammato)/($ARG1$ * 86400))*100,2) in percentuale FROM host, log_archive_host DOVE log_archive_host.host_id = hosts.host_id E hosts.name = '$ARG 2$' E from_unixtime(date_end) > date_sub(ora(), INTERVALLO $ARG 1$ giorno)  ordina PER date_end DESC" -H 127.0.0.1 -d centreon_storage -u centreon -p CONTRASEÑA_USUARIO_CENTREON -t 60 --no-querytime -T -g -l 'SLA' -U %

  • SLA de Hosts Uptime en Tiempo:
$CENTREONPLUGINS$/Nagios-Plugins/check_mysql_query.pl -q "SELEZIONA CONCAT(PAVIMENTO(ORA(sec_to_time(SOMMA(UPTimeProgrammato))) / 24), 'd_', MOD(ORA(sec_to_time(SOMMA(UPTimeProgrammato))), 24), 'h_', MINUTO(sec_to_time(SOMMA(UPTimeProgrammato))), 'm') AS Tiempo FROM padroni di casa, log_archive_host DOVE log_archive_host.host_id = hosts.host_id E hosts.name = '$ARG 2$' E from_unixtime(date_end) > date_sub(ora(), INTERVALLO $ARG 1$ giorno)  ordina PER date_end DESC" -H 127.0.0.1 -d centreon_storage -u centreon -p CONTRASEÑA_USUARIO_CENTREON -t 60 --no-querytime -T -g -l 'SLA'

  • SLA di inattività degli host in %:
$CENTREONPLUGINS$/Nagios-Plugins/check_mysql_query.pl -q "SELEZIONA ROUND((SOMMA(INATTIVITÀ programmata)/($ARG1$ * 86400))*100,2) in percentuale FROM host, log_archive_host DOVE log_archive_host.host_id = hosts.host_id E hosts.name = '$ARG 2$' E from_unixtime(date_end) > date_sub(ora(), INTERVALLO $ARG 1$ giorno)  ordina PER date_end DESC" -H 127.0.0.1 -d centreon_storage -u centreon -p CONTRASEÑA_USUARIO_CENTREON -t 60 --no-querytime -T -g -l 'SLA' -U %

  • SLA di inattività degli host in tempo:
$CENTREONPLUGINS$/Nagios-Plugins/check_mysql_query.pl -q "SELEZIONA CONCAT(PAVIMENTO(ORA(sec_to_time(SOMMA(INATTIVITÀ programmata))) / 24), 'd_', MOD(ORA(sec_to_time(SOMMA(INATTIVITÀ programmata))), 24), 'h_', MINUTO(sec_to_time(SOMMA(INATTIVITÀ programmata))), 'm') AS Tiempo FROM padroni di casa, log_archive_host DOVE log_archive_host.host_id = hosts.host_id E hosts.name = '$ARG 2$' E from_unixtime(date_end) > date_sub(ora(), INTERVALLO $ARG 1$ giorno)  ordina PER date_end DESC" -H 127.0.0.1 -d centreon_storage -u centreon -p CONTRASEÑA_USUARIO_CENTREON -t 60 --no-querytime -T -g -l 'SLA'

E ora manca solo creare tanti Servizi per monitorare lo SLA quanto ci interessa, in questo caso pratico, io li sto usando solo per misurare lo SLA dei Servizi di Business, e quindi per visualizzarli in NagVis. Come argomenti metteremo i giorni dello SLA che ci interessa vedere e nel Nome del Servizio, il nome unico di un Servizio da controllare.

E come sempre, dopo aver salvato ed esportato la configurazione, avremo i nostri servizi SLA pronti per essere controllati tramite una query nel database di Centreon il tempo o la percentuale dello stato di un Servizio.

E in NagVis, con el Gadget de RawNumbers podremos añadir los ítems SLA monitorizados y quedará más atractivo a la hora de movernos entre mapas y conocer el SLA que ofrece cualquier servicio, ideal para perfiles no 100% técnicos y quieran conocer el estado de su infraestructura en tiempo real.

Post consigliati

Autore

nheobug@bujarra.com
Autor del blog Bujarra.com Cualquier necesidad que tengas, Non esitate a contattarmi, Cercherò di aiutarti ogni volta che potrò, Condividere è vivere ;) . Goditi i documenti!!!

Libro PowerShell in spagnolo

18 Novembre 2021