Page 1 of 2

Custom Plugin Output contains embedded URL

Posted: Fri Mar 21, 2014 1:50 pm
by SteveBeauchemin
I have Plugin Output from SNMP traps and other sources. They contain important URL data that points directly to another application and at the exact problem sent by the trap. In Nagios Core, I can show those in the plugin output, which is displayed in the Status Information column. Users can then click the link and launch a separate web page opening an application that takes them to the exact location they need to be to see the pertinent data.

The plugin output provides specific information relevant to the test - for example - using an href link with colors:
OK:<A HREF='http://ntnc/onlinereports/OVO_ActiveMessagesDetail.asp?Instance=&Node=sql04' TARGET='_blank'> 2 Total Messages</A> <FONT STYLE='BACKGROUND-COLOR: RED' COLOR='WHITE'>(Critical: 1 owned: 1)</FONT> <FONT STYLE='BACKGROUND-COLOR: ORANGE' COLOR='BLACK'>(Major: 1 owned: 1)</FONT>

Another plugin output displaying Trap data with an embedded URL:
This trap is sent when a Device Event trigger fires. Device: t50-1-ap - <A HREF='https://c1-1v-awb/ap_monitoring%3Fid=2636' TARGET='AirWave'>Click for AirWave</A> Device Event Event Contents matches wlsxAuthServerTimedOut and SNMP Trap Category is Auth. Notes: Clear Pass is not responding to Auth this alert will be sent.

Both examples are Plugin output that is displayed in Nagios Status Information column on the web page. In Nagios Core this looks and works perfectly.

In my transition to Nagios XI, the URL are not working, and the colors are remapped to one single color.

Is there a setting in Nagios XI that I can change that will let me bring back this loss of functionality?

Please advise.

Thanks.

Steve B

Re: Custom Plugin Output contains embedded URL

Posted: Fri Mar 21, 2014 2:20 pm
by sreinhardt
My guess, without looking into the code yet, is that these are being filtered or stripped to prevent potential XSS attacks. I can check with the dev team and do some digging, however I am not sure this will be an easy fix for you. At the same time, are you able to get this information via notifications to users so that is at least an option?

Re: Custom Plugin Output contains embedded URL

Posted: Fri Mar 21, 2014 4:49 pm
by SteveBeauchemin
Since I still have my original server in place, I will not formally move these tests to the new server until I have a solution. The alerts will work in the new setup, but the embedded URL and colors are just wrong.

To help be more specific, this is the test and output from the command line versus the GUI.
this is the test using the command line.
./check_ovo_messages.pl -t 30 -H [Hostname] -u [Oracle-User] -p [Oracle-Password] -O [Oracle-Server] -S [SID] -P [Port]

this is the output - on both systems, old and new - Core and XI - the output is the same
OK:<A HREF='http://nc/onlinereports/OVO_ActiveMessa ... Node=sql08' TARGET='_blank'> 3 Total Messages</A> <FONT COLOR='BLACK' STYLE='BACKGROUND-COLOR: YELLOW'>(Minor: 1 owned: 0)</FONT> <FONT COLOR='BLACK' STYLE='BACKGROUND-COLOR: CYAN'>(Warning: 2 owned: 0)</FONT>

