diff --git a/bin/pd-nagios b/bin/pd-nagios index 681b72c..bf1b045 100755 --- a/bin/pd-nagios +++ b/bin/pd-nagios @@ -44,12 +44,14 @@ class NagiosEvent: ) } - def __init__(self, service_key, event_type, notification_type, details, incident_key=None): + def __init__(self, service_key, event_type, notification_type, details, incident_key=None, client="", client_url=""): self._service_key = service_key self._event_type = event_type self._notification_type = notification_type self._details = dict(details.items() + [("pd_nagios_object", self._notification_type)]) self._given_incident_key = incident_key + self._client = client + self._client_url = client_url def enqueue(self): from pdagent.config import load_agent_config @@ -62,8 +64,8 @@ class NagiosEvent: self._service_key, self._incident_key(), self._event_description(), - "", - "", + self._client, + self._client_url, self._details, agent_config.get_agent_id(), "pd-nagios" @@ -123,7 +125,9 @@ def main(): args.event_type, args.notification_type, details, - args.incident_key + args.incident_key, + args.client, + args.client_url ) try: @@ -171,6 +175,20 @@ def build_queue_arg_parser(description): help="Nagios notification type (host or service)", choices=["service", "host"] ) + parser.add_argument( + "-c", + "--client", + dest="client", + help="Client Name", + default="" + ) + parser.add_argument( + "-u", + "--client-url", + dest="client_url", + help="Client URL", + default="" + ) return parser def parse_fields(fields): diff --git a/conf.d/pagerduty-icinga2.conf b/conf.d/pagerduty-icinga2.conf index 7353b41..7d06b2b 100644 --- a/conf.d/pagerduty-icinga2.conf +++ b/conf.d/pagerduty-icinga2.conf @@ -22,8 +22,16 @@ object NotificationCommand "notify-service-by-pagerduty" { order = 2 value = "$notification.type$" } - "-f" = { + "-c" = { order = 3 + value = NodeName + } + "-u" = { + order = 4 + value = "https://"+NodeName+"/icingaweb2" + } + "-f" = { + order = 5 repeat_key = true value = "$f_args$" } @@ -57,8 +65,16 @@ object NotificationCommand "notify-host-by-pagerduty" { order = 2 value = "$notification.type$" } - "-f" = { + "-c" = { order = 3 + value = NodeName + } + "-u" = { + order = 4 + value = "https://"+NodeName+"/icingaweb2" + } + "-f" = { + order = 5 repeat_key = true value = "$f_args$" }