Remove Nagios-beta.png reference from spec file

The file cannot be found, and rpm will not build with an invalid
source reference.

Signed-off-by: Daniel Wittenberg <dwittenberg2008@gmail.com>
Signed-off-by: Andreas Ericsson <ae@op5.se>
core: Avoid running checks when they're globally disabled

Previously we would execute implicit host dependency checks (for
child and parent hosts) when we received a passive host check
result for either the parent or the child, and and the same went
for both types of host and service dependencies, even though the
check type in question was globally disabled (either by config or
by external command).

This patch alters the behaviour so that disabling checks really
disables them (which I assume is desired), but also means that
submitting passive service checks to hosts and services that in
some way depend upon or are depended upon by other objects can
result in the wrong type of notification being sent out (ie,
"DOWN" instead of "UNREACHABLE" for hosts).

There's nothing we can do about that if we really want to follow
the users wishes, but it's quite a lot easier to explain why
dependency checks aren't working properly when checks are
globally disabled than it is to explain why checks are being
executed.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Remove tinderbox build-script

The location it's pointing to doesn't exist, and insofar as I know
we have no tinderbox build servers anywhere, so it's just dead
code.

Signed-off-by: Andreas Ericsson <ae@op5.se>
core: Add perfect-hash sources to version control

It's stupid and useless to have them sitting on my laptop, and it's
even dumber to not use gperf output as-is. This patch fixes both
those issues, allowing anyone to easily extend the types and names
of variables we can get from our worker-processes.

We do check in the output of the gperf run though, as we'd otherwise
introduce a new dependency into the build. Only people who want to
add variables to the worker processes need to bother with the new
dependency.

Signed-off-by: Andreas Ericsson <ae@op5.se>
core: Don't free the lock file path too soon

It's used after the main loop ends in the main function to remove the
lock file once we're shut down.

As the variable was already freed and pointed to NULL, unlink would not
remove the lock file, but instead return EFAULT. This is not how daemons
are supposed to behave.

Signed-off-by: Robin Sonefors <robin.sonefors@op5.com>
core: Fix checkresult spool reaping

Not that it's used anymore (except as a deprecated legacy interface
for passing passive checkresults to Nagios), but we really shouldn't
bomb out before we've even started parsing results.

Signed-off-by: Andreas Ericsson <ae@op5.se>
core: Fix checkresult sourcename assignment

Since we parse sourcename as a const char pointer if no engine is
set, we can make this really easy by just not setting the engine
and just have Nagios return the string for us.

Signed-off-by: Andreas Ericsson <ae@op5.se>
core: Avoid running dependency host checks when globally disabled

When we receive non-OK service checks we'd otherwise end up running
host checks, even though they're disabled. Since global commands
really are meant to be honored, we do that with this patch.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Updated version for 4.0.0-beta1 release
xod: Stop leaking memory when using precached objects

Even though *using* precached objects is a pretty dumb idea nowadays,
we still support it and shouldn't leak memory when it's used.

Signed-off-by: Andreas Ericsson <ae@op5.se>
core: Stop segfaulting when core workers disconnect

Previously we tried to remove the worker from the correct worker
list, but the worker list was a NULL pointer since we never set
the core worker list for core workers.

Even though it's unseemly to brag, I'm kinda proud of the fact that
the workers don't die without being forcefully bludgeoned to death
by a signal.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Update to version 4.0.0beta2

(impossible-to-trigger-) segfault bug fixed, so it's appropriate.

Signed-off-by: Andreas Ericsson <ae@op5.se>
core: Make it obvious when checks time out

When checks time out and we just say "Check did not exit properly",
people think things are severely broken, even though it's sort of
true that the check really *didn't* exit properly when we killed it.

We can be nicer though, and with this patch we are just that.

Signed-off-by: Andreas Ericsson <ae@op5.se>
core: Restore the "Checked %u <objects>" lines for escalations

Apparently, some people use scripts to verify and report how many of
each object type is loaded, and when we removed the "Checked" lines
for host and service escalations (since they're pre-verified), we
screwed those people over. Since it's an easy fix (that also lets us
remove some of the spammier output), we might as well add it back in.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Enhance navbar search to also look for aliases and addresses

