Kann ich mein SMS Gateway an Icinga 2 anbinden?

 

 

Selbstverständlich können Sie Ihr SMS Gateway dazu nutzen Alarme aus Icinga 2 via SMS zu versenden.

 

 

ê Es wird empfohlen einen neuen Systembenutzer für die Verwendung des nötigen Skripts anzulegen. Das Skript verwendet die HTTP-API des SMS Gateways.

 

 

 

Download-links:

https://github.com/NETWAYS/notify-brevisone

https://github.com/NETWAYS/notify-brevisone/releases/tag/v0.1.0

 

 

 

1. Herunterladen und Konfigurieren des nötigen Skripts

 

Hierzu benötigen Sie zunächst das Skript sendsms.sh. Laden Sie es herunter und legen Sie es auf Ihrem Centreon Server im Verzeichnis /usr/local/bin/ ab.

 

Im Verzeichnis /usr/local/bin/ legen Sie eine Datei "config" an. Die Datei "config" enthält die Konfiguration für das Skript.

 

 

username=<myuser>

 

password=<mypassword>

 

host=<IP Addresse des SMS Gateways>

 

#mode=<Mögliche Modis können hier entnommen werden>

 

#insecuressl=true

 

#proxy=[protocol://][user:password@]proxyhost[:port]

 

 

Mit # begonnene Zeilen gelten als Kommentare. Die auskommentierten Optionen sind nicht notwendig.

 

Die Option insecuressl=true schaltet die Zertifikatsüberprüfung ab.

 

Alle über die "config" Datei konfigurierten Werte können über Parameter überschrieben werden.

 

 

2. Konfiguration Icinga 2

 

In diesem Schritt müssen nun Kommandos für die SMS Benachrichtigung in Icinga 2 konfiguriert werden. Außerdem müssen entsprechende Kontakte angelegt werden.

 

1. Beispiel: Definition für SMS Benachrichtigungen in /etc/icinga2/conf.d/commands.conf

 

object NotificationCommand "braintower-host-notification" {

import "plugin-notification-command"

command = [ PluginDir + "/sendsms.sh" ]

arguments = {

"-pager" = {

value = "$braintower_pager$"

description = "Telephone number of the SMS recipient"

skip_key = true

}

"-message" = {

value = "$braintower_message$"

description = "SMS message text"

skip_key = true

}

}

vars.braintower_pager = "$user.pager$"

vars.braintower_message = "$notification.type$ - Host $host.display_name$ is $host.state$ since $icinga.long_date_time$ info: $host.output$"

}

 

 

 

object NotificationCommand "braintower-service-notification" {

import "plugin-notification-command"

command = [ PluginDir + "/sendsms.sh" ]

arguments = {

"-pager" = {

value = "$braintower_pager$"

description = "Telephone number of the SMS recipient"

skip_key = true

}

"-message" = {

value = "$braintower_message$"

description = "SMS message text"

skip_key = true

}

}

vars.braintower_pager = "$user.pager$"

vars.braintower_message = "$notification.type$ - Host $host.display_name$ is $host.state$ since $icinga.long_date_time$ info: $host.output$"

}

 

 

 

2. Beispiel: Definition von Host-/Service Templates für SMS Benachrichtigungen in /etc/icings2/conf.d/templates.conf

 

template Notification "braintower-host-notification" {

command = "braintower-host-notification"

states = [ Up, Down ]

types = [ Problem, Acknowledgement, Recovery, Custom, FlappingStart, FlappingEnd, DowntimeStart, DowntimeEnd, DowntimeRemoved ]

period = "24x7"

}

 

 

 

template Notification "braintower-service-notification" {

command = "braintower-service-notification"

states = [ OK, Warning, Critical, Unknown ]

types = [ Problem, Acknowledgement, Recovery, Custom, FlappingStart, FlappingEnd, DowntimeStart, DowntimeEnd, DowntimeRemoved ]

period = "24x7"

}

 

 

 

3. Beispiel: Host-/Service Templates für SMS Benachrichtigungen auf einen Host binden in /etc/icinga2/conf.d/notifications.conf

 

apply Notification "braintower-alerts" to Host {

import "braintower-host-notification"

user_groups = host.vars.notification.sms.groups

assign where host.vars.notification.sms

}

 

 

 

apply Notification "braintower-alerts" to Service {

import "braintower-service-notification"

user_groups = host.vars.notification.sms.groups

assign where host.vars.notification.sms

}

 

 

 

4. Beispiel: Definition einer Benutzergruppe für SMS Benachrichtigungen in /etc/icinga2/conf.d/groups.conf

 

object UserGroup "smsusers" {

display_name = "Icinga 2 SMS Group"

}

 

 

 

5. Beispiel: Einen Kontakt zur Benutzergruppe für SMS Benachrichtigungen hinzufügen /etc/icinga2/conf.d/users.conf

 

object User "Max_Muster" {

import "generic-user"

display_name = "Max Muster"

groups = [ "smsusers" ]

pager = "00491701234567"

}

 

 

 

 

 

 

Verwandte Artikel