[Nagios-devel] [PATCH] xrddefault: Fix loading of notified_on from

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

[Nagios-devel] [PATCH] xrddefault: Fix loading of notified_on from

Post by Guest »

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
---
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) notified_on |= (atoi(val) > 0 ? OPT_DOWN : 0);
else if(!strcmp(var, "notified_on_unreachable"))
- temp_host->notified_on |= (atoi(val) > 0 ? 1 : 0) 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) notified_on |= ((atoi(val) > 0) ? OPT_UNKNOWN : 0);
else if(!strcmp(var, "notified_on_warning"))
- temp_service->notified_on |= ((atoi(val) > 0) ? 0 : 1) notified_on |= ((atoi(val) > 0) ? OPT_WARNING : 0);
else if(!strcmp(var, "notified_on_critical"))
- temp_service->notified_on = ((atoi(val) > 0) ? 0 : 1) 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 post was automatically imported from historical nagios-devel mailing list archives
Original poster: robin.sonefors@op5.com
Locked