Page 1 of 1
Nagios XI URL In Notifications
Posted: Tue Jan 04, 2022 8:26 am
by shoreypu
I found the following article about adding the Nagios Core URL in Notifications,
https://support.nagios.com/kb/article/n ... s-765.html.
Is there an option to add the Nagios XI URL in Notifications instead?
Thanks in advance...John
Re: Nagios XI URL In Notifications
Posted: Tue Jan 04, 2022 4:42 pm
by ssax
If the Contact has an associated user in Admin > Manage Users and is using the xi_host_notification_handler and xi_service_notification_handler notification commands you can follow this to adjust the notification templates:
https://assets.nagios.com/downloads/nag ... iables.pdf
If they are just Core Contacts (what we call contacts that do not have an associated user of the same name that use notify-host-by-email and notify-service-by-email commands), you would just follow the same KB you linked to but add the XI URL to it.
Code: Select all
website_url=http://YOURXISERVER/nagiosxi/
See here under the Notifications columns for what other macros are available for use by the notifications commands:
https://assets.nagios.com/downloads/nag ... olist.html
See here for reference:
https://assets.nagios.com/downloads/nag ... ntacts.pdf
Re: Nagios XI URL In Notifications
Posted: Wed Jan 05, 2022 2:11 pm
by shoreypu
So we are using the later (Core Contacts). I did try to using website_url=
http://YOURXISERVER/nagiosxi/ as you had suggested, but the URL I'm receiving doesn't work. Note, we are using https, not http.
For example, using $SERVICEINFOURL$:
https://YOURXISERVER/nagiosxi/cgi-bin/e ... rvicecheck
Result: Not Found - The requested URL /nagiosxi/cgi-bin/extinfo.cgi was not found on this server.
However, using
https://YOURXISERVER/nagios/cgi-bin/ext ... rvicecheck takes me to the service details in the Core interface.
For reference, this is the permalink for the service details in the XI interface:
https://YOURXISERVER/nagiosxi/?xiwindow ... est%3Dauto
John
Re: Nagios XI URL In Notifications
Posted: Wed Jan 05, 2022 6:52 pm
by ssax
I apologize, I misunderstood.
That's a bit more difficult because the hostname and servicedesc in the URL needs to be urlencoded, you could do this:
Code: Select all
cd /usr/local/nagios/libexec
wget https://gist.githubusercontent.com/cdown/1163649/raw/c3a30da93e94828918dcf3918e995726f445fc25/gistfile1.sh
chown apache.nagios gistfile1.sh
chmod 660 gistfile1.sh
Then you could define your commands like this:
Code: Select all
define command {
command_name notify-host-by-email
command_line . /usr/local/nagios/libexec/gistfile1.sh && /usr/bin/printf "%b" "***** Nagios Monitor XI Alert *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n\nHost Info URL: https://X.X.X.X/nagiosxi/includes/components/xicore/status.php?show=hostdetail&host=`urlencode '$HOSTNAME$'`\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}
define command {
command_name notify-service-by-email
command_line . /usr/local/nagios/libexec/gistfile1.sh && /usr/bin/printf "%b" "***** Nagios Monitor XI Alert *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n\nService Info URL: https://X.X.X.X/nagiosxi/includes/components/xicore/status.php?show=servicedetail&host=`urlencode '$HOSTNAME$'`&service=`urlencode '$SERVICEDESC$'`&dest=auto\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}
EDIT: To change the From address on the notifications you can change this portion of each command:
To:
Re: Nagios XI URL In Notifications
Posted: Fri Jan 14, 2022 7:56 am
by shoreypu
I was able to get the links working in our test environment. Thanks!!!
This topic can be considered closed.