[PATCH] Don't skip host checks when service checks are disabled

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

[PATCH] Don't skip host checks when service checks are disabled

Post by Guest »


--A6N2fC+uXW/VQSAv
Content-Type: multipart/mixed; boundary="r5Pyd7+fXNt84Ff3"
Content-Disposition: inline


--r5Pyd7+fXNt84Ff3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Tue, Sep 21, 2010 at 12:22:36AM +0100, Stephen Gran said:
> This is my simple minded attempt at matching the originally reported
> failure case (host checks being skipped when service checks disabled).
> It fails without my patch and passes with my patch. Hopefully it's
> clear enough - please ask for clarification if not.

Um, and now actually with the patch ...
--=20
--------------------------------------------------------------------------
| Stephen Gran | "Hey Ivan, check your six." -- |
| [email protected] | Sidewinder missile jacket patch, |
| http://www.lobefin.net/~steve | showing a Sidewinder driving up the |
| | tail of a Russian Su-27 |
--------------------------------------------------------------------------

--r5Pyd7+fXNt84Ff3
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="0001-Don-t-skip-host-checks-when-service-checks-are-disab.patch"
Content-Transfer-Encoding: quoted-printable

=46rom 7d65963c7d6176dc6bd3e642f852713b3a1aa4fe Mon Sep 17 00:00:00 2001
=46rom: Stephen Gran
Date: Tue, 21 Sep 2010 00:09:48 +0100
Subject: [PATCH] Don't skip host checks when service checks are disabled

The problem here is when a host check is scheduled after a service check,
but service checks are for disabled. Take the following sequence:

sc1 -> hc1

when entering event_execution_loop(), run_event starts set to TRUE.
Match of a service check event is true, and servicechecks are disabled,
so run_event changes to FALSE, and the event gets re-eschuled, and
removed from the current event queue.

Next in the work queue is the hc1 event, and it is checked because the
next block is an "if" and not "else if", which would result in that event
being handled in the next loop. In this case, as hc1 is already visible
to the queue checker, and the condition for a hostcheck event matches, and
run_event is set to FALSE from before, the hc1 event is silently skipped.

The attached test case only attempts to match this case - a host check
immediately following a service check in the work queue when service
checks are disabled.

Signed-off-by: Stephen Gran
---
base/events.c | 3 +-
t-tap/test_events.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++=
+--
2 files changed, 83 insertions(+), 6 deletions(-)

diff --git a/base/events.c b/base/events.c
index 0c9a91b..a0fbfc4 100644
--- a/base/events.c
+++ b/base/events.c
@@ -1082,7 +1082,6 @@ int event_execution_loop(void){
run_event=3DFALSE;
}
=20
- }
=20
/* Removed. Reports that if you disable all service checks, service che=
cks continue to be run. Also
t-tap/test_events will fail if this flag is set - TV
@@ -1091,7 +1090,7 @@ int event_execution_loop(void){
/* run_event=3DTRUE; */
=20
/* run a few checks before executing a host check... */
- if(event_list_low->event_type=3D=3DEVENT_HOST_CHECK){
+ }else if(event_list_low->event_type=3D=3DEVENT_HOST_CHECK){
=20
temp_host=3D(host *)event_list_low->event_data;
=20
diff --git a/t-tap/test_events.c b/t-tap/test_events.c
index 76a1598..6a5fe94 100644
--- a/t-tap/test_events.c
+++ b/t-tap/test_events.c
@@ -92,7 +92,11 @@ service *service_list;
=20
int check_for_expired_comment(unsigned long temp_long) {}
void broker_timed_event(int int1, int int2, int int3, timed_event *timed_e=
vent1, struct timeval *timeval1) {}
-int perform_scheduled_host_check(host *temp_host,int int1,double double1) =
{}
+int perform_scheduled_host_check(host *temp_host,int int1,double double1) {
+ time_t now=3D0L;
+ time(&now);
+ temp_host->last_check =3D now;
+}
int check_for_expired_downtime(void) {}
int reap_check_results(void) {}
void check_host_result_freshness() {}
@@ -108,6 +112,9 @@ time_t get_next_log_rotation_time(void) {

...[email truncated]...


This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
Locked