oconfsplit: Include 'exclude' timeperiods in split-outs

Previously, timeperiods that have 'exclude' timeperiods linked
where the excluded period(s) aren't used elsewhere would be
left out of the split-out configuration. With this patch, the
excluded periods are instead included. Which doesn't make sense
grammatically, but it should make sense if you're familiar with
the naemon config syntax. If you aren't, you probably shouldn't
be reading this commit message anyway.

Reported-by: Robin Sonerfors <rsonefors@op5.com>
Signed-off-by: Andreas Ericsson <ae@op5.se>
init script: Make the warnings/error checking clearer

I recently received a patch to fix a non-bug in the init script
which was sent because the logic was pretty unclear earlier.

This changes it around a bit so it should be obvious which
condition triggers which return status.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Merge pull request #89 from naemon/dev/minor-fixes

Dev/minor fixes
Commands: Break at end of case statements

A switch with independent cases should have break at the end of the
case, since the code will fall through otherwise.

Signed-off-by: Max Sikstrom <msikstrom@op5.com>
xsddefault: don't leak memory

A my_free should be called for the status file path storage even if we
shouldn't or couldn't unlink the file

Signed-off-by: Max Sikstrom <msikstrom@op5.com>
Remove scheduling_info struct

The scheduling information structure contains lot of information and
statistics about the the current configuration, such as amount of hosts
and services.

There are a couple of problems with this struct however. Since the
scheduling is simplified/randomized, the inter-check delays isn't
really anything to bother about. The amount of hosts and services can
easily be mined out either from the cfg-files with tools, or by using
livestatus on a running system (recommended). Also the timings about
upcoming checks can be mined out through livestatus, possibly by
implementing a check for it, so the information actually can be graphed
and monitored.

The problem with the scheduling_info is however how it's implemmented.
One great goal for refactoring naemon would be to isolate its modules,
so the code doesn't look like spaghetti. The wproc module has already
been refactored to remove dependencies to lot of other parts, by
presenting an interface with callbacks. The event module depends on
everything, more or less. And everything depends on the event module.
The nature of the scheduling_info struct is that it needs to be
maintained in lot of different parts of the system, which is possible
in event module at the moment, but makes it impossible to move the
check execution handling out of event.c.

Removing scheduling_info struct will make it lot easier to refactor
event.c to make naemon lot more modular.

Signed-off-by: Max Sikstrom <msikstrom@op5.com>
Remove test_scheduling

Test scheduling is basically a feature to analyze the scheduling_info
struct, which was a bad idea, as said in previous commit message. It
was also used to analyze timings for loading configuration, which there
is another API for already (there are lot of timing_points in the code,
use naemon -T to display).

So this is basically a cleanup to remove redundant timing analysis
features, which just adds lot of noise to the code.

Signed-off-by: Max Sikstrom <msikstrom@op5.com>
Remove event type statistics tracking

Since the goal is to refactor the event queue to not know about
different event types, but just one type, which is a callback type, we
can remove the tracking of counts for different event types.

Next step should be to move per-module specific logic out to the
different modules. The method should_run_event() would be a good target
for next step.

Signed-off-by: Max Sikstrom <msikstrom@op5.com>
Move timed_event to event header + cleanup

since the timed_event structure is tightly coupled to the events.c
file, and timed events, we should keep that structure in that module,
so we don't need to include the entire systems data strctures just to
handle some events.

Also, start the cleanup of unused event types, since we don't want
event types at all quite soon, but just callbacks.

Signed-off-by: Max Sikstrom <msikstrom@op5.com>
Add simplified schedule new event function + refactor simple events

Since callback based events is much easier to maintain in the events.c,
we should use that method. Also, that would keep all logic related to
the event at the same place as the code requesting the event, keeping
the all code related to a particular functionality together.

This first step updates the restart and shutdown process commands to
use callback events.

Signed-off-by: Max Sikstrom <msikstrom@op5.com>
events.h: Reorder methods, remove methods no longer implemented

Since not all mehtods are implemented, we should clean up those. Just a
minor cleanup

Signed-off-by: Max Sikstrom <msikstrom@op5.com>
Let checks.c handle check scheduling intitalization

Since the modules should know about themself, and not depend on other
parts to initialize it's events, the check execution initialization
should be handled in the check exeuction module, not in the event
scheduling module.

It lead to really nasty dependencies, and still does, but not as much.

Signed-off-by: Max Sikstrom <msikstrom@op5.com>
Remove init_timing_loop, let modules initialze themself

It's better that the modules, that knows about their own events,
initialize the events, and not let the event exeuction module load
them. It's even one step closer to letting the events.c provide an
event execution platform instead of an
naemon-dictator-handle-all-other-modules-as-puppies-module.

Signed-off-by: Max Sikstrom <msikstrom@op5.com>
Remove EVENT_STATUS_SAVE in favour for callback

Replace the EVENT_STATUS_SAVE with callback event.

Signed-off-by: Max Sikstrom <msikstrom@op5.com>
Remove EVENT_RETENTION_SAVE in faviour for callback event

Move check result logic from event.c to sretention.c, where the rest of
the rentention data code is placed

Signed-off-by: Max Sikstrom <msikstrom@op5.com>
Cleanup events no longer used

Some event id:s isn't used anymore, but since removing event types in
favor for callbacks, we could simply remove them, to clean up for
future refactoring

Signed-off-by: Max Sikstrom <msikstrom@op5.com>
Comments: Remove expired feature and events

As a part of cleaning up the events, it was discovered that the comment
expiration feature wasn't working at all, and never actually tried to
be used.

Instead of fixing the not used internal functionality, the not used
internal functionality can instead be removed, and one more event type
is gone.

Signed-off-by: Max Sikstrom <msikstrom@op5.com>
Convert check freshness to callback events

Changing this reduces some of the dependencies for check in events.c,
and moving more check logic to checks.c

Signed-off-by: Max Sikstrom <msikstrom@op5.com>
Change check orphaned event to callback event

The orphaned event is quite strange, looks like a
execution-bug-selfcheck-and-heal event, which checks if checks hasn't
been executed, and thus reschedule them, something like if a host or
service check has been forgotten.

Anyway, this isn't about cleaning up the check exeuction code, so keep
the event as is, but execute it through callbacks so we can get rid of
that dependency from events.c to checks.c

Signed-off-by: Max Sikstrom <msikstrom@op5.com>
Convert reap check event to callback event

Simply remove one more slot of the switch/case in events.c, and remove
one more dependency to checks.c from events.c

Signed-off-by: Max Sikstrom <msikstrom@op5.com>