static void read_bootinfo(const void *fdt) { int ret; if ((ret = dt_set(fdt)) != 0) { printf("setup: fdt sanity checks failed! " "fdt_error: %s\n", dt_strerror(ret)); exit(ENOEXEC); } if ((ret = dt_get_bootargs_ptr(&bootargs)) < 0) { printf("fdt failure: %s\n", dt_strerror(ret)); exit(ENOEXEC); } if ((ret = dt_get_memory_params(&mem_start, &mem_size)) < 0) { printf("setup: can't find memory params! " "fdt_error: %s\n", dt_strerror(ret)); exit(ENOEXEC); } }
/* adds a host or service downtime entry to the list in memory */ int add_downtime(int downtime_type, char *host_name, char *svc_description, time_t entry_time, char *author, char *comment_data, time_t start_time, time_t flex_downtime_start, time_t end_time, int fixed, unsigned long triggered_by, unsigned long duration, unsigned long downtime_id, int is_in_effect, int start_notification_sent){ scheduled_downtime *new_downtime = NULL; int result = OK; log_debug_info(DEBUGL_FUNCTIONS, 0, "add_downtime()\n"); /* we don't have enough info */ if(host_name == NULL || (downtime_type == SERVICE_DOWNTIME && svc_description == NULL)) { log_debug_info(DEBUGL_DOWNTIME, 1, "Host name (%s) or service description (%s) is null\n", ((NULL == host_name) ? "null" : host_name), ((NULL == svc_description) ? "null" : svc_description)); return ERROR; } /* allocate memory for the downtime */ if((new_downtime = (scheduled_downtime *)calloc(1, sizeof(scheduled_downtime))) == NULL) { log_debug_info(DEBUGL_DOWNTIME, 1, "Unable to allocate memory for new downtime\n"); return ERROR; } /* duplicate vars */ if((new_downtime->host_name = (char *)strdup(host_name)) == NULL) { log_debug_info(DEBUGL_DOWNTIME, 1, "Unable to allocate memory for new downtime's host name\n"); result = ERROR; } if(downtime_type == SERVICE_DOWNTIME) { if((new_downtime->service_description = (char *)strdup(svc_description)) == NULL) { log_debug_info(DEBUGL_DOWNTIME, 1, "Unable to allocate memory for new downtime's service description\n"); result = ERROR; } } if(author) { if((new_downtime->author = (char *)strdup(author)) == NULL) { log_debug_info(DEBUGL_DOWNTIME, 1, "Unable to allocate memory for new downtime's author\n"); result = ERROR; } } if(comment_data) { if((new_downtime->comment = (char *)strdup(comment_data)) == NULL) { log_debug_info(DEBUGL_DOWNTIME, 1, "Unable to allocate memory for new downtime's comment\n"); result = ERROR; } } new_downtime->type = downtime_type; new_downtime->entry_time = entry_time; new_downtime->start_time = start_time; new_downtime->flex_downtime_start = flex_downtime_start; new_downtime->end_time = end_time; new_downtime->fixed = (fixed > 0) ? TRUE : FALSE; new_downtime->triggered_by = triggered_by; new_downtime->duration = duration; new_downtime->downtime_id = downtime_id; new_downtime->is_in_effect=is_in_effect; new_downtime->start_notification_sent=start_notification_sent; #ifdef NSCORE new_downtime->start_event = ( timed_event *)0; new_downtime->stop_event = ( timed_event *)0; #endif result = downtime_add(new_downtime); if (result) { if (new_downtime->type == SERVICE_DOWNTIME) { log_debug_info(DEBUGL_DOWNTIME, 0, "Failed to add downtime for service '%s' on host '%s': %s\n", new_downtime->service_description, new_downtime->host_name, dt_strerror(result)); } else { log_debug_info(DEBUGL_DOWNTIME, 0, "Failed to add downtime for host '%s': %s\n", new_downtime->host_name, dt_strerror(result)); } result = ERROR; } /* handle errors */ if(result == ERROR) { my_free(new_downtime->comment); my_free(new_downtime->author); my_free(new_downtime->service_description); my_free(new_downtime->host_name); my_free(new_downtime); return ERROR; } #ifdef NSCORE #ifdef USE_EVENT_BROKER /* send data to event broker */ broker_downtime_data(NEBTYPE_DOWNTIME_LOAD, NEBFLAG_NONE, NEBATTR_NONE, downtime_type, host_name, svc_description, entry_time, author, comment_data, start_time, end_time, fixed, triggered_by, duration, downtime_id, NULL); #endif #endif return OK; }