This patch introduces two new configuration options to cgi.cfg, with
the obvious implications:
  * navbar_search_addresses causes the quicksearch thing to also scan
    host addresses when looking for matches.
  * navbar_search_aliases causes the quicksearch to also scan host
    aliases when looking for matches.

The options are turned on by default but can be disabled by setting
the necessary options in cgi.cfg.

Signed-off-by: Jonas Meurer <jonas@freesources.org>
Signed-off-by: Andreas Ericsson <ae@op5.se>
nebmods: Stop with the move-nebmod nonsense

The explanation for why we did this was thus:

> The problem with loaded modules is that if you overwrite the original
> file (e.g. using 'mv'), you do not alter the inode of the original
> file.

Correct.

> Since the original file/module is memory-mapped in some fashion,
> Nagios will segfault the next time an event broker call is directed to
> one of the module's callback functions.

Of course it won't. Why not? The first quoted sentence explained it
perfectly - the same inode still points to the same fil, so putting
another inode in the original path won't make one bit of difference.

What would cause a segfault, though, is truncating the module file and
filling it with new content so the addresses of symbols change while the
inode stays the same. You shouldn't do that.

> This is extremely problematic when it comes to upgrading NEB modules
> while Nagios is running.

To sum up the above: no, it isn't.

In addition to having a bogus reason for existing in the first place,
the code itself is problematic: it tends to cause an accumulation of
weird and nonsensical nebmod files in your var directory over time,
while also breaking any sort of clever debuginfo scheme employed by most
linux distros today, because the debuginfo can't be tracked down when we
invent new, faked names literally only in order to confuse linkers.

(ae's comments):
While it's true that a new inode will point to a new file, most
programs that need to write to the output file tends to do
open(path, O_WRONLY | O_CREAT | O_TRUNC), which truncates the file
rather than removing it first, and then we end up in the segfault
place again. However, this doesn't appear to be a problem on later
linux kernels (based on *very* rudimentary testing), and it does
make us mimic how apache uses dlopen() exactly, so it's apparently
more than possible to work around any and all problems.

For module authors, a good step is to add rules like this to their
makefiles, which avoids the trouble when rebuilding a module that's
currently being tested:
ndomod.so: all.o the.o happy.o object.o files.o
	rm -f $@
	$(CC) -fPIC -o $@ $< $(LIBS)

Signed-off-by: Robin Sonefors <robin.sonefors@op5.com>
Signed-off-by: Andreas Ericsson <ae@op5.se>
Make cgi's build again

Meh. Changing a variable name from a patch without even trying to
build it is stupid (mea culpa).

This fixes up commit 2a5c6d1f3e0cd48ec6489e188ed7abc321873cfa,
which was good the way it was and which I screwed up somewhat.

With this patch on top, things are just peachy once again.

Signed-off-by: Andreas Ericsson <ae@op5.se>
base/workers.c: fix return code of wproc_run_job()

In case of errors, write(2) may return 0, which is interpreted as OK
in the caller.

While at it, increase jobs_running and jobs_started on worker process
only if write succeded and do similarly for the loadctl struct.

Original-patch-by: Ricardo Maraschini <ricardo.maraschini@gmail.com>
Signed-off-by: Andreas Ericsson <ae@op5.se>
core: Add host/service-to-group link when using large install tweaks

There's an early return when using large installation tweaks which
caused us to not populate the {host,service}groups_ptr properly
when large installation tweaks were in effect.

This patch moves the list-addition to before the tweak, causing the
link to always be created.

Signed-off-by: Andreas Ericsson <ae@op5.se>
core wproc: Log properly when important helper scripts fail

When important helper-scripts fail, we used to silently ignore that
unless they timed out. Since it's sort of important that eventhandlers
and notification scripts run like they're supposed to, we must log
properly when they don't so post-mortem debugging of missed
notifications and failed eventhandler runs is not only possible, but
positively convenient.

This patch adds a LOT of logging for all non-check system commands
executed that either get killed by a signal, fail to execute
properly or that simply time out.

This means all kinds of helper scripts now use the same API for
logging their state, so a notification script that fails to find
the "sendmail" binary (or whatever) can simply say so on stderr
(or stdout) and then exit with a non-zero exit-status.

Neato.

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