naemon release 0.8.0

Signed-off-by: Sven Nierlein <Sven.Nierlein@consol.de>
lib/iobroker: Silence valgrind on careless iobroker_close() use

When iobroker_close() was called with a negative filedescriptor we
still issued close() on it, which makes valgrind scream bloody
murder. This patch should fix that.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Make it a bit easier to build addon projects against naemon headers

The previous defaults.h file included autotool macros that were only
set as preprocessor macros on the command line, which made defaults.h
unusable from addon projects.

With this patch we add a buildopts.h, where projects that don't want
to link against the naemon sources but still want to know which
defaults to use (for whatever reason) can #include the defaults.h
file and get the compile-time defaults.

Signed-off-by: Andreas Ericsson <ae@op5.se>
lib/worker: Be more anal about not loosing check output

When multiple checks run concurrently, we can get a signal while still
reading check output. This could cause us to forget about reading the
rest of the output. Be careful not to do that.

This fixes bug op5#8331.

Reviewed-and-discovered-by: Robin Sonefors <robin.sonefors@op5.com>
Signed-off-by: Andreas Ericsson <ae@op5.se>
configure.ac: Make autoreconf run cleanly on cent5

First, it turns out that autoconf 2.59 actually works out. Second,
AC_PROG_LIBTOOL should be used by autoconf projects when they use
libtool - at least older versions. Third, the m4 directory isn't checked
in and isn't autocreated, so remove the AC_CONFIG_MACRO_DIR again - if
you want to use it, go do something sane with m4. I'm not a fan of m4.

Signed-off-by: Robin Sonefors <robin.sonefors@op5.com>
lib/worker: Stop reading if nothing more to read

In the last patch, I over-the-shoulder-programmed away the support for
exiting gather_output when the process is shutting down. Ooups.

Change-Id: I6b041736df4d05899d1686d875e42a1d3c9ce056
Signed-off-by: Robin Sonefors <robin.sonefors@op5.com>
workers: Count correctly when workers are chocked

When a worker is choked, we would decrement the number of active jobs
without first incrementing them. This leads to seemingly 4.2 billion
active jobs on said worker, which makes nagios refuse to schedule any
more checks in that direction. Increment before decrementing, so the
numbers add up.

Change-Id: I85bda501b1671274750f26db0873a24e79ca9e0c
Signed-off-by: Robin Sonefors <robin.sonefors@op5.com>
Merge branch 'dev/lost-output'
Introduce code coverage testing for libnaemon

It's the foundation upon which we put all other building blocks, so
let's be anal when we test it and aim for close to 100% code coverage,
minus the _strerror() functions and a few others that simply don't
apply.

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

Namely, ignore pretty much all test*.trs and test*.log files, although
we do so on a directory basis, since we may want to incorporate test
data later and that test-data will almost certainly have .log files if
we do.

Also, remove the tests from the t-tap directory .gitignore that haven't
been built these past five years.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Fix a bunch of compiler warnings and annoyances with tests

The indentation was pretty horrible, and the plethora of warnings
was just appalling. Naming variables the same as types is not only
frowned upon, but an actual error for many compilers, and mixing
declarations and statements is illegal in ISO C90.

The rest is mostly just getting rid of shadowed variables and
functions and getting included files in the right order.

Signed-off-by: Andreas Ericsson <ae@op5.se>
sretention: Remove some debugging output

Leftover printf()'s from the times when state retention was made
configuration sensitive.

Signed-off-by: Andreas Ericsson <ae@op5.se>
downtime: Log properly when and why we fail to add downtime

Previously that stuff ended up in the debug log, which isn't always
enabled. With this patch, it will end up in the normal logfile
where real errors belong (even though they may well be user errors).

Signed-off-by: Andreas Ericsson <ae@op5.se>
t-tap/smallconfig/retention.dat: Make retained host downtime sensible

It doesn't make sense to have zero-second downtimes, and the code we
have today rightly denies such crap as nonsense. However, the tests
in test_config.c (well, soon-to-be test_config.c) attempts to locate
a host downtime with exactly those parameters, stashed in our
retention data testfile.

This patch fixes it by nudging the end_time by 10 seconds, thus
allowing the downtime a small piece of space in the fourth dimension
in where it can, if not thrive, then at least exist.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Reintroduce config and retention data testing

The old test_nagios_config.c has been revived as test_config.c and
has been given some love so that it actually works and passes just
fine now.

Signed-off-by: Andreas Ericsson <ae@op5.se>
t-tap/smallconfig/naemon.cfg: Enable logging, but to stdout

All the automated testrunners we have grab stdout and send us in
nice emails and stuff. With this patch we'll be spending a little
less time bughunting and a little more time on the fun stuff, like
eating icecream, drinking beer and going bungyjumping.

Signed-off-by: Andreas Ericsson <ae@op5.se>
t-tap/test_timeperiods: Fix 'em

Faster than the speed of Robin. Shuzam!

Signed-off-by: Andreas Ericsson <ae@op5.se>
macros: Escape note macros as well

It seems that randomly blacklisting macros that a user manages to put a
doublequote into, instead of realizing that our whole approach is FUBAR
and that pretty much any macro can be used to break notification
commands, is the way to go. Jay :(

This resolves bug op5#8266.

Change-Id: I746b140947ca397059907518ea4d87c21ce138fe
Signed-off-by: Robin Sonefors <robin.sonefors@op5.com>
test_macros: Escape {host,service}group note macros

This is pretty much identical to the patch in 83d1046dfb6 (which
fixes op5#8266) and as that commit implies, this is a nasty way of dealing
with the issue. There seems to be something fundamentally wrong with
the way macros work today, and we should probably spend some time
working out a better solution.

Anyway, I also added a test which should cover regressions of the service
part of op5#8266, which is the same issue as op5#8270, but for service and host
notes.

This fixes op5#8270.

Change-Id: Ic382c07b1aee988b01234bccdcd09e2d8d99a910
Signed-off-by: Anton Lofgren <alofgren@op5.com>
events: Remove "we're polling" from IPC log

It makes the IPC log become unusable. Put it in the scheduler log at
maximum verbosity - the scheduler log isn't used by anything anyway.

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