Patch to properly poll() on the command pipe

Thomas Guyot-Sionnest dermoth at aei.ca
Mon Jan 14 07:20:31 CET 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Ethan, hi list,

There's one thing that trickle me with nagios since I came across that
code... In nagios v2, base/utils.c, there's the
service_result_worker_thread function that uses poll calls to read from
an ipc pipe, and there's the command_file_worker_thread (still present
in Nagios v3) that seems to be a cut and paste of the previous function
with polling replaced by a sleep timer because poll didn't work.

The reason poll didn't work is simply because to poll a named pipe, you
must open it RDWR, so this patch takes back the code from nagios v2
service_result_worker_thread to use polling on the command pipe.

I did it just for fun, but I'm wondering if you'd be interested in using
is for Nagios v3 (this is against CVS HEAD btw). It worked well on my
Ubuntu box with the following tests:

a. Running Nagios with 1500 passive checks accross 100 hosts getting
their result from NSCA every minute at the exact same time (1)

b. Same as [a] while trying to keep the pipe full by cat'ing a file
containing millions of check results for the same host/service (2)

(1) A perl script (attached too) forking 100 childs syncronized with a
semaphore. every 60 seconds each child opens a pipe to send_nsca and
prints 15 service results. nsca was configured not to aggregate writes.

(2) Running the following just before the semaphore fires off the childs
(results.txt is big enough so that the command finishes after nagios is
done processing the 1500 passive results):
  $ `cat results.txt >>var/rw/nagios.cmd`

I guess this patch would help keeping the command pipe empty on huge
distributed monitoring systems. As I said it was for fun, do whatever
you want with it ;)


Thomas
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHiv8u6dZ+Kt5BchYRAkCGAKCA1muzYCQo31cA1ZI/RPQQyQBidwCgv6K6
2Ft31txzgmay0kCnF/EQ1so=
=d5/z
-----END PGP SIGNATURE-----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: use_poll_on_cmd_pipe.patch
Type: text/x-diff
Size: 2796 bytes
Desc: not available
URL: <https://www.monitoring-lists.org/archive/developers/attachments/20080114/7a48e772/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nsca_test.pl
Type: application/x-perl
Size: 2254 bytes
Desc: not available
URL: <https://www.monitoring-lists.org/archive/developers/attachments/20080114/7a48e772/attachment.bin>
-------------- next part --------------
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
-------------- next part --------------
_______________________________________________
Nagios-devel mailing list
Nagios-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-devel


More information about the Developers mailing list