[PATCH] xrddefault: Fix loading of notified_on from retention data

Robin Sonefors robin.sonefors at op5.com
Mon Jul 8 18:01:14 CEST 2013


There were several problems with how notified_on was loaded from
retention data.

To begin with, notified_on_critical would overwrite the work any other
notified_on* flag had done. That's not very social of it, is it?

To continue, notified_on_warning and notified_on_critical would try to
set their respective bit in the bitmask only if they were *not* set in
the retention data. That's not very logical of it, is it?

Finally, the wrong variable was used for shifting the state, so rather
than setting the flag (1 << STATE), all the fields for both hosts and
services would set the bit at ((1 << STATE) << STATE), leading to values
much larger than expected. That's not very clever of it, is it?

All of these things should be fixed now, so recoveries should once again
work after nagios restarts.

Signed-off-by: Robin Sonefors <robin.sonefors at op5.com>
---
 xdata/xrddefault.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/xdata/xrddefault.c b/xdata/xrddefault.c
index 209781a..a899a17 100644
--- a/xdata/xrddefault.c
+++ b/xdata/xrddefault.c
@@ -1160,9 +1160,9 @@ int xrddefault_read_state_information(void) {
 							else if(!strcmp(var, "last_time_unreachable"))
 								temp_host->last_time_unreachable = strtoul(val, NULL, 10);
 							else if(!strcmp(var, "notified_on_down"))
-								temp_host->notified_on |= (atoi(val) > 0 ? 1 : 0) << OPT_DOWN;
+								temp_host->notified_on |= (atoi(val) > 0 ? OPT_DOWN : 0);
 							else if(!strcmp(var, "notified_on_unreachable"))
-								temp_host->notified_on |= (atoi(val) > 0 ? 1 : 0) << OPT_UNREACHABLE;
+								temp_host->notified_on |= (atoi(val) > 0 ? OPT_UNREACHABLE : 0);
 							else if(!strcmp(var, "last_notification"))
 								temp_host->last_notification = strtoul(val, NULL, 10);
 							else if(!strcmp(var, "current_notification_number"))
@@ -1429,11 +1429,11 @@ int xrddefault_read_state_information(void) {
 									temp_service->check_options = atoi(val);
 								}
 							else if(!strcmp(var, "notified_on_unknown"))
-								temp_service->notified_on |= ((atoi(val) > 0) ? 1 : 0) << OPT_UNKNOWN;
+								temp_service->notified_on |= ((atoi(val) > 0) ? OPT_UNKNOWN : 0);
 							else if(!strcmp(var, "notified_on_warning"))
-								temp_service->notified_on |= ((atoi(val) > 0) ? 0 : 1) << OPT_WARNING;
+								temp_service->notified_on |= ((atoi(val) > 0) ? OPT_WARNING : 0);
 							else if(!strcmp(var, "notified_on_critical"))
-								temp_service->notified_on = ((atoi(val) > 0) ? 0 : 1) << OPT_CRITICAL;
+								temp_service->notified_on |= ((atoi(val) > 0) ? OPT_CRITICAL : 0);
 							else if(!strcmp(var, "current_notification_number"))
 								temp_service->current_notification_number = atoi(val);
 							else if(!strcmp(var, "current_notification_id"))
-- 
1.7.11.7


------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev




More information about the Developers mailing list