commands: Don't lie when logging

Lying logs are not a lot better than none at all. This patch makes
Naemon log unknown service commands as unknown service commands, instead
of unknown host commands.

Signed-off-by: Anton Lofgren <anton.lofgren@gmail.com>
pqueue.[ch]: Update license (and some comments)

The author of libpqueue, Volkan Yazici, emailed me mentioning
that Tom Callaway of RedHat had pointed out a licence
incompatibility between libpqueue and the rest of the code,
with a suggestion that I update the code accordingly.

Reported-by: Volkan Yazici <volkan.yazici@gmail.com>
Signed-off-by: Andreas Ericsson <ae@op5.se>
.gitignore test output

Signed-off-by: Andreas Ericsson <ae@op5.se>
Rename <objecttype>_SKIPLIST macros to OBJTYPE_<objecttype>

We retain the old ones for backwards compatibility, but since we don't
really want to use skiplists at all, we don't want to mention them
either, and the algorithm-agnostic names are much nicer to use.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Stop using the <objecttype>_SKIPLIST macros

We implemented OBJTYPE_<objtype> to have something algorithm-agnostic,
so let's use those instead.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Rearrange xodtemplate.c so all functions in it can be declared static

It's a vipernest of horrible code, but all the functions therein
rely on other functions therein being called first, with the exception
of the entry-level one (xodtemplate_read_config_data), so we really
shouldn't expose any of it to modules.

Why it was originally coded upside down (with callers appearing before
the functions they call), I have no idea, but with this patch we can
at least cut the xodtemplate.h file down to its bare minimum and have
the linker warn us about unused functions, as well as optimize the
config parsing code slightly better.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Avoid initializing variables twice

Only for the xodtemplate_free_*_skiplists functions, but it bugged
me so now it's gone.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Don't overallocate hash tables

We have the macro NUM_HASHED_OBJECT_TYPES to mark which objects
we need to hash, so let's use that for object_hash_tables.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Add red-black trees to libnaemon

Red-black trees provide fast insert, find and remove, as well as
in-order traversal (also post-order and pre-order, but those are
less important for us), in O(n) storage space and O(log n) time.
They are far superior to skiplists in every way, so we're looking
to replace that horrible algorithm with this nice one instead.

There are also other areas where we can make good use of red-black
trees where skiplists are just horrible to work with.

While at it, we make "NAEMON_{BEGIN,END}_DECL" the default macros
to use to make C++ work, while retaining the NAGIOS_* macros as a
backwards compatibility thing.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Replace skiplists with red-black trees in xodtemplate.c

Red-black trees perform better, use less memory and is not a
laughably stupid algorithm. All tests pass so and the
generated object.cache files are identical to the old code
for a large number of different configurations.

Signed-off-by: Andreas Ericsson <ae@op5.se>
lib/rbtree.h: Add missing NAEMON_END_DECL

An unclosed 'extern "C" {' is a good way to screw up C++ builds
against C headers. This adds that missing end-of-declarations
thing so C++ knows that its own files are name-mangled.

Thus the build should work again.

Signed-off-by: Andreas Ericsson <ae@op5.se>
lib/rbtree.c: Initialize num_nodes when creating trees

Without this patch, tests sometimes fail due to the value
being uninitialized but used when attempting to create hash
tables to store objects, which then can become ridiculously
large (like, with several billion entries), causing some
malloc() or other to fail horribly.

Signed-off-by: Andreas Ericsson <ae@op5.se>
commands: Add missing SEND_CUSTOM_SVC_NOTIFICATION

This patch adds in the implementation of SEND_CUSTOM_SVC_NOTIFICATION
which was accidentally removed in a previous overhaul of the command
code.

This fixes issue #65.

Reported-by: Johan Ryberg <johan@securit.se>
Signed-off-by: Anton Lofgren <anton.lofgren@gmail.com>
Merge pull request #67 from catharsis/issue-65

Issue 65
Make timeperiod timerange endings be non-inclusive

With timeperiods like this:
define timeperiod {
  timeperiod_name Test_exclude2
  alias           Test2 for exclude timeperiod
  tuesday 2 16:30-24:00
  exclude         myexclude2
}

define timeperiod{
  timeperiod_name myexclude2
  alias myexclude2
  tuesday 00:00-23:58
}

you would expect checks to start running at 23:58 and stop running
at midnight. Without this patch, however, checks would start at
23:59, which is counterintuitive. One could argue that timerange
endtimes should be inclusive, but then we wouldn't have the 24:00
syntax to mark the end of the day. Since we *do* have 24:00 to
mark end of the day, we must really consider both start and end
times to be in "HH:MM:00" notation, which is exactly what this
patch does.

Signed-off-by: Andreas Ericsson <ae@op5.se>
config: Kill all-but-deleted auto rescheduling

It didn't do anything, it just pretended it did. Stop pretending.

Signed-off-by: Robin Sonefors <robin.sonefors@op5.com>
t-tap config: Remove killed off variables

We don't want them around anymore, as they cause logfiles to
appear in the t-tap directory during "make distcheck", which
in turn causes the build to fail.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Merge branch 'master' of https://github.com/naemon/naemon-core