xod: Fix dependency structs to match the rest of Nagios

Pretty much everything in the xod code matches the actual config
file in terms of struct member names. This patch brings the
dependency code up to scratch with that paradigm.

In itself, this patch is useless code churn, but it allows us to
make changes that simplifies adding variables to the object config.

Signed-off-by: Andreas Ericsson <ae@op5.se>
xod: Add and use a few function-style xod_inherit macros

This makes it a lot more pleasant to add new variables to the object
configuration.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Add {host,service}->hourly_value, and contact->minimum_value

The idea is to use this as a measurement for how important something
is, and to block notifications for things that are unimportant (such
as dev equipment or less prioritized services), as well as creating
a list ordered on business value in various user interfaces.

Signed-off-by: Andreas Ericsson <ae@op5.se>
core: Avoid writing statusdata if user points us to /dev/null

Easter-egg-ish functionality, but since there are so many other ways
users can obtain statusdata info nowadays it doesn't make sense to
forcibly write a huge file to disk if the user doesn't want us to.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Remove {host,service}_check_sighandler() completely

They're relics from the past and no longer of any use to us, just as
the global check_result_info variable.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Fix caching and printing of service notification options

Previously we had 'd' as the char for "notify on scheduled downtime",
but the real character is 's', so we make the substitution and get
on with things.

Reported-by: Joerg Linge <pitchfork@ederdrom.de>
Signed-off-by: Andreas Ericsson <ae@op5.se>
Stop reserving nebcallbacks we aren't using

Since we're controlling the sources, we can easily add callbacks
needed later, without tagging and reserving a bunch of them for no
reason what so ever.

Signed-off-by: Andreas Ericsson <ae@op5.se>
core: Promote the _3x versions of functions by removing _3x suffix

It makes little sense to have a _3x version when we don't have
another version of the functions, so we remove them. While at it,
we remove run_sync_host_check_3x() completely, which was essentially
only called from perform_on_demand_host_check(), which was just a
stub wrapping run_sync_host_check_3x().

While at it, we remove the "host or service check?" logic from our
worker management code and call out to process_check_result() instead,
which does exactly that but serves as an entry point where we can do
mangling, logging and broker callbacks.

Signed-off-by: Andreas Ericsson <ae@op5.se>
core: Restructure the code a bit

The command file and command worker process management code really
belongs in base/commands.c, and by moving it there we can make the
command_file* variables file-scoped instead of global-scoped, which
is a neat bonus.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Add check source determination capabilities

Since the introduction of mod_gearman, dnx, Merlin and worker
processes it's no longer so clear where checks come from, and users
of such systems are left pretty much in the dark about where a
certain check happened, which can be crucial to know when attempting
to find problems in a network.

With this patch, we add a "struct check_engine" which is added to
the checkresult struct, and also add a "void *source" member to the
same struct. The system is quite easy, but a bit more convoluted
than it has to be, since redundancy modules will want to know where
checks came quickly in order to know if they should send the checks
onwards or not.

With this patch that becomes both simple and efficient, and we can
provide const strings for each of our workers, and we can utilize
the same functionality to identify external special-purpose workers
when we get those, which is likely to be an amazing help during the
debugging of those.

Signed-off-by: Andreas Ericsson <ae@op5.se>
process_passive_service_check(): Take description of looked-up service

It makes little sense to use a pointer into the iocache from the
external command buffer, as it gets overwritten from time to time.
With this patch we make things more future-proof in case things
want to stash a pointer to the service_description from the check
result struct later.

Signed-off-by: Andreas Ericsson <ae@op5.se>
core: Refactor event handling loop somewhat

Previously we used to remove the event structure before we checked
if we were supposed to run the event, which caused the event_runtime
fetched from squeue_get_runtime() to point to invalid memory and
sometimes be filled with random crap, causing latency calculations
to be waaay off (like 50 billion years or so).

With this patch we avoid most of the if()'s and move on quicker if
we're not supposed to run the check, removing it explicitly where
needed.

Signed-off-by: Andreas Ericsson <ae@op5.se>
base/events: Fix parameter ordering for latency calculation

The event's actual runtime is the "start", and when we really run it
is the "stop", since that's supposed to come after the time the
event was supposed to run.

This patch fixes it, making latency calculation work properly again.

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