There’s a few steps involved in order to pass details to a script:
Ensure that the notification script reads parameters from the CLI or via environment variable - you can test that standalone on your terminal.
script.sh --notes="...." --notes-url="..."
Depending on the script language you’re using, you’ll need to implement and extend getopts for this.
Extend the NotificationCommand and add additional arguments with using the previously added script parameters. Use placeholder runtime macros, you’ll need them in the actual notification object later.
Basically I’m using the standard-bash-script for notifications that comes with the Icinga installation and what works (as in: compiles an EMail from CLI with all given information) is: ./mail-service-notification_notes.sh -d "2019-04-23" -e "testservice" -l "testhost" -n "testus0r" -o "all cool" -r "testus0r@domain.org" -s "OK" -t "custom" -u "testservice" -a "here goes the notes and with -b I send the notes-URL" -b "https://www.google.de"
What gives me a headache is how I actually fill -a and -b with the Information from Icinga.
It looks ok, but I would only set these parameters if the host/service objects actually have them. That is why I have done the extra step with the parameter names inside the notification, only setting them if those attributes actually exist.
apply Notification "..." to Service {
...
if (service.notes != "") {
vars.notification_notes = service.notes
} else if (host.notes != "") {
vars.notification_nodes = host.notes //fallback
}
if (service.notes_url != "") {
vars.notification_notes_url = service.notes_url
} else if (host.notes_url != "") {
vars.notification_notes_url = host.notes_url //fallback
}
...
}
In case you’re using the Director, you cannot use this method, and yours is more simple. It only needs proper error handling inside the script, e.g. what to show when notes_url is empty (hide the row for instance).
Go for it - sharing the knowledge is key for future adventures Just hop onto #howto and explore how others structure theirs, with markdown formatting including headings, etc.