diff --git a/nagios/nagios/nagios2opsgenie.go b/nagios/nagios/nagios2opsgenie.go index c497c1d..010504f 100644 --- a/nagios/nagios/nagios2opsgenie.go +++ b/nagios/nagios/nagios2opsgenie.go @@ -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() @@ -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 @@ -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 +}