core: Read number of desired workers from configuration

If it's set to 0, we auto-decide on a value that might be suitable,
or possibly entirely off.

The variable is called 'check_workers'.

While at it, we fix some minor logging issues in base/workers.c

Signed-off-by: Andreas Ericsson <ae@op5.se>

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2267 5f96b256-904b-4d8d-8c98-d829582c6739
core: Add a general-purpose addressable query handler

The API is laughably simple. A handler registers itself with a name
and a handling function (matching the qh_handler typedef in nagios.h).
Requests coming to the unix domain socket at query_socket_path must
have the form

  @address<SP>query<NUL>

There can be any number and type of characters after the space following
the address, but the request will not be sent to the handler before we
see a NUL byte.

There is currently a hardcoded limit of 16KiB - (strlen(name) + 2)
for queries, and a limit of 128 chars for names.

On errors, we strive to present the user with http-ish response codes,
since pretty much every language in the world can resolve them to
something sensible, and even the first byte yields a rough idea of
what went wrong.

Included by default is an 'echo' service, which is about as dumb as
they come. When given data, it immediately writes the same data back
to the user again. It should be enough to let people try out the
idea though.

The idea is that the NERD radio will be moved over to the new query
handler too, as it doesn't make much sense to have two separate
socket handling api's when one of them is supposed to be general
purpose.

The path to the query socket can be configured using the newly
introduced 'query_socket_path' main config file variable. It has no
default, so if it isn't configured it's left disabled.

Signed-off-by: Andreas Ericsson <ae@op5.se>

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2268 5f96b256-904b-4d8d-8c98-d829582c6739
nerd: Use the query-handler API

This was easier than I thought, so might as well get it done right
away.

Signed-off-by: Andreas Ericsson <ae@op5.se>

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2269 5f96b256-904b-4d8d-8c98-d829582c6739
specfile: Fix typo s/nagios.init/daemon-init/

Signed-off-by: Andreas Ericsson <ae@op5.se>

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2270 5f96b256-904b-4d8d-8c98-d829582c6739
nerd: Some cleanup in subscription handling and request parsing

Previously we used to coredump after a subscriber had unsubscribed
and more events came in to the channel subscribed to. With this
patch, that's no longer the case.

While at it, we remove a bunch of debugging statements.

Signed-off-by: Andreas Ericsson <ae@op5.se>

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2271 5f96b256-904b-4d8d-8c98-d829582c6739
base/workers: Remove debug printf()

Signed-off-by: Andreas Ericsson <ae@op5.se>

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2272 5f96b256-904b-4d8d-8c98-d829582c6739
Initialize query handler after loading modules

We may not have to if modules are flawed, and this way we're still
available by the time the modules get initialized.

Signed-off-by: Andreas Ericsson <ae@op5.se>

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2273 5f96b256-904b-4d8d-8c98-d829582c6739