Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions bin/pd-nagios
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand Down
20 changes: 18 additions & 2 deletions conf.d/pagerduty-icinga2.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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$"
}
Expand Down Expand Up @@ -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$"
}
Expand Down