/* removes invalid and old downtime entries from the downtime file */ int xdddefault_validate_downtime_data(void) { scheduled_downtime *temp_downtime; scheduled_downtime *next_downtime; int update_file = FALSE; int save = TRUE; /* remove stale downtimes */ for (temp_downtime = scheduled_downtime_list; temp_downtime != NULL; temp_downtime = next_downtime) { next_downtime = temp_downtime->next; save = TRUE; /* delete downtimes with invalid host names */ if (find_host(temp_downtime->host_name) == NULL) save = FALSE; /* delete downtimes with invalid service descriptions */ if (temp_downtime->type == SERVICE_DOWNTIME && find_service(temp_downtime->host_name, temp_downtime->service_description) == NULL) save = FALSE; /* delete downtimes that have expired */ if (temp_downtime->end_time < time(NULL)) save = FALSE; /* delete the downtime */ if (save == FALSE) { update_file = TRUE; delete_downtime(temp_downtime->type, temp_downtime->downtime_id); } } /* remove triggered downtimes without valid parents */ for (temp_downtime = scheduled_downtime_list; temp_downtime != NULL; temp_downtime = next_downtime) { next_downtime = temp_downtime->next; save = TRUE; if (temp_downtime->triggered_by == 0) continue; if (find_host_downtime(temp_downtime->triggered_by) == NULL && find_service_downtime(temp_downtime->triggered_by) == NULL) save = FALSE; /* delete the downtime */ if (save == FALSE) { update_file = TRUE; delete_downtime(temp_downtime->type, temp_downtime->downtime_id); } } /* update downtime file */ if (update_file == TRUE) xdddefault_save_downtime_data(); return OK; }
/* deletes a scheduled service downtime entry */ int delete_service_downtime(unsigned long downtime_id) { /* * do not update status immediately * let aggregated dumps take care of it */ /* delete the downtime from memory */ return delete_downtime(SERVICE_DOWNTIME, downtime_id); }
/* deletes a scheduled service downtime entry */ int delete_service_downtime(unsigned long downtime_id) { int result = OK; /* delete the downtime from memory */ delete_downtime(SERVICE_DOWNTIME, downtime_id); /**** IMPLEMENTATION-SPECIFIC CALLS ****/ #ifdef USE_XDDDEFAULT result = xdddefault_delete_service_downtime(downtime_id); #endif return result; }
int delete_service_downtime(unsigned long downtime_id) { return delete_downtime(SERVICE_DOWNTIME, downtime_id); }
int delete_host_downtime(unsigned long downtime_id) { return delete_downtime(HOST_DOWNTIME, downtime_id); }
/* removes invalid and old downtime entries from the downtime file */ int xdddefault_validate_downtime_data(void) { scheduled_downtime *temp_downtime; scheduled_downtime *next_downtime; int save = TRUE; /* remove stale downtimes */ for(temp_downtime = scheduled_downtime_list; temp_downtime != NULL; temp_downtime = next_downtime) { next_downtime = temp_downtime->next; save = TRUE; /* delete downtimes with invalid host names */ if(find_host(temp_downtime->host_name) == NULL) { log_debug_info(DEBUGL_DOWNTIME, 1, "Deleting downtime with invalid host name: %s\n", temp_downtime->host_name); save = FALSE; } /* delete downtimes with invalid service descriptions */ if(temp_downtime->type == SERVICE_DOWNTIME && find_service(temp_downtime->host_name, temp_downtime->service_description) == NULL) { log_debug_info(DEBUGL_DOWNTIME, 1, "Deleting downtime with invalid service description: %s\n", temp_downtime->service_description); save = FALSE; } /* delete fixed downtimes that have expired */ if((TRUE == temp_downtime->fixed) && (temp_downtime->end_time < time(NULL))) { log_debug_info(DEBUGL_DOWNTIME, 1, "Deleting fixed downtime that expired at: %lu\n", temp_downtime->end_time); save = FALSE; } /* delete flexible downtimes that never started and have expired */ if((FALSE == temp_downtime->fixed) && (0 == temp_downtime->flex_downtime_start) && (temp_downtime->end_time < time(NULL))) { log_debug_info(DEBUGL_DOWNTIME, 1, "Deleting flexible downtime that expired at: %lu\n", temp_downtime->end_time); save = FALSE; } /* delete flexible downtimes that started but whose duration has completed */ if((FALSE == temp_downtime->fixed) && (0 != temp_downtime->flex_downtime_start) && ((temp_downtime->flex_downtime_start + temp_downtime->duration) < time(NULL))) { log_debug_info(DEBUGL_DOWNTIME, 1, "Deleting flexible downtime whose duration ended at: %lu\n", temp_downtime->flex_downtime_start + temp_downtime->duration); save = FALSE; } /* delete the downtime */ if(save == FALSE) { delete_downtime(temp_downtime->type, temp_downtime->downtime_id); } } /* remove triggered downtimes without valid parents */ for(temp_downtime = scheduled_downtime_list; temp_downtime != NULL; temp_downtime = next_downtime) { next_downtime = temp_downtime->next; save = TRUE; if(temp_downtime->triggered_by == 0) continue; if(find_host_downtime(temp_downtime->triggered_by) == NULL && find_service_downtime(temp_downtime->triggered_by) == NULL) save = FALSE; /* delete the downtime */ if(save == FALSE) { delete_downtime(temp_downtime->type, temp_downtime->downtime_id); } } return OK; }