Page 2 of 2

Re: Service Status not displaying

Posted: Thu Aug 04, 2011 12:00 pm
by agriffin
Your plugin should not have so much output. If you're using a custom plugin, please see the Nagios plugin development guidelines, particularly where it says to try to limit plugin output to a single short line of text.

Re: Service Status not displaying

Posted: Thu Aug 04, 2011 12:09 pm
by mguthrie
Yeah, Nagios plugins need to be concise in their output, it wasn't designed to have output like this that spans multiple pages. Although nagios 3 will now support multi-line plugin output, the design of it is still intended that plugin output be MUCH shorter than what is displayed above.

http://nagiosplug.sourceforge.net/devel ... html#AEN33
2.1. Print only one line of text

Nagios will only grab the first line of text from STDOUT when it notifies contacts about potential problems. If you print multiple lines, you're out of luck (though this will be a feature of Nagios 3). Remember, keep your output short and to the point.
Excessively long plugin output like that will either crash functions or get cut off. ndoutils cuts it off after 8k. In the last update I cut it off after 6k, however it appears I should have cut it off shorter.

If you want you can test a fix in the following file (make a backup copy first):
/usr/local/nagiosxi/html/includes/utilsx.inc.php

line 64

Code: Select all

 if($length > 3000)
        {
                        //split huge string into 2 to prevent memory crashing errors in apache
                        $string1 = substr($string,0,3000);
                        $max = ($length > 6000) ? 6000 : $length; //set max length to 6k.
                        $string2 = substr($string,3000,$max);  //ndoutils cuts off data after 8k
Change to:
if($length > 1000)
{
//split huge string into 2 to prevent memory crashing errors in apache
$string1 = substr($string,0,1000);
$max = ($length > 2000) ? 2000 : $length; //set max length to 2k.
$string2 = substr($string,1000,$max); //ndoutils cuts off data after 1k

Re: Service Status not displaying

Posted: Thu Aug 04, 2011 3:55 pm
by rseiwert
Output is from check_wmi_plus.pl. Actually took me two days to isolate what was causing XI to sit and spin. Would prefer error checking in php since you never know what crash debug gigo return could be coming in. Having XI not being able to even list the problem is a problem. The php crash was the service status list. This page only needs the first line so why read anything past the first line? Checking for buffer overflow and illegal chars is also good.

Re: Service Status not displaying

Posted: Thu Aug 04, 2011 5:01 pm
by rseiwert
Looking at the xmlentities function I might suggest something cleaner. If preg_match_all crashes on large strings split the string into 1k pieces with a while loop, run regex on them and collect into another string.

Once able to identify what the problem was I solved it on that machine so the application log no longer contains those error messages which also got XI working again.

I am putting in your current fix hoping to avoid what was happening for the last couple of days.

Re: Service Status not displaying

Posted: Thu Aug 04, 2011 5:06 pm
by mguthrie
The crash happens before it gets to be processed for the service status page. The same backend data call is made for both the service status table and the individual service status details page. We have users who wish to have longer plugin output displayed (log monitoring for example).

What you're describing is a better fix for this issue. I'll add it to my TODO list. I had it splitting at 3k, but it looks like I need to break it down smaller.

Re: Service Status not displaying

Posted: Fri Aug 05, 2011 9:03 am
by rseiwert
I am curious what that regex actually does? Seems interesting but my regular expessions are so rusty?

In my morning bathroom mediation on the matter splitting on linebreak or maxline len so as not to split any multibyte matches. Having a maxbuffersize (to limit regex pasing) and maxreturnsize (to crop output at idk 8K).

Re: Service Status not displaying

Posted: Fri Aug 05, 2011 9:19 am
by mguthrie
That horrible and excessively long regular expression is to protect against characters outside of the ASCII table. We had that issue last fall where plugins were returning bad characters and breaking the XML. : )

Re: Service Status not displaying

Posted: Mon Aug 08, 2011 10:14 am
by rseiwert
If that regex is a complicated pattern match used restrict to ascii and it's causing the segment fault maybe something simpler would work.
Don't know php so excuse my syntax

function simplyclean(buf)
tmpbuf=""
for i = 1 to len(buf)
c=asc(substr(buf,i,1))
if c > 31 and c < 127 then
tmpbuf = tmpbuf + c
end if
next i
simplyclean=tmpbuf
end function

Re: Service Status not displaying

Posted: Tue Aug 09, 2011 9:40 am
by mguthrie
Most of the character-level cleaning tricks I'm finding still require the use of one of the preg_match functions. I'll do some poking around on it though.