Nagios xi URL In Notifications

This support forum board is for support questions relating to Nagios xi, our flagship commercial network monitoring solution.
shoreypu
Posts: 114
Joined: Wed Mar 13, 2019 2:06 pm

Nagios xi URL In Notifications

Post 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
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Nagios xi URL In Notifications

Post 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
shoreypu
Posts: 114
Joined: Wed Mar 13, 2019 2:06 pm

Re: Nagios xi URL In Notifications

Post 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
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Nagios xi URL In Notifications

Post 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:

Code: Select all

/bin/mail -s
To:

Code: Select all

/bin/mail -r 'Nagios xi <some@email.com>' -s
shoreypu
Posts: 114
Joined: Wed Mar 13, 2019 2:06 pm

Re: Nagios xi URL In Notifications

Post by shoreypu »

I was able to get the links working in our test environment. Thanks!!!

This topic can be considered closed.