lib/squeue: Remove branch prediction hackery

It doesn't change the generated assembly code one bit, so we might
as well get rid of it.

Signed-off-by: Andreas Ericsson <ae@op5.se>
core: Remove dead prototype for resort_event_list()

It was removed when we switched to using the squeue library instead
of linked lists for scheduling, but the prototype lingered on.

Signed-off-by: Andreas Ericsson <ae@op5.se>
core: Zero-initialize low-priority timed events

Without doing this, we might get random usec values in the
sq_event, which is quite bad since we're using it to determine
runtime in the scheduling queue, which in turns decides the
amount of time we spend polling.

Signed-off-by: Andreas Ericsson <ae@op5.se>
lib/squeue: Remove debugging output

Noone will see it when we're running, and we still return proper
error messages to the callers, so we needn't bother overly.

We do add an assert() to make check we don't get usecs larger
than 1000000 though.

Signed-off-by: Andreas Ericsson <ae@op5.se>
lib/worker: Remove incessant logging from workers

While we're at it, we also kick out a debug printf().

Signed-off-by: Andreas Ericsson <ae@op5.se>
lib/worker: Close parent's end of socketpair before initialization

Signed-off-by: Andreas Ericsson <ae@op5.se>
core: Add worker management helpers

This provides the in-core helpers needed for us to paw over all
external commands to the worker processes with a minimum of code
duplication.

While at it, we add the struct rusage to the check result struct,
so we can keep track of what resources plugins consume.

Signed-off-by: Andreas Ericsson <ae@op5.se>
core: Handle brokered I/O events adding high priority events

Previously we used to go ahead with the event we got from the
queue no matter if events brokered from the I/O broker turned
were added that were supposed to be run before that one. We still
do (sort of), except that now we prioritize the earlier scheduled
events if the first event is scheduled far enough into the future.

"Far enough" means "one second" in this case.

While we're at it, we remove the fairly useless wproc_poll() call.
Since nagios_iobs is a global variable and wproc_poll() is just a
wrapper around iobroker_poll() called with nagios_iobs and the
timeout as variables, we really don't need the wrapper.

Signed-off-by: Andreas Ericsson <ae@op5.se>
core: Run host and service checks through a worker

Fascinating observation; With a large process (+100MB) we can achieve
1121 fork()'s per second. With a small process as parent, we can
achieve 13891 fork()'s per second, best of five runs on my laptop.

Even accounting for the message passing, which has a constant overhead
of about 50 nanoseconds (two memcpy() and some function call overhead),
this is a clearly superior solution, even if we don't account for the
fact that we're now capable of utilizing parallelization as well, so
we can multiply the number of fork()'s with the number of online cpu's
minus 1 instead of having it fixed at 1.

Naturally, performance will decline when the fork()'ed programs do
something sensible instead of just exiting, but since the same program
was used to measure fork() performance with large and small processes
we can still expect a huge improvement.

Signed-off-by: Andreas Ericsson <ae@op5.se>
core: Run eventhandlers, OC[SH]P commands and others through workers

They used to be run serially. This parallelizes them, as well as
offloading them to a smaller process, which means a huge performance
benefit.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Updated path for libnagios.h
Fixed link for unhandled unreachable host problems on tactical overview page (Rudolf Cejka)
Fixed bug #247: If a service reports no performance data, the perfdata log file has no line indicating the test. (omnikron@free.fr)