include/nebcallbacks: Reduce listed number of supported nebcallbacks

We really only support 26 (which fits nicely into 32 bit types) and
not 33, so we update the macro used for counting callbacks so we
can avoid wasting some memory.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Add alloc_nr() macro

This is useful when dynamically increasing an array where we don't
know how much larger it's going to get. The array will grow by
roughly 1.5 times its current size, but faster in the beginning.
Memory spill should be about 15-20% of total size needed, and we
can live with that for most arrays. Where the arrays are huge and
ultimately bounded by some size unknown at creation time, one can
always realloc() it down to its ultimate size.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Pass check result struct (when available) to event brokers

The check result struct contains a lot of useful information not
found in the host and service structs. This patch provides the
modules with that information for all occasions except on-demand
host checks, which are still special-cased.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Eventbroker API: Add support for built-in core modules

It's usually a good idea to eat ones own dogfood. It's also a
pretty good idea to be able to incorporate nifty modules directly
in to the core, should we decide to go that way.

With this patch, that becomes possible, since we can now add core
modules that can register callbacks and don't cause segfaults when
they're about to be unloaded, and soon that will become highly
useful.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Deprecate {HOST,SERVICE}_CHECK_{ACTIVE_PASSIVE}

Since the way things are checked doesn't differ between hosts and
services, it's just confusing to have two different macros that
mean the exact same thing.

Instead we introduce CHECK_TYPE_{ACTIVE,PASSIVE,PARENT,FILE,OTHER},
with ACTIVE and PASSIVE replacing the four previous similar ones.
CHECK_TYPE_PARENT means we've run an (active) check for the benefit
of an object that depends on the object we just checked. FILE means
we read the check result from a spooled file (which is deprecated
and should just go away as quickly as possible), and OTHER being a
catch-all to let modules set something that marks checks from them
as special.

We retain the old macros yet a while longer, but clearly mark them
as deprecated, and we get rid of them from the sources so others
don't use them by mistake.

Signed-off-by: Andreas Ericsson <ae@op5.se>
lib/lnag-utils: Add ranged_urand()

Proper randomization is highly useful in algorithms where no good
solution exists, but it's boring to type and off-by-ones tend to
sneak in when coding at three in the morning. With this helper we
avoid such errors, which is a Good Thing(tm) since such bugs are
by their very definition impossible to reliably reproduce.

Signed-off-by: Andreas Ericsson <ae@op5.se>
core: Run first check of objects within their max check delay

If the initially scheduled checks happen to end up too far into the
future we simply schedule them on a random slot within their
check window. The check_window() macro takes care of calculating the
max time we have, regardless of whether the host (or service) is in
soft or hard state.

This fixes issue 83.

Signed-off-by: Andreas Ericsson <ae@op5.se>
xpd: Re-initialize perfdata_file_pipe vars to FALSE on reloads

Without this patch we would otherwise lose the ability to reconfigure
perfdata handling, leading us to lose performance data indefinitely.

This fixes issue 138.

Signed-off-by: Andreas Ericsson <ae@op5.se>
base/checks: Stop being tricksy with orphan detection checks

The orphan detection logic might be doing it wrong with regards to
hosts (it looks correct, but that's no guarantee), but intentionally
fooling ourselves with a bug in one place to work around a bug in
another makes absolutely no sense what so ever.

This patch removes one such cover-up bug. If we get the bug with
orphaned host checks back (unlikely, as they're run by the worker
processes now), we can fix that properly instead of working around
it in such a hackish manner.

This fixes issue 270.

Signed-off-by: Andreas Ericsson <ae@op5.se>
xod: Fix contact inheritance

According to the docs, contacts should only be inherited from host to
service if the service has no other contacts what so ever (and the
same goes for escalations), but the way the code worked was that it
handled contact_groups and contacts directives separately, meaning
services with only 'contacts' specified were still eligible for
inheriting 'contact_groups' from the host, leading to much confusion.

This patch fixes that, and thereby issue 314.

While we're at it, we re-organize the inheritance macros a bit and
make sure to use them for cross-object inheritance too.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Show the buildmachinery some love

The specfile now has support for the devel package and the init
script has sysconfig support with automagic ramdisk fiddling.

Patched-by: Daniel Wittenberg <dwittenberg2008@gmail.com>
Signed-off-by: Andreas Ericsson <ae@op5.se>
Add NERD, the Nagios Event Radio Dispatcher

Yes, I came up with the acronym first and the name afterwards.

This is quite nifty though, as it provides external applications
with a way to obtain real-time data from Nagios without having
to resort to writing C-code or relying on other addons. There's
currently only two channels; hostchecks and servicechecks, and
only two commands; subscribe and unsubscribe, but since channels
can be added without any major fuzz that will most likely happen
whenever people need a new type of data.

It's also quite neat that eventbroker modules can create their
own channels and thereby set up "radio merlin", or whatever
takes ones fancy.

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