Skip to content

Commit

Permalink
Support setting "priority" in Icinga 2 integration
Browse files Browse the repository at this point in the history
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 opsgenie#52

Signed-off-by: Tobias von der Krone <[email protected]>
  • Loading branch information
Tobias von der Krone committed Sep 10, 2019
1 parent e9117a5 commit dfadc73
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions icinga2/icinga2/icinga2opsgenie.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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){
Expand Down
4 changes: 4 additions & 0 deletions icinga2/icinga2/opsgenie.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -48,13 +49,15 @@ object NotificationCommand "opsgenie-service-notification" {
"-lssc" = "$service.last_state_change$"
"-so" = "$service.output$"
"-spd" = "$service.perfdata$"
"-priority" = "$priority$"
}
}

object NotificationCommand "opsgenie-host-notification" {
import "plugin-notification-command"

vars.hgns = {{ host.groups.join(",") }}
vars.priority = "P3"
command = [ "/usr/bin/icinga2opsgenie" ]
arguments = {
"-entityType" = "host"
Expand All @@ -81,6 +84,7 @@ object NotificationCommand "opsgenie-host-notification" {
"-lhsc" = "$host.last_state_change$"
"-ho" = "$host.output$"
"-hpd" = "$host.perfdata$"
"-priority" = "$priority$"
}
}

Expand Down

0 comments on commit dfadc73

Please sign in to comment.