Tests: new tests in test_checks

test_checks has been updated with a handful of new tests that will. In
addition, the tests have been update to support future testing of passive
passive checks.
Tests: added passive checks to test_checks
JSON: Added json_escape_string() function

This commit adds a json_escape_string() function to escape strings based
on a passed set of replacement pairs. The variable argument functionality
in json_string() was also removed because it is never used and has been
demonstrated to cause problems with strings containing % signs.
JSON: Escape percent signs in most strings

A printf-family function is used for flexibility reasons when adding
a string to the JSON structure. For this reason any percent signs in
strings generated external to the JSON code (object attributes, plugin
output, etc.) should have percent signs escaped (to "%%") before being
added in the json_*_append_string() functions to prevent the % sign
from being interpreted as a format specifier.

This commit accomplishes that by passing a structure with the escapes
to the json_*_append_string() functions where escaping is desired and
a NULL when it is not desired. When json_object_append_string() sees a
non-null structure, it calls json_escape_string() on the string before
it calls the printf-family function.
Checks: Avoid bunching of checks delayed due to timeperiod constraints

For checks that need to be scheduled in the future because they are
not currently in a timeperiod that allows checks, this commit adds
a delay so that we don't get a bunch of checks scheduled at the same
time and thus have spikey load on the system.

Specifically for checks that are delayed at Nagios core start-up,
the delay is equal to the delay that would have been applied if the
checked had been scheduled immediately. For checks that are being
rescheduled due to a regular interval, the delay past the start
of the valid timeperiod is a random number between 0 and the interval
length.

The latter delay could be better handled by applying the same criteria
that are applied at start-up, but that criteria is not available when
checks are rescheduled. Making the criteria avaiable would require
additional fields in the host and service structures.
Update READMEUpdate README.
Limit the number of autocalculated core workers.

When no value is given for check_workers in the configuration, the
"number of CPUs * 1.5" autocalculation can result in an excessive number
of workers on machines with a large number of schedulable cores. We now
set a maximum of 48 autocalculated workers.

This alse ensures specialized_workers is set to NULL after destroying
the table to avoid leaving a dangling pointer, and returns an error from
init_workers() if allocation of the specialized_workers table fails.

Reported-by: Janice Singh
Signed-off-by: Eric J. Mislivec <emislivec@nagios.com>
JSON CGI: Now escaping all required characters

This commit implements escaping for all characters required by the JSON
specification.
Checks: Fixed scheduling of service checks

Commit 62af86766d24e73c33edb76ae01ea1ac8dcb6f04 introduced a random delay
when rescheduling all service checks. This should have only been applied
when the next check time is more than the check interval (or retry interval)
in the future because of check timeperiod constraints. This commit fixes
that issue. The logic was already correct for rescheduling host checks.
JSON: Removed quotes around numeric durations

Previously durations in JSON, such as those in the availability report,
were quoted with double quotes even when they were numeric values. This
commit removes the quotes for numeric values, but preserves them when
the duration is in the format "xd xh xm xs".
JSON: Escape backslashes first

This commit causes backslashes to be escaped first so they don't cause
backslashes created by other escapes from being escaped themselves.
Merge branch 'master' of github.com:NagiosEnterprises/nagioscore into emislivec-tracker0582-runcmd
runcmd: Continue to fork() unbalanced commands.

The worker layer & event/check scheduling aren't handling an error
return from runcmd_open() well. To get sensible handling of commands
with unbalanced quotes at the higher layers, continue on to fork a
child process that will exit with an error status and write a message
to stderr that will get picked up by the worker and sent to Core.
Currently, if we just return an error from the parent (worker) we can
end up in situations where the failing command will be repeatedly
rescheduled to run immediately.