Skip to content

Commit

Permalink
nagios integration: Support setting "priority"
Browse files Browse the repository at this point in the history
Based on similar pull request for Iciniga 2 integration by tobiasvdk:
  opsgenie#53
(not sure if it wouldn't be better to fail than only log if validation
of specified priority fails)
  • Loading branch information
ickiller committed Mar 30, 2022
1 parent 55d5fa5 commit bbc3f9b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions nagios/nagios/nagios2opsgenie.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ func parseFlags_readConfig_setupLogging() {

responders := flag.String("responders", "", "Responders")
tags := flag.String("tags", "", "Tags")
priority := flag.String("priority", "", "Priority (P1...P5)")

flag.Parse()

Expand Down Expand Up @@ -372,6 +373,15 @@ func parseFlags_readConfig_setupLogging() {
parameters["tags"] = configParameters["tags"]
}

if *priority == "" {
parameters["priority"] = ""
} else if IsValidPriority(*priority) {
parameters["priority"] = *priority
} else {
logger.Warning("Priority is not valid, needs to be one of P1, P2, P3, P4, P5.")
parameters["priority"] = ""
}

parameters["entity_type"] = *entityType

parameters["notification_type"] = *notificationType
Expand Down Expand Up @@ -452,3 +462,16 @@ func parseFlags_readConfig_setupLogging() {
}
}
}

func IsValidPriority(priority string) bool {
switch priority {
case
"P1",
"P2",
"P3",
"P4",
"P5":
return true
}
return false
}

0 comments on commit bbc3f9b

Please sign in to comment.