From the same test in the Nagios XI GUI I get the following line in the Status Information column.
OK: 3 Total Messages (Minor: 1 owned: 0)
where [3 Total Messages] is the link to the bad URL (next line)
[http://[NagiosXI-Server] /nagiosxi/includes/components/xicore/'http://nc/onlinereports/OVO_ActiveMessa ... e=sql08%27
where [(Minor: 1 owned: 0)] font background is white, with green text.
where [(Warning: 2 owned: 0)] is not displayed at all.

In the URL above, the link is redefined to use the xicore directory as a relative location for the actual URL. It does not use the fully qualified URL.
Also, it ignores the colors defined in the command line output.

The same test on Nagios Core shows the following line in the GUI
OK: 3 Total Messages (Minor: 1 owned: 0) (Warning: 2 owned: 0)
where [3 Total Messages] is the link to the URL [http://nc/onlinereports/OVO_ActiveMessa ... Node=sql08]
where [(Minor: 1 owned: 0)] is background yellow, with black text
where [(Warning: 2 owned: 0)] is background cyan, with black text

I suspect that the NagiosQL interface and its heavy use of javascript may be forcing it's will upon my test output.

I hope this clears up any questions of what I am trying to do. Basically there are 2 issues. One is the URL fully qualified versus relative. The other issue is control of colors. Any help in this regard would be much appreciated.

Thanks.

Steve B

Re: Custom Plugin Output contains embedded URL

Posted: Mon Mar 24, 2014 10:32 am
by tmcdonald
It might be useful to see the source code of the page. Can you right-click on the page and select "View Source" or "Page Source" or something similar? Then save the page that comes up and attach it here. It might have some sensitive info so if that is going to be an issue let us know before posting it.

Re: Custom Plugin Output contains embedded URL

Posted: Mon Mar 24, 2014 12:08 pm
by SteveBeauchemin
I tried to view the page source for the Nagios XI screen containing the Status Information for the host. The source does not show any of the Status Information for any tests. Maybe that is a Chrome Browser thing. So I made life easier, took me 1 minute to create a custom test that clearly displays the issue.

This should be easier for you to understand. The source of the test follows.
I named it check_url.sh

Code: Select all

#! /bin/sh
ECHO="/bin/echo"
if [ $# -lt 1 ]; then
    $ECHO "URL follows <A HREF='http://www.google.com' TARGET='_blank'>Click Here</A>"
else
    $ECHO "URL follows Click Here"
fi
exit 0
This should be simple enough for you to add to your libexec directory, make a command, and a service, and apply it to a host.
Make 2 services, one with no parameters, and one with a parameter.

Then, on your screen, click the link, look at the page source, get the data you need to verify what I am seeing.

Let me know what you come up with.

Thanks

Steve B

Re: Custom Plugin Output contains embedded URL

Posted: Mon Mar 24, 2014 1:52 pm
by scottwilkerson
If you want to display HTML in plugin output you can enable that in XI through Admin -> Manage System Config and check the box "Allow HTML Tags in Host/Service Status"

Re: Custom Plugin Output contains embedded URL

Posted: Mon Mar 24, 2014 6:39 pm
by SteveBeauchemin
I started this game with that checked and am not having any fun. Is there specific syntax I need to use for HTML to display properly with that checked? As you can see from my previous posts, I am using HTML in Nagios Core with no problem.

Please refer to my previous post, create the test I provided, and try it yourself.

Steve B

Re: Custom Plugin Output contains embedded URL

Posted: Tue Mar 25, 2014 3:44 pm
by tmcdonald

Code: Select all

#! /bin/sh
ECHO="/bin/echo"
if [ $# -lt 1 ]; then
    $ECHO "URL follows <A HREF='http://www.google.com' TARGET='_blank'>Click Here</A>"
else
    $ECHO "URL follows Click Here"
fi
exit 0
did not work for me. However the following did just fine:

Code: Select all

#! /bin/sh
if [ $# -lt 1 ]; then
    echo "URL follows <a href=http://www.google.com>Click Here</a>"
else
    echo "URL follows Click Here"
fi
exit 0
Lose the quotes around the URL and target attributes and you should be fine. Worked in FF, IE, and Chrome.

Re: Custom Plugin Output contains embedded URL

Posted: Tue Mar 25, 2014 3:51 pm
by scottwilkerson
Or this

Code: Select all

#! /bin/sh
ECHO="/bin/echo"
if [ $# -lt 1 ]; then
    $ECHO 'URL follows <A href="http://www.google.com" TARGET="_blank">Click Here</A>'
else
    $ECHO "URL follows Click Here"
fi
exit 0

Re: Custom Plugin Output contains embedded URL

Posted: Tue Mar 25, 2014 6:01 pm
by SteveBeauchemin
Thanks!

That was it. I have modified my code now, transposed the single quote and the double quotes, made a couple minor adjustments, and the output looks great!

Something so simple shouldn't be so hard. The colors work perfect now, and the URL launches a separate window/tab like I needed.

Much Appreciated guys.

See you in October!

Thanks again.

Steve B