Re: [Nagios-devel] spopen and stderr

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

Re: [Nagios-devel] spopen and stderr

Post by Guest »

On Thu, 12 Dec 2002, Dave Viner wrote:
> I'm trying to write a plugin and having some trouble w/ spopen. I seems to
> be reporting stdout fine, but stderr seems to be lost. My code looks like:
:
> /* open the child process stderr */
> child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r");
:

I can't find a reference to child_stderr_array in nagios 1.0, although the
childerr array would be equivalent. What version of nagios is this against?

:
> while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process))
:
> if (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) {
:
> cmd contains the correct command to run. When I run it from the command
> line, there's a bunch of output to stderr
:
> So, stderr is getting the output, but stdout gets nothing. When I run this
> from my plugin using spopen, I get:
> $ ./check_myprog
> CRITICAL - Plugin timed out after 15 seconds
:

What is probably happening here is the stderr pipe is filling up so your child
process blocks on its writes to stderr. The parent process is waiting for
input from the child's stdout which never comes. Since the child is blocked
on its write, it can never exit and close the stdout fd. Timeout happens, and
the check gives up.

You can verify this is what is happening with an strace/truss.

You should probably not write to stderr in your child processes.

--
It's looking like if MySQL AB doesn't make a movie based on the manual,
nobody's ever gonna learn how to use a database.
- r.





This post was automatically imported from historical nagios-devel mailing list archives
Original poster: dan-nagios@drown.org
Locked