diff --git a/src/naemon/macros.c b/src/naemon/macros.c index 587a75a4..c0f460c8 100644 --- a/src/naemon/macros.c +++ b/src/naemon/macros.c @@ -627,6 +627,10 @@ static int grab_standard_host_macro_r(nagios_macros *mac, int macro_type, host * objectlist *temp_objectlist = NULL; time_t current_time = 0L; unsigned long duration = 0L; + int days = 0; + int hours = 0; + int minutes = 0; + int seconds = 0; char *buf1 = NULL; char *buf2 = NULL; int total_host_services = 0; @@ -704,10 +708,19 @@ static int grab_standard_host_macro_r(nagios_macros *mac, int macro_type, host * case MACRO_HOSTDURATION: time(¤t_time); duration = (unsigned long)(current_time - temp_host->last_state_change); + if (macro_type == MACRO_HOSTDURATIONSEC) *output = (char *)mkstr("%lu", duration); else { - *output = (char *)mkstr("%s", duration_string(duration)); + + days = duration / 86400; + duration -= (days * 86400); + hours = duration / 3600; + duration -= (hours * 3600); + minutes = duration / 60; + duration -= (minutes * 60); + seconds = duration; + *output = (char *)mkstr("%dd %dh %dm %ds", days, hours, minutes, seconds); } break; case MACRO_HOSTEXECUTIONTIME: @@ -735,7 +748,7 @@ static int grab_standard_host_macro_r(nagios_macros *mac, int macro_type, host * *output = (char *)mkstr("%d", temp_host->current_notification_number); break; case MACRO_HOSTNOTIFICATIONID: - *output = temp_host->current_notification_id; + *output = (char *)mkstr("%lu", temp_host->current_notification_id); break; case MACRO_HOSTEVENTID: *output = (char *)mkstr("%lu", temp_host->current_event_id); @@ -744,32 +757,10 @@ static int grab_standard_host_macro_r(nagios_macros *mac, int macro_type, host * *output = (char *)mkstr("%lu", temp_host->last_event_id); break; case MACRO_HOSTPROBLEMID: - if(temp_host->current_problem_id != NULL) - *output = temp_host->current_problem_id; + *output = (char *)mkstr("%lu", temp_host->current_problem_id); break; case MACRO_LASTHOSTPROBLEMID: - if(temp_host->last_problem_id != NULL) - *output = temp_host->last_problem_id; - break; - case MACRO_HOSTPROBLEMSTART: - *output = (char *)mkstr("%lu", (unsigned long)temp_host->problem_start); - break; - case MACRO_HOSTPROBLEMEND: - *output = (char *)mkstr("%lu", (unsigned long)temp_host->problem_end); - break; - case MACRO_HOSTPROBLEMDURATIONSEC: - case MACRO_HOSTPROBLEMDURATION: - if(temp_host->problem_end > 0) { - duration = (unsigned long)(temp_host->problem_end - temp_host->problem_start); - } else if(temp_host->problem_start > 0) { - time(¤t_time); - duration = (unsigned long)(current_time - temp_host->problem_start); - } - if (macro_type == MACRO_HOSTPROBLEMDURATIONSEC) - *output = (char *)mkstr("%lu", duration); - else { - *output = (char *)mkstr("%s", duration_string(duration)); - } + *output = (char *)mkstr("%lu", temp_host->last_problem_id); break; case MACRO_HOSTACTIONURL: if (temp_host->action_url) @@ -959,6 +950,10 @@ static int grab_standard_service_macro_r(nagios_macros *mac, int macro_type, ser objectlist *temp_objectlist = NULL; time_t current_time = 0L; unsigned long duration = 0L; + int days = 0; + int hours = 0; + int minutes = 0; + int seconds = 0; char *buf1 = NULL; char *buf2 = NULL; @@ -1049,19 +1044,31 @@ static int grab_standard_service_macro_r(nagios_macros *mac, int macro_type, ser break; case MACRO_SERVICEDURATIONSEC: case MACRO_SERVICEDURATION: + time(¤t_time); duration = (unsigned long)(current_time - temp_service->last_state_change); + + /* get the state duration in seconds */ if (macro_type == MACRO_SERVICEDURATIONSEC) *output = (char *)mkstr("%lu", duration); + + /* get the state duration */ else { - *output = (char *)mkstr("%s", duration_string(duration)); + days = duration / 86400; + duration -= (days * 86400); + hours = duration / 3600; + duration -= (hours * 3600); + minutes = duration / 60; + duration -= (minutes * 60); + seconds = duration; + *output = (char *)mkstr("%dd %dh %dm %ds", days, hours, minutes, seconds); } break; case MACRO_SERVICENOTIFICATIONNUMBER: *output = (char *)mkstr("%d", temp_service->current_notification_number); break; case MACRO_SERVICENOTIFICATIONID: - *output = temp_service->current_notification_id; + *output = (char *)mkstr("%lu", temp_service->current_notification_id); break; case MACRO_SERVICEEVENTID: *output = (char *)mkstr("%lu", temp_service->current_event_id); @@ -1070,30 +1077,10 @@ static int grab_standard_service_macro_r(nagios_macros *mac, int macro_type, ser *output = (char *)mkstr("%lu", temp_service->last_event_id); break; case MACRO_SERVICEPROBLEMID: - *output = temp_service->current_problem_id; + *output = (char *)mkstr("%lu", temp_service->current_problem_id); break; case MACRO_LASTSERVICEPROBLEMID: - *output = temp_service->last_problem_id; - break; - case MACRO_SERVICEPROBLEMSTART: - *output = (char *)mkstr("%lu", (unsigned long)temp_service->problem_start); - break; - case MACRO_SERVICEPROBLEMEND: - *output = (char *)mkstr("%lu", (unsigned long)temp_service->problem_end); - break; - case MACRO_SERVICEPROBLEMDURATIONSEC: - case MACRO_SERVICEPROBLEMDURATION: - if(temp_service->problem_end > 0) { - duration = (unsigned long)(temp_service->problem_end - temp_service->problem_start); - } else if(temp_service->problem_start > 0) { - time(¤t_time); - duration = (unsigned long)(current_time - temp_service->problem_start); - } - if (macro_type == MACRO_SERVICEPROBLEMDURATIONSEC) - *output = (char *)mkstr("%lu", duration); - else { - *output = (char *)mkstr("%s", duration_string(duration)); - } + *output = (char *)mkstr("%lu", temp_service->last_problem_id); break; case MACRO_SERVICEACTIONURL: if (temp_service->action_url) @@ -1582,11 +1569,6 @@ static int grab_macrox_value_r(nagios_macros *mac, int macro_type, char *arg1, c case MACRO_LASTHOSTPROBLEMID: case MACRO_LASTHOSTSTATE: case MACRO_LASTHOSTSTATEID: - case MACRO_HOSTPROBLEMSTART: - case MACRO_HOSTPROBLEMEND: - case MACRO_HOSTPROBLEMDURATIONSEC: - case MACRO_HOSTPROBLEMDURATION: - /* a standard host macro */ if (arg2 == NULL) { @@ -1706,10 +1688,6 @@ static int grab_macrox_value_r(nagios_macros *mac, int macro_type, char *arg1, c case MACRO_LASTSERVICEPROBLEMID: case MACRO_LASTSERVICESTATE: case MACRO_LASTSERVICESTATEID: - case MACRO_SERVICEPROBLEMSTART: - case MACRO_SERVICEPROBLEMEND: - case MACRO_SERVICEPROBLEMDURATIONSEC: - case MACRO_SERVICEPROBLEMDURATION: /* use saved service pointer */ if (arg1 == NULL && arg2 == NULL) { @@ -2713,14 +2691,6 @@ int init_macrox_names(void) add_macrox_name(HOSTVALUE); add_macrox_name(SERVICEVALUE); add_macrox_name(PROBLEMVALUE); - add_macrox_name(HOSTPROBLEMSTART); - add_macrox_name(HOSTPROBLEMEND); - add_macrox_name(HOSTPROBLEMDURATIONSEC); - add_macrox_name(HOSTPROBLEMDURATION); - add_macrox_name(SERVICEPROBLEMSTART); - add_macrox_name(SERVICEPROBLEMEND); - add_macrox_name(SERVICEPROBLEMDURATIONSEC); - add_macrox_name(SERVICEPROBLEMDURATION); return OK; } diff --git a/src/naemon/objects_host.c b/src/naemon/objects_host.c index 0037d136..1e6aaac1 100644 --- a/src/naemon/objects_host.c +++ b/src/naemon/objects_host.c @@ -188,6 +188,7 @@ int setup_host_variables(host *new_host, const char *display_name, const char *a new_host->last_hard_state = initial_state; new_host->current_attempt = (initial_state == STATE_UP) ? 1 : max_attempts; new_host->notifications_enabled = (notifications_enabled > 0) ? TRUE : FALSE; + new_host->display_status = initial_state; return 0; } @@ -326,9 +327,6 @@ void destroy_host(host *this_host) nm_free(this_host->icon_image_alt); nm_free(this_host->vrml_image); nm_free(this_host->statusmap_image); - nm_free(this_host->current_notification_id); - nm_free(this_host->last_problem_id); - nm_free(this_host->current_problem_id); nm_free(this_host); } @@ -596,6 +594,31 @@ int log_host_event(host *hst) { unsigned long log_options = 0L; + /* set displays status */ + /* handle Downtime and ACK */ + // if ( (hst->scheduled_downtime_depth > 0) && (hst->problem_has_been_acknowledged == FALSE) ) { + if ( hst->scheduled_downtime_depth > 0 ) { + hst->display_status = 1; + } + else if (hst->problem_has_been_acknowledged == TRUE) { + hst->display_status = 2; + } + /* Flapping*/ + else if (hst->is_flapping > 0) { + hst->display_status = 3; + } + /* Unreachable */ + else if (hst->current_state == STATE_UNREACHABLE) { + hst->display_status = 7; + } + /* Down */ + else if (hst->current_state == STATE_DOWN) { + hst->display_status = 8; + } + else if (hst->current_state == STATE_OK) { + hst->display_status = 0; + } + /* get the log options */ if (hst->current_state == STATE_DOWN) log_options = NSLOG_HOST_DOWN; diff --git a/src/naemon/objects_host.h b/src/naemon/objects_host.h index 099bec32..38ce1567 100644 --- a/src/naemon/objects_host.h +++ b/src/naemon/objects_host.h @@ -89,10 +89,8 @@ struct host { int current_attempt; unsigned long current_event_id; unsigned long last_event_id; - char *current_problem_id; - char *last_problem_id; - time_t problem_start; - time_t problem_end; + unsigned long current_problem_id; + unsigned long last_problem_id; double latency; double execution_time; int is_executing; @@ -112,7 +110,7 @@ struct host { int notified_on; int current_notification_number; int no_more_notifications; - char *current_notification_id; + unsigned long current_notification_id; int check_flapping_recovery_notification; int scheduled_downtime_depth; int pending_flex_downtime; /* UNUSED */ @@ -124,6 +122,7 @@ struct host { struct objectlist *comments_list; double percent_state_change; int total_services; + int display_status; unsigned long modified_attributes; struct command *event_handler_ptr; struct command *check_command_ptr; diff --git a/src/naemon/objects_service.c b/src/naemon/objects_service.c index d1e8e3ed..02ee900c 100644 --- a/src/naemon/objects_service.c +++ b/src/naemon/objects_service.c @@ -197,6 +197,7 @@ int setup_service_variables(service *new_service, const char *display_name, cons new_service->current_state = initial_state; new_service->last_state = initial_state; new_service->last_hard_state = initial_state; + new_service->display_status = initial_state; /* check the service check_command */ @@ -339,9 +340,6 @@ void destroy_service(service *this_service, int truncate_lists) nm_free(this_service->action_url); nm_free(this_service->icon_image); nm_free(this_service->icon_image_alt); - nm_free(this_service->current_notification_id); - nm_free(this_service->last_problem_id); - nm_free(this_service->current_problem_id); nm_free(this_service); } @@ -519,6 +517,32 @@ int log_service_event(service *svc) { unsigned long log_options = 0L; + if ( svc->scheduled_downtime_depth > 0 ) { + svc->display_status = 1; + } + else if (svc->problem_has_been_acknowledged == TRUE) { + svc->display_status = 2; + } + /* Flapping*/ + else if (svc->is_flapping > 0) { + svc->display_status = 3; + } + /* Warning */ + else if (svc->current_state == STATE_WARNING) { + svc->display_status = 4; + } + /* Unknown */ + else if (svc->current_state == STATE_UNKNOWN) { + svc->display_status = 5; + } + /* CRITICAL */ + else if (svc->current_state == STATE_CRITICAL) { + svc->display_status = 6; + } + else if (svc->current_state == STATE_OK) { + svc->display_status = 0; + } + /* don't log soft errors if the user doesn't want to */ if (svc->state_type == SOFT_STATE && !log_service_retries) return OK; diff --git a/src/naemon/objects_service.h b/src/naemon/objects_service.h index 35031b85..7fe92aaa 100644 --- a/src/naemon/objects_service.h +++ b/src/naemon/objects_service.h @@ -83,10 +83,8 @@ struct service { int current_attempt; unsigned long current_event_id; unsigned long last_event_id; - char *current_problem_id; - char *last_problem_id; - time_t problem_start; - time_t problem_end; + unsigned long current_problem_id; + unsigned long last_problem_id; time_t last_notification; time_t next_notification; int no_more_notifications; @@ -101,7 +99,7 @@ struct service { int is_being_freshened; unsigned int notified_on; int current_notification_number; - char *current_notification_id; + unsigned long current_notification_id; double latency; double execution_time; int is_executing; @@ -118,6 +116,7 @@ struct service { struct host *host_ptr; struct command *event_handler_ptr; char *event_handler_args; + int display_status; struct command *check_command_ptr; struct timeperiod *check_period_ptr; struct timeperiod *notification_period_ptr; diff --git a/src/naemon/statusdata.c b/src/naemon/statusdata.c index 15268d32..e783121c 100644 --- a/src/naemon/statusdata.c +++ b/src/naemon/statusdata.c @@ -5,6 +5,7 @@ #include "broker.h" #include "globals.h" #include "events.h" +#include "sehandlers.h" /******************************************************************/ @@ -86,6 +87,40 @@ int update_program_status(int aggregated_dump) int update_host_status(host *hst, int aggregated_dump) { + int display_status = 0; + + display_status = hst->display_status; + + /* Downtime */ + if (hst->scheduled_downtime_depth > 0) { + display_status = 1; + } + /* ACK */ + else if (hst->problem_has_been_acknowledged == TRUE) { + display_status = 2; + } + /* Flapping*/ + else if (hst->is_flapping > 0) { + display_status = 3; + } + /* Unreachable */ + else if (hst->current_state == STATE_UNREACHABLE) { + display_status = 7; + } + /* Down */ + else if (hst->current_state == STATE_DOWN) { + display_status = 8; + } + else if (hst->current_state == STATE_OK) { + display_status = 0; + } + + if (display_status != hst->display_status) { + hst->display_status = display_status; + log_host_event(hst); + broker_statechange_data(NEBTYPE_STATECHANGE_END, NEBFLAG_NONE, NEBATTR_NONE, HOST_STATECHANGE, (void *)hst, hst->current_state, hst->state_type, hst->current_attempt, hst->max_attempts); + } + if (aggregated_dump == FALSE) broker_host_status(NEBTYPE_HOSTSTATUS_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, hst); @@ -96,6 +131,43 @@ int update_host_status(host *hst, int aggregated_dump) /* updates service status info */ int update_service_status(service *svc, int aggregated_dump) { + int display_status; + + display_status = svc->display_status; + + /* Downtime */ + if ( svc->scheduled_downtime_depth > 0) { + display_status = 1; + } + /* ACK */ + else if (svc->problem_has_been_acknowledged == TRUE) { + display_status = 2; + } + /* Flapping*/ + else if (svc->is_flapping > 0) { + display_status = 3; + } + /* Warning */ + else if (svc->current_state == STATE_WARNING) { + display_status = 4; + } + /* Unknown */ + else if (svc->current_state == STATE_UNKNOWN) { + display_status = 5; + } + /* CRITICAL */ + else if (svc->current_state == STATE_CRITICAL) { + display_status = 6; + } + else if (svc->current_state == STATE_OK) { + display_status = 0; + } + + if (display_status != svc->display_status) { + svc->display_status = display_status; + log_service_event(svc); + broker_statechange_data(NEBTYPE_STATECHANGE_END, NEBFLAG_NONE, NEBATTR_NONE, SERVICE_STATECHANGE, (void *)svc, svc->current_state, svc->state_type, svc->current_attempt, svc->max_attempts); + } if (aggregated_dump == FALSE) broker_service_status(NEBTYPE_SERVICESTATUS_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, svc); diff --git a/src/naemon/xrddefault.c b/src/naemon/xrddefault.c index 5d9823a5..2d6862b1 100644 --- a/src/naemon/xrddefault.c +++ b/src/naemon/xrddefault.c @@ -154,6 +154,8 @@ int xrddefault_save_state_information(void) fprintf(fp, "next_comment_id=%lu\n", next_comment_id); fprintf(fp, "next_downtime_id=%lu\n", next_downtime_id); fprintf(fp, "next_event_id=%lu\n", next_event_id); + fprintf(fp, "next_problem_id=%lu\n", next_problem_id); + fprintf(fp, "next_notification_id=%lu\n", next_notification_id); fprintf(fp, "}\n"); /* save host state information */ @@ -176,10 +178,8 @@ int xrddefault_save_state_information(void) fprintf(fp, "last_hard_state=%d\n", temp_host->last_hard_state); fprintf(fp, "last_event_id=%lu\n", temp_host->last_event_id); fprintf(fp, "current_event_id=%lu\n", temp_host->current_event_id); - fprintf(fp, "current_problem_id=%s\n", (temp_host->current_problem_id == NULL) ? "" : temp_host->current_problem_id); - fprintf(fp, "last_problem_id=%s\n", (temp_host->last_problem_id == NULL) ? "" : temp_host->last_problem_id); - fprintf(fp, "problem_start=%lu\n", temp_host->problem_start); - fprintf(fp, "problem_end=%lu\n", temp_host->problem_end); + fprintf(fp, "current_problem_id=%lu\n", temp_host->current_problem_id); + fprintf(fp, "last_problem_id=%lu\n", temp_host->last_problem_id); fprintf(fp, "plugin_output=%s\n", (temp_host->plugin_output == NULL) ? "" : temp_host->plugin_output); fprintf(fp, "long_plugin_output=%s\n", (temp_host->long_plugin_output == NULL) ? "" : temp_host->long_plugin_output); fprintf(fp, "performance_data=%s\n", (temp_host->perf_data == NULL) ? "" : temp_host->perf_data); @@ -200,7 +200,7 @@ int xrddefault_save_state_information(void) fprintf(fp, "notified_on_unreachable=%d\n", flag_isset(temp_host->notified_on, OPT_UNREACHABLE)); fprintf(fp, "last_notification=%lu\n", temp_host->last_notification); fprintf(fp, "current_notification_number=%d\n", temp_host->current_notification_number); - fprintf(fp, "current_notification_id=%s\n", (temp_host->current_notification_id == NULL) ? "" : temp_host->current_notification_id); + fprintf(fp, "current_notification_id=%lu\n", temp_host->current_notification_id); if (conf_host && conf_host->notifications_enabled != temp_host->notifications_enabled) { fprintf(fp, "config:notifications_enabled=%d\n", conf_host->notifications_enabled); fprintf(fp, "notifications_enabled=%d\n", temp_host->notifications_enabled); @@ -235,6 +235,7 @@ int xrddefault_save_state_information(void) fprintf(fp, "is_flapping=%d\n", temp_host->is_flapping); fprintf(fp, "percent_state_change=%.2f\n", temp_host->percent_state_change); fprintf(fp, "check_flapping_recovery_notification=%d\n", temp_host->check_flapping_recovery_notification); + fprintf(fp, "display_status=%d\n", temp_host->display_status); fprintf(fp, "last_update=%lu\n", temp_host->last_update); fprintf(fp, "state_history="); @@ -273,10 +274,8 @@ int xrddefault_save_state_information(void) fprintf(fp, "last_hard_state=%d\n", temp_service->last_hard_state); fprintf(fp, "last_event_id=%lu\n", temp_service->last_event_id); fprintf(fp, "current_event_id=%lu\n", temp_service->current_event_id); - fprintf(fp, "current_problem_id=%s\n", (temp_service->current_problem_id == NULL) ? "" : temp_service->current_problem_id); - fprintf(fp, "last_problem_id=%s\n", (temp_service->last_problem_id == NULL) ? "" : temp_service->last_problem_id); - fprintf(fp, "problem_start=%lu\n", temp_service->problem_start); - fprintf(fp, "problem_end=%lu\n", temp_service->problem_end); + fprintf(fp, "current_problem_id=%lu\n", temp_service->current_problem_id); + fprintf(fp, "last_problem_id=%lu\n", temp_service->last_problem_id); fprintf(fp, "current_attempt=%d\n", temp_service->current_attempt); fprintf(fp, "max_attempts=%d\n", temp_service->max_attempts); fprintf(fp, "normal_check_interval=%f\n", temp_service->check_interval); @@ -298,7 +297,7 @@ int xrddefault_save_state_information(void) fprintf(fp, "notified_on_warning=%d\n", flag_isset(temp_service->notified_on, OPT_WARNING)); fprintf(fp, "notified_on_critical=%d\n", flag_isset(temp_service->notified_on, OPT_CRITICAL)); fprintf(fp, "current_notification_number=%d\n", temp_service->current_notification_number); - fprintf(fp, "current_notification_id=%s\n", (temp_service->current_notification_id == NULL) ? "" : temp_service->current_notification_id); + fprintf(fp, "current_notification_id=%lu\n", temp_service->current_notification_id); fprintf(fp, "last_notification=%lu\n", temp_service->last_notification); if (conf_svc && conf_svc->notifications_enabled != temp_service->notifications_enabled) { fprintf(fp, "config:notifications_enabled=%d\n", conf_svc->notifications_enabled); @@ -335,6 +334,7 @@ int xrddefault_save_state_information(void) fprintf(fp, "is_flapping=%d\n", temp_service->is_flapping); fprintf(fp, "percent_state_change=%.2f\n", temp_service->percent_state_change); fprintf(fp, "check_flapping_recovery_notification=%d\n", temp_service->check_flapping_recovery_notification); + fprintf(fp, "display_status=%d\n", temp_service->display_status); fprintf(fp, "state_history="); for (x = 0; x < MAX_STATE_HISTORY_ENTRIES; x++) fprintf(fp, "%s%d", (x > 0) ? "," : "", temp_service->state_history[(x + temp_service->state_history_index) % MAX_STATE_HISTORY_ENTRIES]); @@ -470,7 +470,8 @@ int xrddefault_save_state_information(void) /******************************************************************/ #define RETAIN_BOOL(type, obj, v, attr) \ do { \ - if (obj->modified_attributes & attr && (!have.v || (have.v && conf.v == obj->v))) { \ + if ((obj->modified_attributes & attr && !have.v) || (have.v && conf.v == obj->v)) { \ + printf("Retaining boolean " #v " for " #type " (%s) (conf.v = %d; have.v = %d)\n", val, conf.v, have.v); \ pre_modify_##type##_attribute(obj, attr); \ obj->v = atoi(val) > 0 ? TRUE : FALSE; \ } \ @@ -999,6 +1000,10 @@ int xrddefault_read_state_information(void) next_downtime_id = strtoul(val, NULL, 10); else if (!strcmp(var, "next_event_id")) next_event_id = strtoul(val, NULL, 10); + else if (!strcmp(var, "next_problem_id")) + next_problem_id = strtoul(val, NULL, 10); + else if (!strcmp(var, "next_notification_id")) + next_notification_id = strtoul(val, NULL, 10); } break; @@ -1057,16 +1062,10 @@ int xrddefault_read_state_information(void) temp_host->current_event_id = strtoul(val, NULL, 10); else if (!strcmp(var, "last_event_id")) temp_host->last_event_id = strtoul(val, NULL, 10); - else if (!strcmp(var, "current_problem_id")) { - nm_free(temp_host->current_problem_id); - temp_host->current_problem_id = nm_strdup(val); - } else if (!strcmp(var, "last_problem_id")) { - nm_free(temp_host->last_problem_id); - temp_host->last_problem_id = nm_strdup(val); - } else if (!strcmp(var, "problem_start")) - temp_host->problem_start = strtoul(val, NULL, 10); - else if (!strcmp(var, "problem_end")) - temp_host->problem_end = strtoul(val, NULL, 10); + else if (!strcmp(var, "current_problem_id")) + temp_host->current_problem_id = strtoul(val, NULL, 10); + else if (!strcmp(var, "last_problem_id")) + temp_host->last_problem_id = strtoul(val, NULL, 10); else if (!strcmp(var, "state_type")) temp_host->state_type = atoi(val); else if (!strcmp(var, "last_state_change")) @@ -1089,15 +1088,16 @@ int xrddefault_read_state_information(void) temp_host->last_notification = strtoul(val, NULL, 10); else if (!strcmp(var, "current_notification_number")) temp_host->current_notification_number = atoi(val); - else if (!strcmp(var, "current_notification_id")) { - nm_free(temp_host->current_notification_id); - temp_host->current_notification_id = nm_strdup(val); - } else if (!strcmp(var, "is_flapping")) + else if (!strcmp(var, "current_notification_id")) + temp_host->current_notification_id = strtoul(val, NULL, 10); + else if (!strcmp(var, "is_flapping")) temp_host->is_flapping = atoi(val); else if (!strcmp(var, "percent_state_change")) temp_host->percent_state_change = strtod(val, NULL); else if (!strcmp(var, "check_flapping_recovery_notification")) temp_host->check_flapping_recovery_notification = atoi(val); + else if (!strcmp(var, "display_status")) + temp_host->display_status = atoi(val); else if (!strcmp(var, "state_history")) { temp_ptr = val; for (x = 0; x < MAX_STATE_HISTORY_ENTRIES; x++) { @@ -1310,16 +1310,10 @@ int xrddefault_read_state_information(void) temp_service->current_event_id = strtoul(val, NULL, 10); else if (!strcmp(var, "last_event_id")) temp_service->last_event_id = strtoul(val, NULL, 10); - else if (!strcmp(var, "current_problem_id")) { - nm_free(temp_service->current_problem_id); - temp_service->current_problem_id = nm_strdup(val); - } else if (!strcmp(var, "last_problem_id")) { - nm_free(temp_service->last_problem_id); - temp_service->last_problem_id = nm_strdup(val); - } else if (!strcmp(var, "problem_start")) - temp_service->problem_start = strtoul(val, NULL, 10); - else if (!strcmp(var, "problem_end")) - temp_service->problem_end = strtoul(val, NULL, 10); + else if (!strcmp(var, "current_problem_id")) + temp_service->current_problem_id = strtoul(val, NULL, 10); + else if (!strcmp(var, "last_problem_id")) + temp_service->last_problem_id = strtoul(val, NULL, 10); else if (!strcmp(var, "state_type")) temp_service->state_type = atoi(val); else if (!strcmp(var, "last_state_change")) @@ -1361,10 +1355,9 @@ int xrddefault_read_state_information(void) 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")) { - nm_free(temp_service->current_notification_id); - temp_service->current_notification_id = nm_strdup(val); - } else if (!strcmp(var, "last_notification")) + else if (!strcmp(var, "current_notification_id")) + temp_service->current_notification_id = strtoul(val, NULL, 10); + else if (!strcmp(var, "last_notification")) temp_service->last_notification = strtoul(val, NULL, 10); else if (!strcmp(var, "is_flapping")) temp_service->is_flapping = atoi(val); @@ -1372,6 +1365,8 @@ int xrddefault_read_state_information(void) temp_service->percent_state_change = strtod(val, NULL); else if (!strcmp(var, "check_flapping_recovery_notification")) temp_service->check_flapping_recovery_notification = atoi(val); + else if (!strcmp(var, "display_status")) + temp_service->display_status = atoi(val); else if (!strcmp(var, "state_history")) { temp_ptr = val; for (x = 0; x < MAX_STATE_HISTORY_ENTRIES; x++) {