From dfadc7366c44c4703f86ae260970000897c4f2e2 Mon Sep 17 00:00:00 2001 From: Tobias von der Krone Date: Tue, 10 Sep 2019 20:56:59 +0200 Subject: [PATCH] Support setting "priority" in Icinga 2 integration Add a parameter to set the priority of an alert in the Icinga 2 intergration. This is necessary since host down alerts mostly are of priority P1. refs #52 Signed-off-by: Tobias von der Krone --- icinga2/icinga2/icinga2opsgenie.go | 3 +++ icinga2/icinga2/opsgenie.conf | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/icinga2/icinga2/icinga2opsgenie.go b/icinga2/icinga2/icinga2opsgenie.go index f29c743..a245399 100644 --- a/icinga2/icinga2/icinga2opsgenie.go +++ b/icinga2/icinga2/icinga2opsgenie.go @@ -308,6 +308,7 @@ func parseFlags()map[string]string{ responders := flag.String("responders","","Responders") tags := flag.String("tags","","Tags") + priority := flag.String("priority","","Priority") flag.Parse() @@ -388,6 +389,8 @@ func parseFlags()map[string]string{ parameters["service_perf_data"] = *servicePerfData parameters["service_check_command"] = *serviceCheckCommand + parameters["priority"] = *priority + args := flag.Args() for i := 0; i < len(args); i += 2 { if(len(args)%2 != 0 && i==len(args)-1){ diff --git a/icinga2/icinga2/opsgenie.conf b/icinga2/icinga2/opsgenie.conf index 3533409..c40675d 100644 --- a/icinga2/icinga2/opsgenie.conf +++ b/icinga2/icinga2/opsgenie.conf @@ -3,6 +3,7 @@ object NotificationCommand "opsgenie-service-notification" { vars.hgns = {{ host.groups.join(",") }} vars.sgns = {{ service.groups.join(",") }} + vars.priority = "P3" command = [ "/usr/bin/icinga2opsgenie" ] arguments = { "-entityType" = "service" @@ -48,6 +49,7 @@ object NotificationCommand "opsgenie-service-notification" { "-lssc" = "$service.last_state_change$" "-so" = "$service.output$" "-spd" = "$service.perfdata$" + "-priority" = "$priority$" } } @@ -55,6 +57,7 @@ object NotificationCommand "opsgenie-host-notification" { import "plugin-notification-command" vars.hgns = {{ host.groups.join(",") }} + vars.priority = "P3" command = [ "/usr/bin/icinga2opsgenie" ] arguments = { "-entityType" = "host" @@ -81,6 +84,7 @@ object NotificationCommand "opsgenie-host-notification" { "-lhsc" = "$host.last_state_change$" "-ho" = "$host.output$" "-hpd" = "$host.perfdata$" + "-priority" = "$priority$" } }