Page 1 of 1

[Nagios-devel] Nagios3 hang

Posted: Fri May 08, 2009 1:35 am
by Guest
--_000_D52E7E0EBA1C264CB2DCD0DAD5D5DA8904BCB35F05heraskywavemo_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Hi All:

I write an event handler to start our daemon service. The problem is that o=
nce the event handler code finished, whole Nagios process keep hanging. I c=
heck the CPU usage is 100% and by using strace I can see a lot of following=
system call:

read(5, 0xbf879450, 1023) =3D -1 EAGAIN (Resource temporarily=
unavailable)

By checking the source code, I found the reason of this problem.

Nagios main process create a pipe fd[5,6] and fork a child process. In this=
child process, it use popen to create pipe and invoke event handler script=
. Once child process get output from event handler script, it transfer it t=
o main process by using fd 6. Because in popen function, it doesn't close f=
d 6 before invoking event handler script, fd 6 is inherited down to our dae=
mon process. Because our daemon process doesn't close fd 6, Nagios main pro=
cess keep getting EAGAIN.

Suggestion:

To fix this problem, I would suggest to fix two parts.

1 Don't use popen. Instead create pipe, fork child process and close all un=
used file descriptor before invoking event handler script.

2 In main process, set timeout for getting EAGAIN error code to avoid endl=
ess loop.

Oliver

--_000_D52E7E0EBA1C264CB2DCD0DAD5D5DA8904BCB35F05heraskywavemo_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable





















Hi All:

 

I write an event handler to start our daemon service. =
The
problem is that once the event handler code finished, whole Nagios process =
keep
hanging. I check the CPU usage is 100% and by using strace I can see a lot =
of
following system call:

 

read(5, 0xbf879450,
1023)           &nbs=
p;  
=3D -1 EAGAIN (Resource temporarily unavailable)

 

By checking the source code, I found the reason of thi=
s
problem.

 

Nagios main process create a pipe fd[5,6] and fork a c=
hild
process. In this child process, it use popen to create pipe and in

...[email truncated]...


This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]