base/nerd.c: Avoid spurious warnings about uninitialized variables

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2483 5f96b256-904b-4d8d-8c98-d829582c6739
lib/pqueue: Don't memset() memory we've just calloc()'ed

calloc() nuls out newly allocated memory, so we might as well save
the nano-second per program launch by removing it.

Patch-by: Ricardo José Maraschini <ricardo.maraschini@opservices.com.br>
Signed-off-by: Andreas Ericsson <ae@op5.se>

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2484 5f96b256-904b-4d8d-8c98-d829582c6739
base/nerd: Fix crash during shutdown after using opathchecks

If opathchecks had been used, the cleanup code didn't properly zero the
host_parent_path_cache pointer, meaning it would dangle and cause
crashes the next time it was used.

Signed-off-by: Robin Sonefors <robin.sonefors@op5.com>

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2485 5f96b256-904b-4d8d-8c98-d829582c6739
nerd: Fix subscriptions after config reload

We didn't clean up the channels completely during shutdown, so in a
reload, we'd append the channels created during startup after the old,
stale ones. The old ones no longer did anything, and when trying to
subscribe to the new ones, we'd end up subscribing to the old ones.

Signed-off-by: Robin Sonefors <robin.sonefors@op5.com>

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2486 5f96b256-904b-4d8d-8c98-d829582c6739
base/query_handler: Implement a simple help handler

Because the query handlers are plentiful and nifty, they're something I
should be using, but because I'm bad at remembering things and tired of
reading the source to find out how things work, I need help.

The way I can think of to get help is to try to exercise peer pressure
on whoever writes the query handler, by telling users that there should
be a help text, and then giving them errors error messages when the
query handler doesn't have any help text.

The protocol I've invented for asking for help text is the "--help"
command to the query handler - a fairly universal convention in
unixland, and also unlikely to clash with something else.

Signed-off-by: Robin Sonefors <robin.sonefors@op5.com>
Signed-off-by: Andreas Ericsson <ae@op5.se>

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2487 5f96b256-904b-4d8d-8c98-d829582c6739
query-handler: Do error logging when registering query handlers

It's retarded to have every module and in-core query handler have
to do its own error logging when we can do it in one place and
also include a legible error message in that one place instead of
attempting to guess at all the others.

While at it, we stop logging "success" messages from unimportant
in-core query handlers.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2488 5f96b256-904b-4d8d-8c98-d829582c6739
qh: Fall for peer pressure from myself, and implement some help

This is still quite sparse, as it's intended as inline help and hints,
rather than as complete documentation, but it should still prove
helpful.

While at it, we remove some mangling remnants from the nerd query
handler.

Signed-off-by: Robin Sonefors <robin.sonefors@op5.com>
Signed-off-by: Andreas Ericsson <ae@op5.se>

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2489 5f96b256-904b-4d8d-8c98-d829582c6739
Revert "common/macros: Always log warnings from macro resolutions"

This reverts commit efda1f7bf770759edfc9ca2d8d4f2c31fb196ea4.

As it turns out, this can yield an enourmous amount of log spam,
so we leave it to the debug log like it once was.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2490 5f96b256-904b-4d8d-8c98-d829582c6739
nerd: Use the nerd: prefix for our "initialized" log message

It's nifty to grep on, so let's make that possible.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2491 5f96b256-904b-4d8d-8c98-d829582c6739
qh: Let registrars supply a description of the service they provide

This is supposed to be a brief message that we print when listing the
registered handlers to help users who are unfamiliar with the various
handlers.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2492 5f96b256-904b-4d8d-8c98-d829582c6739
qh: Be less strict with query format

With this patch, we stop requiring '@' or '#' as query-prefixes.
They can still be used to denote "keepalive" or "oneshot" queries,
respectively, but we no longer require them to be present and fall
back to 'keepalive' if neither of them is. Queries without a magic
byte-prefix will thus get a persistent connection.

We also stop requiring a specific query and pass a nul byte buffer
with length 0 in case none is passed. Handlers can respond to this
in any way they like, although a strong suggestion (which we also
follow) is that (empty-query) = "help", unless other compelling
options exist.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2493 5f96b256-904b-4d8d-8c98-d829582c6739
xodtemplate: Fix crash when referring to invalid servicegroups

The code for printing error messages when a service is referring to an
invalid servicegroup was incorrect, because it used the wrong pointer -
which can be uninitialized - for writing file and line of the error.

In other words: when you do things incorrectly, nagios will no longer do
so too.

Signed-off-by: Robin Sonefors <robin.sonefors@op5.com>

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2494 5f96b256-904b-4d8d-8c98-d829582c6739
nerd: Implement query handler help

This help is dynamically generated, as requested by Andreas Ericsson.

Signed-off-by: Robin Sonefors <robin.sonefors@op5.com>

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2495 5f96b256-904b-4d8d-8c98-d829582c6739
nerd: Make API useful for eventbroker modules

Since 'broadcast()' was made static and thus limited to the file
nerd.c and no other way existed that let callers get the list of
subscribers or communicate with them in any way, the NERD api
was quite incomplete earlier. With this patch, we instantly make
it reasonably usable.

broadcast() is renamed to nerd_broadcast() and published to the
rest of Nagios and we add nerd_get_subscriptions() as well as
nerd_get_channel_id() as publicly available functions.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2496 5f96b256-904b-4d8d-8c98-d829582c6739
base/notifications: Do send notifications when services goes down

So, this was a bit silly...

When checking a service alert's notification viability, we forgot
to check if the alert was about a recovery before ensuring that the
recovery was valid to send out. This means that people who've tried
upgrading have usually received some notifications - just enough not to
think too hard about it - and people who haven't have still received
other types of notifications.

Signed-off-by: Robin Sonefors <robin.sonefors@op5.com>

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2497 5f96b256-904b-4d8d-8c98-d829582c6739
base/notifications: Handle notified_on properly for hosts

All other notified_on code ensures that it doesn't unset the old value,
so there seems to be some kind of trick to that. This place doesn't,
though, so make it use the macro for achieving this task instead.

Signed-off-by: Robin Sonefors <robin.sonefors@op5.com>

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