325
326
/******************************************************************/
327
328
/* write all status data to file */
328
int xsddefault_save_status_data(void){
329
char *temp_file=NULL;
330
customvariablesmember *temp_customvariablesmember=NULL;
331
host *temp_host=NULL;
332
service *temp_service=NULL;
333
contact *temp_contact=NULL;
334
comment *temp_comment=NULL;
335
scheduled_downtime *temp_downtime=NULL;
329
int xsddefault_save_status_data(void) {
330
char *temp_file = NULL;
331
customvariablesmember *temp_customvariablesmember = NULL;
332
host *temp_host = NULL;
333
service *temp_service = NULL;
334
contact *temp_contact = NULL;
335
comment *temp_comment = NULL;
336
scheduled_downtime *temp_downtime = NULL;
336
337
time_t current_time;
339
int used_external_command_buffer_slots=0;
340
int high_external_command_buffer_slots=0;
340
int used_external_command_buffer_slots = 0;
341
int high_external_command_buffer_slots = 0;
343
log_debug_info(DEBUGL_FUNCTIONS,0,"save_status_data()\n");
344
log_debug_info(DEBUGL_FUNCTIONS, 0, "save_status_data()\n");
345
346
/* open a safe temp file for output */
346
if(xsddefault_temp_file==NULL)
348
asprintf(&temp_file,"%sXXXXXX",xsddefault_temp_file);
352
log_debug_info(DEBUGL_STATUSDATA,2,"Writing status data to temp file '%s'\n",temp_file);
354
if((fd=mkstemp(temp_file))==-1){
347
if(xsddefault_temp_file == NULL)
349
asprintf(&temp_file, "%sXXXXXX", xsddefault_temp_file);
350
if(temp_file == NULL)
353
log_debug_info(DEBUGL_STATUSDATA, 2, "Writing status data to temp file '%s'\n", temp_file);
355
if((fd = mkstemp(temp_file)) == -1) {
356
357
/* log an error */
358
logit(NSLOG_RUNTIME_ERROR,TRUE,"Error: Unable to create temp file for writing status data!\n");
358
logit(NSLOG_RUNTIME_ERROR, TRUE, "Error: Unable to create temp file for writing status data: %s\n", strerror(errno));
361
360
/* free memory */
362
361
my_free(temp_file);
366
fp=(FILE *)fdopen(fd,"w");
365
fp = (FILE *)fdopen(fd, "w");
370
369
unlink(temp_file);
372
371
/* log an error */
374
logit(NSLOG_RUNTIME_ERROR,TRUE,"Error: Unable to open temp file '%s' for writing status data!\n",temp_file);
372
logit(NSLOG_RUNTIME_ERROR, TRUE, "Error: Unable to open temp file '%s' for writing status data: %s\n", temp_file, strerror(errno));
377
374
/* free memory */
378
375
my_free(temp_file);
383
380
/* get number of items in the command buffer */
384
if(check_external_commands==TRUE){
381
if(check_external_commands == TRUE) {
385
382
pthread_mutex_lock(&external_command_buffer.buffer_lock);
386
used_external_command_buffer_slots=external_command_buffer.items;
387
high_external_command_buffer_slots=external_command_buffer.high;
383
used_external_command_buffer_slots = external_command_buffer.items;
384
high_external_command_buffer_slots = external_command_buffer.high;
388
385
pthread_mutex_unlock(&external_command_buffer.buffer_lock);
391
used_external_command_buffer_slots=0;
392
high_external_command_buffer_slots=0;
388
used_external_command_buffer_slots = 0;
389
high_external_command_buffer_slots = 0;
395
392
/* generate check statistics */
396
393
generate_check_stats();
398
395
/* write version info to status file */
399
fprintf(fp,"########################################\n");
400
fprintf(fp,"# NAGIOS STATUS FILE\n");
402
fprintf(fp,"# THIS FILE IS AUTOMATICALLY GENERATED\n");
403
fprintf(fp,"# BY NAGIOS. DO NOT MODIFY THIS FILE!\n");
404
fprintf(fp,"########################################\n\n");
396
fprintf(fp, "########################################\n");
397
fprintf(fp, "# NAGIOS STATUS FILE\n");
399
fprintf(fp, "# THIS FILE IS AUTOMATICALLY GENERATED\n");
400
fprintf(fp, "# BY NAGIOS. DO NOT MODIFY THIS FILE!\n");
401
fprintf(fp, "########################################\n\n");
406
403
time(¤t_time);
408
405
/* write file info */
409
fprintf(fp,"info {\n");
410
fprintf(fp,"\tcreated=%lu\n",current_time);
411
fprintf(fp,"\tversion=%s\n",PROGRAM_VERSION);
412
fprintf(fp,"\tlast_update_check=%lu\n",last_update_check);
413
fprintf(fp,"\tupdate_available=%d\n",update_available);
414
fprintf(fp,"\tlast_version=%s\n",(last_program_version==NULL)?"":last_program_version);
415
fprintf(fp,"\tnew_version=%s\n",(new_program_version==NULL)?"":new_program_version);
416
fprintf(fp,"\t}\n\n");
406
fprintf(fp, "info {\n");
407
fprintf(fp, "\tcreated=%lu\n", current_time);
408
fprintf(fp, "\tversion=%s\n", PROGRAM_VERSION);
409
fprintf(fp, "\tlast_update_check=%lu\n", last_update_check);
410
fprintf(fp, "\tupdate_available=%d\n", update_available);
411
fprintf(fp, "\tlast_version=%s\n", (last_program_version == NULL) ? "" : last_program_version);
412
fprintf(fp, "\tnew_version=%s\n", (new_program_version == NULL) ? "" : new_program_version);
413
fprintf(fp, "\t}\n\n");
418
415
/* save program status data */
419
fprintf(fp,"programstatus {\n");
420
fprintf(fp,"\tmodified_host_attributes=%lu\n",modified_host_process_attributes);
421
fprintf(fp,"\tmodified_service_attributes=%lu\n",modified_service_process_attributes);
422
fprintf(fp,"\tnagios_pid=%d\n",nagios_pid);
423
fprintf(fp,"\tdaemon_mode=%d\n",daemon_mode);
424
fprintf(fp,"\tprogram_start=%lu\n",program_start);
425
fprintf(fp,"\tlast_command_check=%lu\n",last_command_check);
426
fprintf(fp,"\tlast_log_rotation=%lu\n",last_log_rotation);
427
fprintf(fp,"\tenable_notifications=%d\n",enable_notifications);
428
fprintf(fp,"\tactive_service_checks_enabled=%d\n",execute_service_checks);
429
fprintf(fp,"\tpassive_service_checks_enabled=%d\n",accept_passive_service_checks);
430
fprintf(fp,"\tactive_host_checks_enabled=%d\n",execute_host_checks);
431
fprintf(fp,"\tpassive_host_checks_enabled=%d\n",accept_passive_host_checks);
432
fprintf(fp,"\tenable_event_handlers=%d\n",enable_event_handlers);
433
fprintf(fp,"\tobsess_over_services=%d\n",obsess_over_services);
434
fprintf(fp,"\tobsess_over_hosts=%d\n",obsess_over_hosts);
435
fprintf(fp,"\tcheck_service_freshness=%d\n",check_service_freshness);
436
fprintf(fp,"\tcheck_host_freshness=%d\n",check_host_freshness);
437
fprintf(fp,"\tenable_flap_detection=%d\n",enable_flap_detection);
438
fprintf(fp,"\tenable_failure_prediction=%d\n",enable_failure_prediction);
439
fprintf(fp,"\tprocess_performance_data=%d\n",process_performance_data);
440
fprintf(fp,"\tglobal_host_event_handler=%s\n",(global_host_event_handler==NULL)?"":global_host_event_handler);
441
fprintf(fp,"\tglobal_service_event_handler=%s\n",(global_service_event_handler==NULL)?"":global_service_event_handler);
442
fprintf(fp,"\tnext_comment_id=%lu\n",next_comment_id);
443
fprintf(fp,"\tnext_downtime_id=%lu\n",next_downtime_id);
444
fprintf(fp,"\tnext_event_id=%lu\n",next_event_id);
445
fprintf(fp,"\tnext_problem_id=%lu\n",next_problem_id);
446
fprintf(fp,"\tnext_notification_id=%lu\n",next_notification_id);
447
fprintf(fp,"\ttotal_external_command_buffer_slots=%d\n",external_command_buffer_slots);
448
fprintf(fp,"\tused_external_command_buffer_slots=%d\n",used_external_command_buffer_slots);
449
fprintf(fp,"\thigh_external_command_buffer_slots=%d\n",high_external_command_buffer_slots);
450
fprintf(fp,"\tactive_scheduled_host_check_stats=%d,%d,%d\n",check_statistics[ACTIVE_SCHEDULED_HOST_CHECK_STATS].minute_stats[0],check_statistics[ACTIVE_SCHEDULED_HOST_CHECK_STATS].minute_stats[1],check_statistics[ACTIVE_SCHEDULED_HOST_CHECK_STATS].minute_stats[2]);
451
fprintf(fp,"\tactive_ondemand_host_check_stats=%d,%d,%d\n",check_statistics[ACTIVE_ONDEMAND_HOST_CHECK_STATS].minute_stats[0],check_statistics[ACTIVE_ONDEMAND_HOST_CHECK_STATS].minute_stats[1],check_statistics[ACTIVE_ONDEMAND_HOST_CHECK_STATS].minute_stats[2]);
452
fprintf(fp,"\tpassive_host_check_stats=%d,%d,%d\n",check_statistics[PASSIVE_HOST_CHECK_STATS].minute_stats[0],check_statistics[PASSIVE_HOST_CHECK_STATS].minute_stats[1],check_statistics[PASSIVE_HOST_CHECK_STATS].minute_stats[2]);
453
fprintf(fp,"\tactive_scheduled_service_check_stats=%d,%d,%d\n",check_statistics[ACTIVE_SCHEDULED_SERVICE_CHECK_STATS].minute_stats[0],check_statistics[ACTIVE_SCHEDULED_SERVICE_CHECK_STATS].minute_stats[1],check_statistics[ACTIVE_SCHEDULED_SERVICE_CHECK_STATS].minute_stats[2]);
454
fprintf(fp,"\tactive_ondemand_service_check_stats=%d,%d,%d\n",check_statistics[ACTIVE_ONDEMAND_SERVICE_CHECK_STATS].minute_stats[0],check_statistics[ACTIVE_ONDEMAND_SERVICE_CHECK_STATS].minute_stats[1],check_statistics[ACTIVE_ONDEMAND_SERVICE_CHECK_STATS].minute_stats[2]);
455
fprintf(fp,"\tpassive_service_check_stats=%d,%d,%d\n",check_statistics[PASSIVE_SERVICE_CHECK_STATS].minute_stats[0],check_statistics[PASSIVE_SERVICE_CHECK_STATS].minute_stats[1],check_statistics[PASSIVE_SERVICE_CHECK_STATS].minute_stats[2]);
456
fprintf(fp,"\tcached_host_check_stats=%d,%d,%d\n",check_statistics[ACTIVE_CACHED_HOST_CHECK_STATS].minute_stats[0],check_statistics[ACTIVE_CACHED_HOST_CHECK_STATS].minute_stats[1],check_statistics[ACTIVE_CACHED_HOST_CHECK_STATS].minute_stats[2]);
457
fprintf(fp,"\tcached_service_check_stats=%d,%d,%d\n",check_statistics[ACTIVE_CACHED_SERVICE_CHECK_STATS].minute_stats[0],check_statistics[ACTIVE_CACHED_SERVICE_CHECK_STATS].minute_stats[1],check_statistics[ACTIVE_CACHED_SERVICE_CHECK_STATS].minute_stats[2]);
458
fprintf(fp,"\texternal_command_stats=%d,%d,%d\n",check_statistics[EXTERNAL_COMMAND_STATS].minute_stats[0],check_statistics[EXTERNAL_COMMAND_STATS].minute_stats[1],check_statistics[EXTERNAL_COMMAND_STATS].minute_stats[2]);
416
fprintf(fp, "programstatus {\n");
417
fprintf(fp, "\tmodified_host_attributes=%lu\n", modified_host_process_attributes);
418
fprintf(fp, "\tmodified_service_attributes=%lu\n", modified_service_process_attributes);
419
fprintf(fp, "\tnagios_pid=%d\n", nagios_pid);
420
fprintf(fp, "\tdaemon_mode=%d\n", daemon_mode);
421
fprintf(fp, "\tprogram_start=%lu\n", program_start);
422
fprintf(fp, "\tlast_command_check=%lu\n", last_command_check);
423
fprintf(fp, "\tlast_log_rotation=%lu\n", last_log_rotation);
424
fprintf(fp, "\tenable_notifications=%d\n", enable_notifications);
425
fprintf(fp, "\tactive_service_checks_enabled=%d\n", execute_service_checks);
426
fprintf(fp, "\tpassive_service_checks_enabled=%d\n", accept_passive_service_checks);
427
fprintf(fp, "\tactive_host_checks_enabled=%d\n", execute_host_checks);
428
fprintf(fp, "\tpassive_host_checks_enabled=%d\n", accept_passive_host_checks);
429
fprintf(fp, "\tenable_event_handlers=%d\n", enable_event_handlers);
430
fprintf(fp, "\tobsess_over_services=%d\n", obsess_over_services);
431
fprintf(fp, "\tobsess_over_hosts=%d\n", obsess_over_hosts);
432
fprintf(fp, "\tcheck_service_freshness=%d\n", check_service_freshness);
433
fprintf(fp, "\tcheck_host_freshness=%d\n", check_host_freshness);
434
fprintf(fp, "\tenable_flap_detection=%d\n", enable_flap_detection);
435
fprintf(fp, "\tenable_failure_prediction=%d\n", enable_failure_prediction);
436
fprintf(fp, "\tprocess_performance_data=%d\n", process_performance_data);
437
fprintf(fp, "\tglobal_host_event_handler=%s\n", (global_host_event_handler == NULL) ? "" : global_host_event_handler);
438
fprintf(fp, "\tglobal_service_event_handler=%s\n", (global_service_event_handler == NULL) ? "" : global_service_event_handler);
439
fprintf(fp, "\tnext_comment_id=%lu\n", next_comment_id);
440
fprintf(fp, "\tnext_downtime_id=%lu\n", next_downtime_id);
441
fprintf(fp, "\tnext_event_id=%lu\n", next_event_id);
442
fprintf(fp, "\tnext_problem_id=%lu\n", next_problem_id);
443
fprintf(fp, "\tnext_notification_id=%lu\n", next_notification_id);
444
fprintf(fp, "\ttotal_external_command_buffer_slots=%d\n", external_command_buffer_slots);
445
fprintf(fp, "\tused_external_command_buffer_slots=%d\n", used_external_command_buffer_slots);
446
fprintf(fp, "\thigh_external_command_buffer_slots=%d\n", high_external_command_buffer_slots);
447
fprintf(fp, "\tactive_scheduled_host_check_stats=%d,%d,%d\n", check_statistics[ACTIVE_SCHEDULED_HOST_CHECK_STATS].minute_stats[0], check_statistics[ACTIVE_SCHEDULED_HOST_CHECK_STATS].minute_stats[1], check_statistics[ACTIVE_SCHEDULED_HOST_CHECK_STATS].minute_stats[2]);
448
fprintf(fp, "\tactive_ondemand_host_check_stats=%d,%d,%d\n", check_statistics[ACTIVE_ONDEMAND_HOST_CHECK_STATS].minute_stats[0], check_statistics[ACTIVE_ONDEMAND_HOST_CHECK_STATS].minute_stats[1], check_statistics[ACTIVE_ONDEMAND_HOST_CHECK_STATS].minute_stats[2]);
449
fprintf(fp, "\tpassive_host_check_stats=%d,%d,%d\n", check_statistics[PASSIVE_HOST_CHECK_STATS].minute_stats[0], check_statistics[PASSIVE_HOST_CHECK_STATS].minute_stats[1], check_statistics[PASSIVE_HOST_CHECK_STATS].minute_stats[2]);
450
fprintf(fp, "\tactive_scheduled_service_check_stats=%d,%d,%d\n", check_statistics[ACTIVE_SCHEDULED_SERVICE_CHECK_STATS].minute_stats[0], check_statistics[ACTIVE_SCHEDULED_SERVICE_CHECK_STATS].minute_stats[1], check_statistics[ACTIVE_SCHEDULED_SERVICE_CHECK_STATS].minute_stats[2]);
451
fprintf(fp, "\tactive_ondemand_service_check_stats=%d,%d,%d\n", check_statistics[ACTIVE_ONDEMAND_SERVICE_CHECK_STATS].minute_stats[0], check_statistics[ACTIVE_ONDEMAND_SERVICE_CHECK_STATS].minute_stats[1], check_statistics[ACTIVE_ONDEMAND_SERVICE_CHECK_STATS].minute_stats[2]);
452
fprintf(fp, "\tpassive_service_check_stats=%d,%d,%d\n", check_statistics[PASSIVE_SERVICE_CHECK_STATS].minute_stats[0], check_statistics[PASSIVE_SERVICE_CHECK_STATS].minute_stats[1], check_statistics[PASSIVE_SERVICE_CHECK_STATS].minute_stats[2]);
453
fprintf(fp, "\tcached_host_check_stats=%d,%d,%d\n", check_statistics[ACTIVE_CACHED_HOST_CHECK_STATS].minute_stats[0], check_statistics[ACTIVE_CACHED_HOST_CHECK_STATS].minute_stats[1], check_statistics[ACTIVE_CACHED_HOST_CHECK_STATS].minute_stats[2]);
454
fprintf(fp, "\tcached_service_check_stats=%d,%d,%d\n", check_statistics[ACTIVE_CACHED_SERVICE_CHECK_STATS].minute_stats[0], check_statistics[ACTIVE_CACHED_SERVICE_CHECK_STATS].minute_stats[1], check_statistics[ACTIVE_CACHED_SERVICE_CHECK_STATS].minute_stats[2]);
455
fprintf(fp, "\texternal_command_stats=%d,%d,%d\n", check_statistics[EXTERNAL_COMMAND_STATS].minute_stats[0], check_statistics[EXTERNAL_COMMAND_STATS].minute_stats[1], check_statistics[EXTERNAL_COMMAND_STATS].minute_stats[2]);
460
fprintf(fp,"\tparallel_host_check_stats=%d,%d,%d\n",check_statistics[PARALLEL_HOST_CHECK_STATS].minute_stats[0],check_statistics[PARALLEL_HOST_CHECK_STATS].minute_stats[1],check_statistics[PARALLEL_HOST_CHECK_STATS].minute_stats[2]);
461
fprintf(fp,"\tserial_host_check_stats=%d,%d,%d\n",check_statistics[SERIAL_HOST_CHECK_STATS].minute_stats[0],check_statistics[SERIAL_HOST_CHECK_STATS].minute_stats[1],check_statistics[SERIAL_HOST_CHECK_STATS].minute_stats[2]);
462
fprintf(fp,"\t}\n\n");
457
fprintf(fp, "\tparallel_host_check_stats=%d,%d,%d\n", check_statistics[PARALLEL_HOST_CHECK_STATS].minute_stats[0], check_statistics[PARALLEL_HOST_CHECK_STATS].minute_stats[1], check_statistics[PARALLEL_HOST_CHECK_STATS].minute_stats[2]);
458
fprintf(fp, "\tserial_host_check_stats=%d,%d,%d\n", check_statistics[SERIAL_HOST_CHECK_STATS].minute_stats[0], check_statistics[SERIAL_HOST_CHECK_STATS].minute_stats[1], check_statistics[SERIAL_HOST_CHECK_STATS].minute_stats[2]);
459
fprintf(fp, "\t}\n\n");
465
462
/* save host status data */
466
for(temp_host=host_list;temp_host!=NULL;temp_host=temp_host->next){
468
fprintf(fp,"hoststatus {\n");
469
fprintf(fp,"\thost_name=%s\n",temp_host->name);
471
fprintf(fp,"\tmodified_attributes=%lu\n",temp_host->modified_attributes);
472
fprintf(fp,"\tcheck_command=%s\n",(temp_host->host_check_command==NULL)?"":temp_host->host_check_command);
473
fprintf(fp,"\tcheck_period=%s\n",(temp_host->check_period==NULL)?"":temp_host->check_period);
474
fprintf(fp,"\tnotification_period=%s\n",(temp_host->notification_period==NULL)?"":temp_host->notification_period);
475
fprintf(fp,"\tcheck_interval=%f\n",temp_host->check_interval);
476
fprintf(fp,"\tretry_interval=%f\n",temp_host->retry_interval);
477
fprintf(fp,"\tevent_handler=%s\n",(temp_host->event_handler==NULL)?"":temp_host->event_handler);
479
fprintf(fp,"\thas_been_checked=%d\n",temp_host->has_been_checked);
480
fprintf(fp,"\tshould_be_scheduled=%d\n",temp_host->should_be_scheduled);
481
fprintf(fp,"\tcheck_execution_time=%.3f\n",temp_host->execution_time);
482
fprintf(fp,"\tcheck_latency=%.3f\n",temp_host->latency);
483
fprintf(fp,"\tcheck_type=%d\n",temp_host->check_type);
484
fprintf(fp,"\tcurrent_state=%d\n",temp_host->current_state);
485
fprintf(fp,"\tlast_hard_state=%d\n",temp_host->last_hard_state);
486
fprintf(fp,"\tlast_event_id=%lu\n",temp_host->last_event_id);
487
fprintf(fp,"\tcurrent_event_id=%lu\n",temp_host->current_event_id);
488
fprintf(fp,"\tcurrent_problem_id=%lu\n",temp_host->current_problem_id);
489
fprintf(fp,"\tlast_problem_id=%lu\n",temp_host->last_problem_id);
490
fprintf(fp,"\tplugin_output=%s\n",(temp_host->plugin_output==NULL)?"":temp_host->plugin_output);
491
fprintf(fp,"\tlong_plugin_output=%s\n",(temp_host->long_plugin_output==NULL)?"":temp_host->long_plugin_output);
492
fprintf(fp,"\tperformance_data=%s\n",(temp_host->perf_data==NULL)?"":temp_host->perf_data);
493
fprintf(fp,"\tlast_check=%lu\n",temp_host->last_check);
494
fprintf(fp,"\tnext_check=%lu\n",temp_host->next_check);
495
fprintf(fp,"\tcheck_options=%d\n",temp_host->check_options);
496
fprintf(fp,"\tcurrent_attempt=%d\n",temp_host->current_attempt);
497
fprintf(fp,"\tmax_attempts=%d\n",temp_host->max_attempts);
498
fprintf(fp,"\tstate_type=%d\n",temp_host->state_type);
499
fprintf(fp,"\tlast_state_change=%lu\n",temp_host->last_state_change);
500
fprintf(fp,"\tlast_hard_state_change=%lu\n",temp_host->last_hard_state_change);
501
fprintf(fp,"\tlast_time_up=%lu\n",temp_host->last_time_up);
502
fprintf(fp,"\tlast_time_down=%lu\n",temp_host->last_time_down);
503
fprintf(fp,"\tlast_time_unreachable=%lu\n",temp_host->last_time_unreachable);
504
fprintf(fp,"\tlast_notification=%lu\n",temp_host->last_host_notification);
505
fprintf(fp,"\tnext_notification=%lu\n",temp_host->next_host_notification);
506
fprintf(fp,"\tno_more_notifications=%d\n",temp_host->no_more_notifications);
507
fprintf(fp,"\tcurrent_notification_number=%d\n",temp_host->current_notification_number);
508
fprintf(fp,"\tcurrent_notification_id=%lu\n",temp_host->current_notification_id);
509
fprintf(fp,"\tnotifications_enabled=%d\n",temp_host->notifications_enabled);
510
fprintf(fp,"\tproblem_has_been_acknowledged=%d\n",temp_host->problem_has_been_acknowledged);
511
fprintf(fp,"\tacknowledgement_type=%d\n",temp_host->acknowledgement_type);
512
fprintf(fp,"\tactive_checks_enabled=%d\n",temp_host->checks_enabled);
513
fprintf(fp,"\tpassive_checks_enabled=%d\n",temp_host->accept_passive_host_checks);
514
fprintf(fp,"\tevent_handler_enabled=%d\n",temp_host->event_handler_enabled);
515
fprintf(fp,"\tflap_detection_enabled=%d\n",temp_host->flap_detection_enabled);
516
fprintf(fp,"\tfailure_prediction_enabled=%d\n",temp_host->failure_prediction_enabled);
517
fprintf(fp,"\tprocess_performance_data=%d\n",temp_host->process_performance_data);
518
fprintf(fp,"\tobsess_over_host=%d\n",temp_host->obsess_over_host);
519
fprintf(fp,"\tlast_update=%lu\n",current_time);
520
fprintf(fp,"\tis_flapping=%d\n",temp_host->is_flapping);
521
fprintf(fp,"\tpercent_state_change=%.2f\n",temp_host->percent_state_change);
522
fprintf(fp,"\tscheduled_downtime_depth=%d\n",temp_host->scheduled_downtime_depth);
463
for(temp_host = host_list; temp_host != NULL; temp_host = temp_host->next) {
465
fprintf(fp, "hoststatus {\n");
466
fprintf(fp, "\thost_name=%s\n", temp_host->name);
468
fprintf(fp, "\tmodified_attributes=%lu\n", temp_host->modified_attributes);
469
fprintf(fp, "\tcheck_command=%s\n", (temp_host->host_check_command == NULL) ? "" : temp_host->host_check_command);
470
fprintf(fp, "\tcheck_period=%s\n", (temp_host->check_period == NULL) ? "" : temp_host->check_period);
471
fprintf(fp, "\tnotification_period=%s\n", (temp_host->notification_period == NULL) ? "" : temp_host->notification_period);
472
fprintf(fp, "\tcheck_interval=%f\n", temp_host->check_interval);
473
fprintf(fp, "\tretry_interval=%f\n", temp_host->retry_interval);
474
fprintf(fp, "\tevent_handler=%s\n", (temp_host->event_handler == NULL) ? "" : temp_host->event_handler);
476
fprintf(fp, "\thas_been_checked=%d\n", temp_host->has_been_checked);
477
fprintf(fp, "\tshould_be_scheduled=%d\n", temp_host->should_be_scheduled);
478
fprintf(fp, "\tcheck_execution_time=%.3f\n", temp_host->execution_time);
479
fprintf(fp, "\tcheck_latency=%.3f\n", temp_host->latency);
480
fprintf(fp, "\tcheck_type=%d\n", temp_host->check_type);
481
fprintf(fp, "\tcurrent_state=%d\n", temp_host->current_state);
482
fprintf(fp, "\tlast_hard_state=%d\n", temp_host->last_hard_state);
483
fprintf(fp, "\tlast_event_id=%lu\n", temp_host->last_event_id);
484
fprintf(fp, "\tcurrent_event_id=%lu\n", temp_host->current_event_id);
485
fprintf(fp, "\tcurrent_problem_id=%lu\n", temp_host->current_problem_id);
486
fprintf(fp, "\tlast_problem_id=%lu\n", temp_host->last_problem_id);
487
fprintf(fp, "\tplugin_output=%s\n", (temp_host->plugin_output == NULL) ? "" : temp_host->plugin_output);
488
fprintf(fp, "\tlong_plugin_output=%s\n", (temp_host->long_plugin_output == NULL) ? "" : temp_host->long_plugin_output);
489
fprintf(fp, "\tperformance_data=%s\n", (temp_host->perf_data == NULL) ? "" : temp_host->perf_data);
490
fprintf(fp, "\tlast_check=%lu\n", temp_host->last_check);
491
fprintf(fp, "\tnext_check=%lu\n", temp_host->next_check);
492
fprintf(fp, "\tcheck_options=%d\n", temp_host->check_options);
493
fprintf(fp, "\tcurrent_attempt=%d\n", temp_host->current_attempt);
494
fprintf(fp, "\tmax_attempts=%d\n", temp_host->max_attempts);
495
fprintf(fp, "\tstate_type=%d\n", temp_host->state_type);
496
fprintf(fp, "\tlast_state_change=%lu\n", temp_host->last_state_change);
497
fprintf(fp, "\tlast_hard_state_change=%lu\n", temp_host->last_hard_state_change);
498
fprintf(fp, "\tlast_time_up=%lu\n", temp_host->last_time_up);
499
fprintf(fp, "\tlast_time_down=%lu\n", temp_host->last_time_down);
500
fprintf(fp, "\tlast_time_unreachable=%lu\n", temp_host->last_time_unreachable);
501
fprintf(fp, "\tlast_notification=%lu\n", temp_host->last_host_notification);
502
fprintf(fp, "\tnext_notification=%lu\n", temp_host->next_host_notification);
503
fprintf(fp, "\tno_more_notifications=%d\n", temp_host->no_more_notifications);
504
fprintf(fp, "\tcurrent_notification_number=%d\n", temp_host->current_notification_number);
505
fprintf(fp, "\tcurrent_notification_id=%lu\n", temp_host->current_notification_id);
506
fprintf(fp, "\tnotifications_enabled=%d\n", temp_host->notifications_enabled);
507
fprintf(fp, "\tproblem_has_been_acknowledged=%d\n", temp_host->problem_has_been_acknowledged);
508
fprintf(fp, "\tacknowledgement_type=%d\n", temp_host->acknowledgement_type);
509
fprintf(fp, "\tactive_checks_enabled=%d\n", temp_host->checks_enabled);
510
fprintf(fp, "\tpassive_checks_enabled=%d\n", temp_host->accept_passive_host_checks);
511
fprintf(fp, "\tevent_handler_enabled=%d\n", temp_host->event_handler_enabled);
512
fprintf(fp, "\tflap_detection_enabled=%d\n", temp_host->flap_detection_enabled);
513
fprintf(fp, "\tfailure_prediction_enabled=%d\n", temp_host->failure_prediction_enabled);
514
fprintf(fp, "\tprocess_performance_data=%d\n", temp_host->process_performance_data);
515
fprintf(fp, "\tobsess_over_host=%d\n", temp_host->obsess_over_host);
516
fprintf(fp, "\tlast_update=%lu\n", current_time);
517
fprintf(fp, "\tis_flapping=%d\n", temp_host->is_flapping);
518
fprintf(fp, "\tpercent_state_change=%.2f\n", temp_host->percent_state_change);
519
fprintf(fp, "\tscheduled_downtime_depth=%d\n", temp_host->scheduled_downtime_depth);
524
521
fprintf(fp,"\tstate_history=");
525
522
for(x=0;x<MAX_STATE_HISTORY_ENTRIES;x++)
527
524
fprintf(fp,"\n");
529
526
/* custom variables */
530
for(temp_customvariablesmember=temp_host->custom_variables;temp_customvariablesmember!=NULL;temp_customvariablesmember=temp_customvariablesmember->next){
527
for(temp_customvariablesmember = temp_host->custom_variables; temp_customvariablesmember != NULL; temp_customvariablesmember = temp_customvariablesmember->next) {
531
528
if(temp_customvariablesmember->variable_name)
532
fprintf(fp,"\t_%s=%d;%s\n",temp_customvariablesmember->variable_name,temp_customvariablesmember->has_been_modified,(temp_customvariablesmember->variable_value==NULL)?"":temp_customvariablesmember->variable_value);
534
fprintf(fp,"\t}\n\n");
529
fprintf(fp, "\t_%s=%d;%s\n", temp_customvariablesmember->variable_name, temp_customvariablesmember->has_been_modified, (temp_customvariablesmember->variable_value == NULL) ? "" : temp_customvariablesmember->variable_value);
531
fprintf(fp, "\t}\n\n");
537
534
/* save service status data */
538
for(temp_service=service_list;temp_service!=NULL;temp_service=temp_service->next){
540
fprintf(fp,"servicestatus {\n");
541
fprintf(fp,"\thost_name=%s\n",temp_service->host_name);
543
fprintf(fp,"\tservice_description=%s\n",temp_service->description);
544
fprintf(fp,"\tmodified_attributes=%lu\n",temp_service->modified_attributes);
545
fprintf(fp,"\tcheck_command=%s\n",(temp_service->service_check_command==NULL)?"":temp_service->service_check_command);
546
fprintf(fp,"\tcheck_period=%s\n",(temp_service->check_period==NULL)?"":temp_service->check_period);
547
fprintf(fp,"\tnotification_period=%s\n",(temp_service->notification_period==NULL)?"":temp_service->notification_period);
548
fprintf(fp,"\tcheck_interval=%f\n",temp_service->check_interval);
549
fprintf(fp,"\tretry_interval=%f\n",temp_service->retry_interval);
550
fprintf(fp,"\tevent_handler=%s\n",(temp_service->event_handler==NULL)?"":temp_service->event_handler);
552
fprintf(fp,"\thas_been_checked=%d\n",temp_service->has_been_checked);
553
fprintf(fp,"\tshould_be_scheduled=%d\n",temp_service->should_be_scheduled);
554
fprintf(fp,"\tcheck_execution_time=%.3f\n",temp_service->execution_time);
555
fprintf(fp,"\tcheck_latency=%.3f\n",temp_service->latency);
556
fprintf(fp,"\tcheck_type=%d\n",temp_service->check_type);
557
fprintf(fp,"\tcurrent_state=%d\n",temp_service->current_state);
558
fprintf(fp,"\tlast_hard_state=%d\n",temp_service->last_hard_state);
559
fprintf(fp,"\tlast_event_id=%lu\n",temp_service->last_event_id);
560
fprintf(fp,"\tcurrent_event_id=%lu\n",temp_service->current_event_id);
561
fprintf(fp,"\tcurrent_problem_id=%lu\n",temp_service->current_problem_id);
562
fprintf(fp,"\tlast_problem_id=%lu\n",temp_service->last_problem_id);
563
fprintf(fp,"\tcurrent_attempt=%d\n",temp_service->current_attempt);
564
fprintf(fp,"\tmax_attempts=%d\n",temp_service->max_attempts);
565
fprintf(fp,"\tstate_type=%d\n",temp_service->state_type);
566
fprintf(fp,"\tlast_state_change=%lu\n",temp_service->last_state_change);
567
fprintf(fp,"\tlast_hard_state_change=%lu\n",temp_service->last_hard_state_change);
568
fprintf(fp,"\tlast_time_ok=%lu\n",temp_service->last_time_ok);
569
fprintf(fp,"\tlast_time_warning=%lu\n",temp_service->last_time_warning);
570
fprintf(fp,"\tlast_time_unknown=%lu\n",temp_service->last_time_unknown);
571
fprintf(fp,"\tlast_time_critical=%lu\n",temp_service->last_time_critical);
572
fprintf(fp,"\tplugin_output=%s\n",(temp_service->plugin_output==NULL)?"":temp_service->plugin_output);
573
fprintf(fp,"\tlong_plugin_output=%s\n",(temp_service->long_plugin_output==NULL)?"":temp_service->long_plugin_output);
574
fprintf(fp,"\tperformance_data=%s\n",(temp_service->perf_data==NULL)?"":temp_service->perf_data);
575
fprintf(fp,"\tlast_check=%lu\n",temp_service->last_check);
576
fprintf(fp,"\tnext_check=%lu\n",temp_service->next_check);
577
fprintf(fp,"\tcheck_options=%d\n",temp_service->check_options);
578
fprintf(fp,"\tcurrent_notification_number=%d\n",temp_service->current_notification_number);
579
fprintf(fp,"\tcurrent_notification_id=%lu\n",temp_service->current_notification_id);
580
fprintf(fp,"\tlast_notification=%lu\n",temp_service->last_notification);
581
fprintf(fp,"\tnext_notification=%lu\n",temp_service->next_notification);
582
fprintf(fp,"\tno_more_notifications=%d\n",temp_service->no_more_notifications);
583
fprintf(fp,"\tnotifications_enabled=%d\n",temp_service->notifications_enabled);
584
fprintf(fp,"\tactive_checks_enabled=%d\n",temp_service->checks_enabled);
585
fprintf(fp,"\tpassive_checks_enabled=%d\n",temp_service->accept_passive_service_checks);
586
fprintf(fp,"\tevent_handler_enabled=%d\n",temp_service->event_handler_enabled);
587
fprintf(fp,"\tproblem_has_been_acknowledged=%d\n",temp_service->problem_has_been_acknowledged);
588
fprintf(fp,"\tacknowledgement_type=%d\n",temp_service->acknowledgement_type);
589
fprintf(fp,"\tflap_detection_enabled=%d\n",temp_service->flap_detection_enabled);
590
fprintf(fp,"\tfailure_prediction_enabled=%d\n",temp_service->failure_prediction_enabled);
591
fprintf(fp,"\tprocess_performance_data=%d\n",temp_service->process_performance_data);
592
fprintf(fp,"\tobsess_over_service=%d\n",temp_service->obsess_over_service);
593
fprintf(fp,"\tlast_update=%lu\n",current_time);
594
fprintf(fp,"\tis_flapping=%d\n",temp_service->is_flapping);
595
fprintf(fp,"\tpercent_state_change=%.2f\n",temp_service->percent_state_change);
596
fprintf(fp,"\tscheduled_downtime_depth=%d\n",temp_service->scheduled_downtime_depth);
535
for(temp_service = service_list; temp_service != NULL; temp_service = temp_service->next) {
537
fprintf(fp, "servicestatus {\n");
538
fprintf(fp, "\thost_name=%s\n", temp_service->host_name);
540
fprintf(fp, "\tservice_description=%s\n", temp_service->description);
541
fprintf(fp, "\tmodified_attributes=%lu\n", temp_service->modified_attributes);
542
fprintf(fp, "\tcheck_command=%s\n", (temp_service->service_check_command == NULL) ? "" : temp_service->service_check_command);
543
fprintf(fp, "\tcheck_period=%s\n", (temp_service->check_period == NULL) ? "" : temp_service->check_period);
544
fprintf(fp, "\tnotification_period=%s\n", (temp_service->notification_period == NULL) ? "" : temp_service->notification_period);
545
fprintf(fp, "\tcheck_interval=%f\n", temp_service->check_interval);
546
fprintf(fp, "\tretry_interval=%f\n", temp_service->retry_interval);
547
fprintf(fp, "\tevent_handler=%s\n", (temp_service->event_handler == NULL) ? "" : temp_service->event_handler);
549
fprintf(fp, "\thas_been_checked=%d\n", temp_service->has_been_checked);
550
fprintf(fp, "\tshould_be_scheduled=%d\n", temp_service->should_be_scheduled);
551
fprintf(fp, "\tcheck_execution_time=%.3f\n", temp_service->execution_time);
552
fprintf(fp, "\tcheck_latency=%.3f\n", temp_service->latency);
553
fprintf(fp, "\tcheck_type=%d\n", temp_service->check_type);
554
fprintf(fp, "\tcurrent_state=%d\n", temp_service->current_state);
555
fprintf(fp, "\tlast_hard_state=%d\n", temp_service->last_hard_state);
556
fprintf(fp, "\tlast_event_id=%lu\n", temp_service->last_event_id);
557
fprintf(fp, "\tcurrent_event_id=%lu\n", temp_service->current_event_id);
558
fprintf(fp, "\tcurrent_problem_id=%lu\n", temp_service->current_problem_id);
559
fprintf(fp, "\tlast_problem_id=%lu\n", temp_service->last_problem_id);
560
fprintf(fp, "\tcurrent_attempt=%d\n", temp_service->current_attempt);
561
fprintf(fp, "\tmax_attempts=%d\n", temp_service->max_attempts);
562
fprintf(fp, "\tstate_type=%d\n", temp_service->state_type);
563
fprintf(fp, "\tlast_state_change=%lu\n", temp_service->last_state_change);
564
fprintf(fp, "\tlast_hard_state_change=%lu\n", temp_service->last_hard_state_change);
565
fprintf(fp, "\tlast_time_ok=%lu\n", temp_service->last_time_ok);
566
fprintf(fp, "\tlast_time_warning=%lu\n", temp_service->last_time_warning);
567
fprintf(fp, "\tlast_time_unknown=%lu\n", temp_service->last_time_unknown);
568
fprintf(fp, "\tlast_time_critical=%lu\n", temp_service->last_time_critical);
569
fprintf(fp, "\tplugin_output=%s\n", (temp_service->plugin_output == NULL) ? "" : temp_service->plugin_output);
570
fprintf(fp, "\tlong_plugin_output=%s\n", (temp_service->long_plugin_output == NULL) ? "" : temp_service->long_plugin_output);
571
fprintf(fp, "\tperformance_data=%s\n", (temp_service->perf_data == NULL) ? "" : temp_service->perf_data);
572
fprintf(fp, "\tlast_check=%lu\n", temp_service->last_check);
573
fprintf(fp, "\tnext_check=%lu\n", temp_service->next_check);
574
fprintf(fp, "\tcheck_options=%d\n", temp_service->check_options);
575
fprintf(fp, "\tcurrent_notification_number=%d\n", temp_service->current_notification_number);
576
fprintf(fp, "\tcurrent_notification_id=%lu\n", temp_service->current_notification_id);
577
fprintf(fp, "\tlast_notification=%lu\n", temp_service->last_notification);
578
fprintf(fp, "\tnext_notification=%lu\n", temp_service->next_notification);
579
fprintf(fp, "\tno_more_notifications=%d\n", temp_service->no_more_notifications);
580
fprintf(fp, "\tnotifications_enabled=%d\n", temp_service->notifications_enabled);
581
fprintf(fp, "\tactive_checks_enabled=%d\n", temp_service->checks_enabled);
582
fprintf(fp, "\tpassive_checks_enabled=%d\n", temp_service->accept_passive_service_checks);
583
fprintf(fp, "\tevent_handler_enabled=%d\n", temp_service->event_handler_enabled);
584
fprintf(fp, "\tproblem_has_been_acknowledged=%d\n", temp_service->problem_has_been_acknowledged);
585
fprintf(fp, "\tacknowledgement_type=%d\n", temp_service->acknowledgement_type);
586
fprintf(fp, "\tflap_detection_enabled=%d\n", temp_service->flap_detection_enabled);
587
fprintf(fp, "\tfailure_prediction_enabled=%d\n", temp_service->failure_prediction_enabled);
588
fprintf(fp, "\tprocess_performance_data=%d\n", temp_service->process_performance_data);
589
fprintf(fp, "\tobsess_over_service=%d\n", temp_service->obsess_over_service);
590
fprintf(fp, "\tlast_update=%lu\n", current_time);
591
fprintf(fp, "\tis_flapping=%d\n", temp_service->is_flapping);
592
fprintf(fp, "\tpercent_state_change=%.2f\n", temp_service->percent_state_change);
593
fprintf(fp, "\tscheduled_downtime_depth=%d\n", temp_service->scheduled_downtime_depth);
598
595
fprintf(fp,"\tstate_history=");
599
596
for(x=0;x<MAX_STATE_HISTORY_ENTRIES;x++)
601
598
fprintf(fp,"\n");
603
600
/* custom variables */
604
for(temp_customvariablesmember=temp_service->custom_variables;temp_customvariablesmember!=NULL;temp_customvariablesmember=temp_customvariablesmember->next){
601
for(temp_customvariablesmember = temp_service->custom_variables; temp_customvariablesmember != NULL; temp_customvariablesmember = temp_customvariablesmember->next) {
605
602
if(temp_customvariablesmember->variable_name)
606
fprintf(fp,"\t_%s=%d;%s\n",temp_customvariablesmember->variable_name,temp_customvariablesmember->has_been_modified,(temp_customvariablesmember->variable_value==NULL)?"":temp_customvariablesmember->variable_value);
608
fprintf(fp,"\t}\n\n");
603
fprintf(fp, "\t_%s=%d;%s\n", temp_customvariablesmember->variable_name, temp_customvariablesmember->has_been_modified, (temp_customvariablesmember->variable_value == NULL) ? "" : temp_customvariablesmember->variable_value);
605
fprintf(fp, "\t}\n\n");
611
608
/* save contact status data */
612
for(temp_contact=contact_list;temp_contact!=NULL;temp_contact=temp_contact->next){
614
fprintf(fp,"contactstatus {\n");
615
fprintf(fp,"\tcontact_name=%s\n",temp_contact->name);
617
fprintf(fp,"\tmodified_attributes=%lu\n",temp_contact->modified_attributes);
618
fprintf(fp,"\tmodified_host_attributes=%lu\n",temp_contact->modified_host_attributes);
619
fprintf(fp,"\tmodified_service_attributes=%lu\n",temp_contact->modified_service_attributes);
620
fprintf(fp,"\thost_notification_period=%s\n",(temp_contact->host_notification_period==NULL)?"":temp_contact->host_notification_period);
621
fprintf(fp,"\tservice_notification_period=%s\n",(temp_contact->service_notification_period==NULL)?"":temp_contact->service_notification_period);
623
fprintf(fp,"\tlast_host_notification=%lu\n",temp_contact->last_host_notification);
624
fprintf(fp,"\tlast_service_notification=%lu\n",temp_contact->last_service_notification);
625
fprintf(fp,"\thost_notifications_enabled=%d\n",temp_contact->host_notifications_enabled);
626
fprintf(fp,"\tservice_notifications_enabled=%d\n",temp_contact->service_notifications_enabled);
609
for(temp_contact = contact_list; temp_contact != NULL; temp_contact = temp_contact->next) {
611
fprintf(fp, "contactstatus {\n");
612
fprintf(fp, "\tcontact_name=%s\n", temp_contact->name);
614
fprintf(fp, "\tmodified_attributes=%lu\n", temp_contact->modified_attributes);
615
fprintf(fp, "\tmodified_host_attributes=%lu\n", temp_contact->modified_host_attributes);
616
fprintf(fp, "\tmodified_service_attributes=%lu\n", temp_contact->modified_service_attributes);
617
fprintf(fp, "\thost_notification_period=%s\n", (temp_contact->host_notification_period == NULL) ? "" : temp_contact->host_notification_period);
618
fprintf(fp, "\tservice_notification_period=%s\n", (temp_contact->service_notification_period == NULL) ? "" : temp_contact->service_notification_period);
620
fprintf(fp, "\tlast_host_notification=%lu\n", temp_contact->last_host_notification);
621
fprintf(fp, "\tlast_service_notification=%lu\n", temp_contact->last_service_notification);
622
fprintf(fp, "\thost_notifications_enabled=%d\n", temp_contact->host_notifications_enabled);
623
fprintf(fp, "\tservice_notifications_enabled=%d\n", temp_contact->service_notifications_enabled);
627
624
/* custom variables */
628
for(temp_customvariablesmember=temp_contact->custom_variables;temp_customvariablesmember!=NULL;temp_customvariablesmember=temp_customvariablesmember->next){
625
for(temp_customvariablesmember = temp_contact->custom_variables; temp_customvariablesmember != NULL; temp_customvariablesmember = temp_customvariablesmember->next) {
629
626
if(temp_customvariablesmember->variable_name)
630
fprintf(fp,"\t_%s=%d;%s\n",temp_customvariablesmember->variable_name,temp_customvariablesmember->has_been_modified,(temp_customvariablesmember->variable_value==NULL)?"":temp_customvariablesmember->variable_value);
632
fprintf(fp,"\t}\n\n");
627
fprintf(fp, "\t_%s=%d;%s\n", temp_customvariablesmember->variable_name, temp_customvariablesmember->has_been_modified, (temp_customvariablesmember->variable_value == NULL) ? "" : temp_customvariablesmember->variable_value);
629
fprintf(fp, "\t}\n\n");
635
632
/* save all comments */
636
for(temp_comment=comment_list;temp_comment!=NULL;temp_comment=temp_comment->next){
633
for(temp_comment = comment_list; temp_comment != NULL; temp_comment = temp_comment->next) {
638
if(temp_comment->comment_type==HOST_COMMENT)
639
fprintf(fp,"hostcomment {\n");
635
if(temp_comment->comment_type == HOST_COMMENT)
636
fprintf(fp, "hostcomment {\n");
641
fprintf(fp,"servicecomment {\n");
642
fprintf(fp,"\thost_name=%s\n",temp_comment->host_name);
643
if(temp_comment->comment_type==SERVICE_COMMENT)
644
fprintf(fp,"\tservice_description=%s\n",temp_comment->service_description);
645
fprintf(fp,"\tentry_type=%d\n",temp_comment->entry_type);
646
fprintf(fp,"\tcomment_id=%lu\n",temp_comment->comment_id);
647
fprintf(fp,"\tsource=%d\n",temp_comment->source);
648
fprintf(fp,"\tpersistent=%d\n",temp_comment->persistent);
649
fprintf(fp,"\tentry_time=%lu\n",temp_comment->entry_time);
650
fprintf(fp,"\texpires=%d\n",temp_comment->expires);
651
fprintf(fp,"\texpire_time=%lu\n",temp_comment->expire_time);
652
fprintf(fp,"\tauthor=%s\n",temp_comment->author);
653
fprintf(fp,"\tcomment_data=%s\n",temp_comment->comment_data);
654
fprintf(fp,"\t}\n\n");
638
fprintf(fp, "servicecomment {\n");
639
fprintf(fp, "\thost_name=%s\n", temp_comment->host_name);
640
if(temp_comment->comment_type == SERVICE_COMMENT)
641
fprintf(fp, "\tservice_description=%s\n", temp_comment->service_description);
642
fprintf(fp, "\tentry_type=%d\n", temp_comment->entry_type);
643
fprintf(fp, "\tcomment_id=%lu\n", temp_comment->comment_id);
644
fprintf(fp, "\tsource=%d\n", temp_comment->source);
645
fprintf(fp, "\tpersistent=%d\n", temp_comment->persistent);
646
fprintf(fp, "\tentry_time=%lu\n", temp_comment->entry_time);
647
fprintf(fp, "\texpires=%d\n", temp_comment->expires);
648
fprintf(fp, "\texpire_time=%lu\n", temp_comment->expire_time);
649
fprintf(fp, "\tauthor=%s\n", temp_comment->author);
650
fprintf(fp, "\tcomment_data=%s\n", temp_comment->comment_data);
651
fprintf(fp, "\t}\n\n");
657
654
/* save all downtime */
658
for(temp_downtime=scheduled_downtime_list;temp_downtime!=NULL;temp_downtime=temp_downtime->next){
655
for(temp_downtime = scheduled_downtime_list; temp_downtime != NULL; temp_downtime = temp_downtime->next) {
660
if(temp_downtime->type==HOST_DOWNTIME)
661
fprintf(fp,"hostdowntime {\n");
657
if(temp_downtime->type == HOST_DOWNTIME)
658
fprintf(fp, "hostdowntime {\n");
663
fprintf(fp,"servicedowntime {\n");
664
fprintf(fp,"\thost_name=%s\n",temp_downtime->host_name);
665
if(temp_downtime->type==SERVICE_DOWNTIME)
666
fprintf(fp,"\tservice_description=%s\n",temp_downtime->service_description);
667
fprintf(fp,"\tdowntime_id=%lu\n",temp_downtime->downtime_id);
668
fprintf(fp,"\tentry_time=%lu\n",temp_downtime->entry_time);
669
fprintf(fp,"\tstart_time=%lu\n",temp_downtime->start_time);
670
fprintf(fp,"\tend_time=%lu\n",temp_downtime->end_time);
671
fprintf(fp,"\ttriggered_by=%lu\n",temp_downtime->triggered_by);
672
fprintf(fp,"\tfixed=%d\n",temp_downtime->fixed);
673
fprintf(fp,"\tduration=%lu\n",temp_downtime->duration);
674
fprintf(fp,"\tauthor=%s\n",temp_downtime->author);
675
fprintf(fp,"\tcomment=%s\n",temp_downtime->comment);
676
fprintf(fp,"\t}\n\n");
660
fprintf(fp, "servicedowntime {\n");
661
fprintf(fp, "\thost_name=%s\n", temp_downtime->host_name);
662
if(temp_downtime->type == SERVICE_DOWNTIME)
663
fprintf(fp, "\tservice_description=%s\n", temp_downtime->service_description);
664
fprintf(fp, "\tdowntime_id=%lu\n", temp_downtime->downtime_id);
665
fprintf(fp, "\tentry_time=%lu\n", temp_downtime->entry_time);
666
fprintf(fp, "\tstart_time=%lu\n", temp_downtime->start_time);
667
fprintf(fp, "\tend_time=%lu\n", temp_downtime->end_time);
668
fprintf(fp, "\ttriggered_by=%lu\n", temp_downtime->triggered_by);
669
fprintf(fp, "\tfixed=%d\n", temp_downtime->fixed);
670
fprintf(fp, "\tduration=%lu\n", temp_downtime->duration);
671
fprintf(fp, "\tis_in_effect=%d\n", temp_downtime->is_in_effect);
672
fprintf(fp, "\tauthor=%s\n", temp_downtime->author);
673
fprintf(fp, "\tcomment=%s\n", temp_downtime->comment);
674
fprintf(fp, "\t}\n\n");
680
678
/* reset file permissions */
681
fchmod(fd,S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
679
fchmod(fd, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
683
681
/* flush the file to disk */
686
684
/* close the temp file */
689
687
/* fsync the file so that it is completely written out before moving it */
692
690
/* save/close was successful */
697
695
/* move the temp file to the status log (overwrite the old status log) */
698
if(my_rename(temp_file,xsddefault_status_log)){
696
if(my_rename(temp_file, xsddefault_status_log)) {
699
697
unlink(temp_file);
701
logit(NSLOG_RUNTIME_ERROR,TRUE,"Error: Unable to update status data file '%s': %s",xsddefault_status_log,strerror(errno));
698
logit(NSLOG_RUNTIME_ERROR, TRUE, "Error: Unable to update status data file '%s': %s", xsddefault_status_log, strerror(errno));
707
703
/* a problem occurred saving the file */
712
708
/* remove temp file and log an error */
713
709
unlink(temp_file);
714
logit(NSLOG_RUNTIME_ERROR,TRUE,"Error: Unable to save status file: %s",strerror(errno));
710
logit(NSLOG_RUNTIME_ERROR, TRUE, "Error: Unable to save status file: %s", strerror(errno));
717
713
/* free memory */
718
714
my_free(temp_file);
731
727
/******************************************************************/
733
729
/* read all program, host, and service status information */
734
int xsddefault_read_status_data(char *config_file,int options){
730
int xsddefault_read_status_data(char *config_file, int options) {
736
char input[MAX_PLUGIN_OUTPUT_LENGTH]="";
732
char input[MAX_PLUGIN_OUTPUT_LENGTH] = "";
740
mmapfile *thefile=NULL;
736
mmapfile *thefile = NULL;
742
int data_type=XSDDEFAULT_NO_DATA;
743
hoststatus *temp_hoststatus=NULL;
744
servicestatus *temp_servicestatus=NULL;
738
int data_type = XSDDEFAULT_NO_DATA;
739
hoststatus *temp_hoststatus = NULL;
740
servicestatus *temp_servicestatus = NULL;
749
745
/* comment and downtime vars */
750
unsigned long comment_id=0;
751
int persistent=FALSE;
753
time_t expire_time=0L;
754
int entry_type=USER_COMMENT;
755
int source=COMMENTSOURCE_INTERNAL;
756
time_t entry_time=0L;
757
char *host_name=NULL;
758
char *service_description=NULL;
760
char *comment_data=NULL;
761
unsigned long downtime_id=0;
762
time_t start_time=0L;
765
unsigned long triggered_by=0;
766
unsigned long duration=0L;
746
unsigned long comment_id = 0;
747
int persistent = FALSE;
749
time_t expire_time = 0L;
750
int entry_type = USER_COMMENT;
751
int source = COMMENTSOURCE_INTERNAL;
752
time_t entry_time = 0L;
753
char *host_name = NULL;
754
char *service_description = NULL;
756
char *comment_data = NULL;
757
unsigned long downtime_id = 0;
758
time_t start_time = 0L;
759
time_t end_time = 0L;
761
unsigned long triggered_by = 0;
762
unsigned long duration = 0L;
764
int is_in_effect = FALSE;
770
767
/* initialize some vars */
771
for(x=0;x<MAX_CHECK_STATS_TYPES;x++){
772
program_stats[x][0]=0;
773
program_stats[x][1]=0;
774
program_stats[x][2]=0;
768
for(x = 0; x < MAX_CHECK_STATS_TYPES; x++) {
769
program_stats[x][0] = 0;
770
program_stats[x][1] = 0;
771
program_stats[x][2] = 0;
777
774
/* grab configuration data */
778
result=xsddefault_grab_config_info(config_file);
775
result = xsddefault_grab_config_info(config_file);
782
779
/* open the status file for reading */
784
if((fp=fopen(xsddefault_status_log,"r"))==NULL)
781
if((fp = fopen(xsddefault_status_log, "r")) == NULL)
787
if((thefile=mmap_fopen(xsddefault_status_log))==NULL)
784
if((thefile = mmap_fopen(xsddefault_status_log)) == NULL)
791
788
/* Big speedup when reading status.dat in bulk */
792
defer_downtime_sorting=1;
793
defer_comment_sorting=1;
789
defer_downtime_sorting = 1;
790
defer_comment_sorting = 1;
795
792
/* read all lines in the status file */
800
if(fgets(input,sizeof(input),fp)==NULL)
797
if(fgets(input, sizeof(input), fp) == NULL)
803
800
/* free memory */
806
803
/* read the next line */
807
if((input=mmap_fgets(thefile))==NULL)
804
if((input = mmap_fgets(thefile)) == NULL)
813
810
/* skip blank lines and comments */
814
if(input[0]=='#' || input[0]=='\x0')
811
if(input[0] == '#' || input[0] == '\x0')
817
else if(!strcmp(input,"info {"))
818
data_type=XSDDEFAULT_INFO_DATA;
819
else if(!strcmp(input,"programstatus {"))
820
data_type=XSDDEFAULT_PROGRAMSTATUS_DATA;
821
else if(!strcmp(input,"hoststatus {")){
822
data_type=XSDDEFAULT_HOSTSTATUS_DATA;
823
temp_hoststatus=(hoststatus *)malloc(sizeof(hoststatus));
825
temp_hoststatus->host_name=NULL;
826
temp_hoststatus->plugin_output=NULL;
827
temp_hoststatus->long_plugin_output=NULL;
828
temp_hoststatus->perf_data=NULL;
829
temp_hoststatus->check_options=0;
832
else if(!strcmp(input,"servicestatus {")){
833
data_type=XSDDEFAULT_SERVICESTATUS_DATA;
834
temp_servicestatus=(servicestatus *)malloc(sizeof(servicestatus));
835
if(temp_servicestatus){
836
temp_servicestatus->host_name=NULL;
837
temp_servicestatus->description=NULL;
838
temp_servicestatus->plugin_output=NULL;
839
temp_servicestatus->long_plugin_output=NULL;
840
temp_servicestatus->perf_data=NULL;
841
temp_servicestatus->check_options=0;
844
else if(!strcmp(input,"contactstatus {")){
845
data_type=XSDDEFAULT_CONTACTSTATUS_DATA;
814
else if(!strcmp(input, "info {"))
815
data_type = XSDDEFAULT_INFO_DATA;
816
else if(!strcmp(input, "programstatus {"))
817
data_type = XSDDEFAULT_PROGRAMSTATUS_DATA;
818
else if(!strcmp(input, "hoststatus {")) {
819
data_type = XSDDEFAULT_HOSTSTATUS_DATA;
820
temp_hoststatus = (hoststatus *)calloc(1, sizeof(hoststatus));
822
else if(!strcmp(input, "servicestatus {")) {
823
data_type = XSDDEFAULT_SERVICESTATUS_DATA;
824
temp_servicestatus = (servicestatus *)calloc(1, sizeof(servicestatus));
826
else if(!strcmp(input, "contactstatus {")) {
827
data_type = XSDDEFAULT_CONTACTSTATUS_DATA;
846
828
/* unimplemented */
848
else if(!strcmp(input,"hostcomment {"))
849
data_type=XSDDEFAULT_HOSTCOMMENT_DATA;
850
else if(!strcmp(input,"servicecomment {"))
851
data_type=XSDDEFAULT_SERVICECOMMENT_DATA;
852
else if(!strcmp(input,"hostdowntime {"))
853
data_type=XSDDEFAULT_HOSTDOWNTIME_DATA;
854
else if(!strcmp(input,"servicedowntime {"))
855
data_type=XSDDEFAULT_SERVICEDOWNTIME_DATA;
857
else if(!strcmp(input,"}")){
861
case XSDDEFAULT_INFO_DATA:
864
case XSDDEFAULT_PROGRAMSTATUS_DATA:
867
case XSDDEFAULT_HOSTSTATUS_DATA:
868
add_host_status(temp_hoststatus);
869
temp_hoststatus=NULL;
872
case XSDDEFAULT_SERVICESTATUS_DATA:
873
add_service_status(temp_servicestatus);
874
temp_servicestatus=NULL;
877
case XSDDEFAULT_CONTACTSTATUS_DATA:
881
case XSDDEFAULT_HOSTCOMMENT_DATA:
882
case XSDDEFAULT_SERVICECOMMENT_DATA:
884
/* add the comment */
885
add_comment((data_type==XSDDEFAULT_HOSTCOMMENT_DATA)?HOST_COMMENT:SERVICE_COMMENT,entry_type,host_name,service_description,entry_time,author,comment_data,comment_id,persistent,expires,expire_time,source);
887
/* free temp memory */
889
my_free(service_description);
891
my_free(comment_data);
894
entry_type=USER_COMMENT;
896
source=COMMENTSOURCE_INTERNAL;
904
case XSDDEFAULT_HOSTDOWNTIME_DATA:
905
case XSDDEFAULT_SERVICEDOWNTIME_DATA:
907
/* add the downtime */
908
if(data_type==XSDDEFAULT_HOSTDOWNTIME_DATA)
909
add_host_downtime(host_name,entry_time,author,comment_data,start_time,end_time,fixed,triggered_by,duration,downtime_id);
911
add_service_downtime(host_name,service_description,entry_time,author,comment_data,start_time,end_time,fixed,triggered_by,duration,downtime_id);
913
/* free temp memory */
915
my_free(service_description);
917
my_free(comment_data);
934
data_type=XSDDEFAULT_NO_DATA;
937
else if(data_type!=XSDDEFAULT_NO_DATA){
939
var=strtok(input,"=");
940
val=strtok(NULL,"\n");
830
else if(!strcmp(input, "hostcomment {"))
831
data_type = XSDDEFAULT_HOSTCOMMENT_DATA;
832
else if(!strcmp(input, "servicecomment {"))
833
data_type = XSDDEFAULT_SERVICECOMMENT_DATA;
834
else if(!strcmp(input, "hostdowntime {"))
835
data_type = XSDDEFAULT_HOSTDOWNTIME_DATA;
836
else if(!strcmp(input, "servicedowntime {"))
837
data_type = XSDDEFAULT_SERVICEDOWNTIME_DATA;
839
else if(!strcmp(input, "}")) {
843
case XSDDEFAULT_INFO_DATA:
846
case XSDDEFAULT_PROGRAMSTATUS_DATA:
849
case XSDDEFAULT_HOSTSTATUS_DATA:
850
add_host_status(temp_hoststatus);
851
temp_hoststatus = NULL;
854
case XSDDEFAULT_SERVICESTATUS_DATA:
855
add_service_status(temp_servicestatus);
856
temp_servicestatus = NULL;
859
case XSDDEFAULT_CONTACTSTATUS_DATA:
863
case XSDDEFAULT_HOSTCOMMENT_DATA:
864
case XSDDEFAULT_SERVICECOMMENT_DATA:
866
/* add the comment */
867
add_comment((data_type == XSDDEFAULT_HOSTCOMMENT_DATA) ? HOST_COMMENT : SERVICE_COMMENT, entry_type, host_name, service_description, entry_time, author, comment_data, comment_id, persistent, expires, expire_time, source);
869
/* free temp memory */
871
my_free(service_description);
873
my_free(comment_data);
876
entry_type = USER_COMMENT;
878
source = COMMENTSOURCE_INTERNAL;
886
case XSDDEFAULT_HOSTDOWNTIME_DATA:
887
case XSDDEFAULT_SERVICEDOWNTIME_DATA:
889
/* add the downtime */
890
if(data_type == XSDDEFAULT_HOSTDOWNTIME_DATA)
891
add_host_downtime(host_name, entry_time, author, comment_data, start_time, end_time, fixed, triggered_by, duration, downtime_id, is_in_effect);
893
add_service_downtime(host_name, service_description, entry_time, author, comment_data, start_time, end_time, fixed, triggered_by, duration, downtime_id, is_in_effect);
895
/* free temp memory */
897
my_free(service_description);
899
my_free(comment_data);
909
is_in_effect = FALSE;
917
data_type = XSDDEFAULT_NO_DATA;
920
else if(data_type != XSDDEFAULT_NO_DATA) {
922
var = strtok(input, "=");
923
val = strtok(NULL, "\n");
946
case XSDDEFAULT_INFO_DATA:
949
case XSDDEFAULT_PROGRAMSTATUS_DATA:
950
/* NOTE: some vars are not read, as they are not used by the CGIs (modified attributes, event handler commands, etc.) */
951
if(!strcmp(var,"nagios_pid"))
952
nagios_pid=atoi(val);
953
else if(!strcmp(var,"daemon_mode"))
954
daemon_mode=(atoi(val)>0)?TRUE:FALSE;
955
else if(!strcmp(var,"program_start"))
956
program_start=strtoul(val,NULL,10);
957
else if(!strcmp(var,"last_command_check"))
958
last_command_check=strtoul(val,NULL,10);
959
else if(!strcmp(var,"last_log_rotation"))
960
last_log_rotation=strtoul(val,NULL,10);
961
else if(!strcmp(var,"enable_notifications"))
962
enable_notifications=(atoi(val)>0)?TRUE:FALSE;
963
else if(!strcmp(var,"active_service_checks_enabled"))
964
execute_service_checks=(atoi(val)>0)?TRUE:FALSE;
965
else if(!strcmp(var,"passive_service_checks_enabled"))
966
accept_passive_service_checks=(atoi(val)>0)?TRUE:FALSE;
967
else if(!strcmp(var,"active_host_checks_enabled"))
968
execute_host_checks=(atoi(val)>0)?TRUE:FALSE;
969
else if(!strcmp(var,"passive_host_checks_enabled"))
970
accept_passive_host_checks=(atoi(val)>0)?TRUE:FALSE;
971
else if(!strcmp(var,"enable_event_handlers"))
972
enable_event_handlers=(atoi(val)>0)?TRUE:FALSE;
973
else if(!strcmp(var,"obsess_over_services"))
974
obsess_over_services=(atoi(val)>0)?TRUE:FALSE;
975
else if(!strcmp(var,"obsess_over_hosts"))
976
obsess_over_hosts=(atoi(val)>0)?TRUE:FALSE;
977
else if(!strcmp(var,"check_service_freshness"))
978
check_service_freshness=(atoi(val)>0)?TRUE:FALSE;
979
else if(!strcmp(var,"check_host_freshness"))
980
check_host_freshness=(atoi(val)>0)?TRUE:FALSE;
981
else if(!strcmp(var,"enable_flap_detection"))
982
enable_flap_detection=(atoi(val)>0)?TRUE:FALSE;
983
else if(!strcmp(var,"enable_failure_prediction"))
984
enable_failure_prediction=(atoi(val)>0)?TRUE:FALSE;
985
else if(!strcmp(var,"process_performance_data"))
986
process_performance_data=(atoi(val)>0)?TRUE:FALSE;
988
else if (!strcmp(var,"total_external_command_buffer_slots"))
989
buffer_stats[0][0]=atoi(val);
990
else if (!strcmp(var,"used_external_command_buffer_slots"))
991
buffer_stats[0][1]=atoi(val);
992
else if (!strcmp(var,"high_external_command_buffer_slots"))
993
buffer_stats[0][2]=atoi(val);
996
else if (strstr(var,"_stats")){
999
if(!strcmp(var,"active_scheduled_host_check_stats"))
1000
x=ACTIVE_SCHEDULED_HOST_CHECK_STATS;
1001
if(!strcmp(var,"active_ondemand_host_check_stats"))
1002
x=ACTIVE_ONDEMAND_HOST_CHECK_STATS;
1003
if(!strcmp(var,"passive_host_check_stats"))
1004
x=PASSIVE_HOST_CHECK_STATS;
1005
if(!strcmp(var,"active_scheduled_service_check_stats"))
1006
x=ACTIVE_SCHEDULED_SERVICE_CHECK_STATS;
1007
if(!strcmp(var,"active_ondemand_service_check_stats"))
1008
x=ACTIVE_ONDEMAND_SERVICE_CHECK_STATS;
1009
if(!strcmp(var,"passive_service_check_stats"))
1010
x=PASSIVE_SERVICE_CHECK_STATS;
1011
if(!strcmp(var,"cached_host_check_stats"))
1012
x=ACTIVE_CACHED_HOST_CHECK_STATS;
1013
if(!strcmp(var,"cached_service_check_stats"))
1014
x=ACTIVE_CACHED_SERVICE_CHECK_STATS;
1015
if(!strcmp(var,"external_command_stats"))
1016
x=EXTERNAL_COMMAND_STATS;
1017
if(!strcmp(var,"parallel_host_check_stats"))
1018
x=PARALLEL_HOST_CHECK_STATS;
1019
if(!strcmp(var,"serial_host_check_stats"))
1020
x=SERIAL_HOST_CHECK_STATS;
1023
if((ptr=strtok(val,","))){
1024
program_stats[x][0]=atoi(ptr);
1025
if((ptr=strtok(NULL,","))){
1026
program_stats[x][1]=atoi(ptr);
1027
if((ptr=strtok(NULL,"\n")))
1028
program_stats[x][2]=atoi(ptr);
929
case XSDDEFAULT_INFO_DATA:
932
case XSDDEFAULT_PROGRAMSTATUS_DATA:
933
/* NOTE: some vars are not read, as they are not used by the CGIs (modified attributes, event handler commands, etc.) */
934
if(!strcmp(var, "nagios_pid"))
935
nagios_pid = atoi(val);
936
else if(!strcmp(var, "daemon_mode"))
937
daemon_mode = (atoi(val) > 0) ? TRUE : FALSE;
938
else if(!strcmp(var, "program_start"))
939
program_start = strtoul(val, NULL, 10);
940
else if(!strcmp(var, "last_command_check"))
941
last_command_check = strtoul(val, NULL, 10);
942
else if(!strcmp(var, "last_log_rotation"))
943
last_log_rotation = strtoul(val, NULL, 10);
944
else if(!strcmp(var, "enable_notifications"))
945
enable_notifications = (atoi(val) > 0) ? TRUE : FALSE;
946
else if(!strcmp(var, "active_service_checks_enabled"))
947
execute_service_checks = (atoi(val) > 0) ? TRUE : FALSE;
948
else if(!strcmp(var, "passive_service_checks_enabled"))
949
accept_passive_service_checks = (atoi(val) > 0) ? TRUE : FALSE;
950
else if(!strcmp(var, "active_host_checks_enabled"))
951
execute_host_checks = (atoi(val) > 0) ? TRUE : FALSE;
952
else if(!strcmp(var, "passive_host_checks_enabled"))
953
accept_passive_host_checks = (atoi(val) > 0) ? TRUE : FALSE;
954
else if(!strcmp(var, "enable_event_handlers"))
955
enable_event_handlers = (atoi(val) > 0) ? TRUE : FALSE;
956
else if(!strcmp(var, "obsess_over_services"))
957
obsess_over_services = (atoi(val) > 0) ? TRUE : FALSE;
958
else if(!strcmp(var, "obsess_over_hosts"))
959
obsess_over_hosts = (atoi(val) > 0) ? TRUE : FALSE;
960
else if(!strcmp(var, "check_service_freshness"))
961
check_service_freshness = (atoi(val) > 0) ? TRUE : FALSE;
962
else if(!strcmp(var, "check_host_freshness"))
963
check_host_freshness = (atoi(val) > 0) ? TRUE : FALSE;
964
else if(!strcmp(var, "enable_flap_detection"))
965
enable_flap_detection = (atoi(val) > 0) ? TRUE : FALSE;
966
else if(!strcmp(var, "enable_failure_prediction"))
967
enable_failure_prediction = (atoi(val) > 0) ? TRUE : FALSE;
968
else if(!strcmp(var, "process_performance_data"))
969
process_performance_data = (atoi(val) > 0) ? TRUE : FALSE;
971
else if(!strcmp(var, "total_external_command_buffer_slots"))
972
buffer_stats[0][0] = atoi(val);
973
else if(!strcmp(var, "used_external_command_buffer_slots"))
974
buffer_stats[0][1] = atoi(val);
975
else if(!strcmp(var, "high_external_command_buffer_slots"))
976
buffer_stats[0][2] = atoi(val);
979
else if(strstr(var, "_stats")) {
982
if(!strcmp(var, "active_scheduled_host_check_stats"))
983
x = ACTIVE_SCHEDULED_HOST_CHECK_STATS;
984
if(!strcmp(var, "active_ondemand_host_check_stats"))
985
x = ACTIVE_ONDEMAND_HOST_CHECK_STATS;
986
if(!strcmp(var, "passive_host_check_stats"))
987
x = PASSIVE_HOST_CHECK_STATS;
988
if(!strcmp(var, "active_scheduled_service_check_stats"))
989
x = ACTIVE_SCHEDULED_SERVICE_CHECK_STATS;
990
if(!strcmp(var, "active_ondemand_service_check_stats"))
991
x = ACTIVE_ONDEMAND_SERVICE_CHECK_STATS;
992
if(!strcmp(var, "passive_service_check_stats"))
993
x = PASSIVE_SERVICE_CHECK_STATS;
994
if(!strcmp(var, "cached_host_check_stats"))
995
x = ACTIVE_CACHED_HOST_CHECK_STATS;
996
if(!strcmp(var, "cached_service_check_stats"))
997
x = ACTIVE_CACHED_SERVICE_CHECK_STATS;
998
if(!strcmp(var, "external_command_stats"))
999
x = EXTERNAL_COMMAND_STATS;
1000
if(!strcmp(var, "parallel_host_check_stats"))
1001
x = PARALLEL_HOST_CHECK_STATS;
1002
if(!strcmp(var, "serial_host_check_stats"))
1003
x = SERIAL_HOST_CHECK_STATS;
1006
if((ptr = strtok(val, ","))) {
1007
program_stats[x][0] = atoi(ptr);
1008
if((ptr = strtok(NULL, ","))) {
1009
program_stats[x][1] = atoi(ptr);
1010
if((ptr = strtok(NULL, "\n")))
1011
program_stats[x][2] = atoi(ptr);
1035
case XSDDEFAULT_HOSTSTATUS_DATA:
1036
/* NOTE: some vars are not read, as they are not used by the CGIs (modified attributes, event handler commands, etc.) */
1037
if(temp_hoststatus!=NULL){
1038
if(!strcmp(var,"host_name"))
1039
temp_hoststatus->host_name=(char *)strdup(val);
1040
else if(!strcmp(var,"has_been_checked"))
1041
temp_hoststatus->has_been_checked=(atoi(val)>0)?TRUE:FALSE;
1042
else if(!strcmp(var,"should_be_scheduled"))
1043
temp_hoststatus->should_be_scheduled=(atoi(val)>0)?TRUE:FALSE;
1044
else if(!strcmp(var,"check_execution_time"))
1045
temp_hoststatus->execution_time=strtod(val,NULL);
1046
else if(!strcmp(var,"check_latency"))
1047
temp_hoststatus->latency=strtod(val,NULL);
1048
else if(!strcmp(var,"check_type"))
1049
temp_hoststatus->check_type=atoi(val);
1050
else if(!strcmp(var,"current_state"))
1051
temp_hoststatus->status=atoi(val);
1052
else if(!strcmp(var,"last_hard_state"))
1053
temp_hoststatus->last_hard_state=atoi(val);
1054
else if(!strcmp(var,"plugin_output")){
1055
temp_hoststatus->plugin_output=(char *)strdup(val);
1056
unescape_newlines(temp_hoststatus->plugin_output);
1058
else if(!strcmp(var,"long_plugin_output")){
1059
temp_hoststatus->long_plugin_output=(char *)strdup(val);
1060
unescape_newlines(temp_hoststatus->long_plugin_output);
1062
else if(!strcmp(var,"performance_data"))
1063
temp_hoststatus->perf_data=(char *)strdup(val);
1064
else if(!strcmp(var,"current_attempt"))
1065
temp_hoststatus->current_attempt=atoi(val);
1066
else if(!strcmp(var,"max_attempts"))
1067
temp_hoststatus->max_attempts=atoi(val);
1068
else if(!strcmp(var,"last_check"))
1069
temp_hoststatus->last_check=strtoul(val,NULL,10);
1070
else if(!strcmp(var,"next_check"))
1071
temp_hoststatus->next_check=strtoul(val,NULL,10);
1072
else if(!strcmp(var,"check_options"))
1073
temp_hoststatus->check_options=atoi(val);
1074
else if(!strcmp(var,"current_attempt"))
1075
temp_hoststatus->current_attempt=(atoi(val)>0)?TRUE:FALSE;
1076
else if(!strcmp(var,"state_type"))
1077
temp_hoststatus->state_type=atoi(val);
1078
else if(!strcmp(var,"last_state_change"))
1079
temp_hoststatus->last_state_change=strtoul(val,NULL,10);
1080
else if(!strcmp(var,"last_hard_state_change"))
1081
temp_hoststatus->last_hard_state_change=strtoul(val,NULL,10);
1082
else if(!strcmp(var,"last_time_up"))
1083
temp_hoststatus->last_time_up=strtoul(val,NULL,10);
1084
else if(!strcmp(var,"last_time_down"))
1085
temp_hoststatus->last_time_down=strtoul(val,NULL,10);
1086
else if(!strcmp(var,"last_time_unreachable"))
1087
temp_hoststatus->last_time_unreachable=strtoul(val,NULL,10);
1088
else if(!strcmp(var,"last_notification"))
1089
temp_hoststatus->last_notification=strtoul(val,NULL,10);
1090
else if(!strcmp(var,"next_notification"))
1091
temp_hoststatus->next_notification=strtoul(val,NULL,10);
1092
else if(!strcmp(var,"no_more_notifications"))
1093
temp_hoststatus->no_more_notifications=(atoi(val)>0)?TRUE:FALSE;
1094
else if(!strcmp(var,"current_notification_number"))
1095
temp_hoststatus->current_notification_number=atoi(val);
1096
else if(!strcmp(var,"notifications_enabled"))
1097
temp_hoststatus->notifications_enabled=(atoi(val)>0)?TRUE:FALSE;
1098
else if(!strcmp(var,"problem_has_been_acknowledged"))
1099
temp_hoststatus->problem_has_been_acknowledged=(atoi(val)>0)?TRUE:FALSE;
1100
else if(!strcmp(var,"acknowledgement_type"))
1101
temp_hoststatus->acknowledgement_type=atoi(val);
1102
else if(!strcmp(var,"active_checks_enabled"))
1103
temp_hoststatus->checks_enabled=(atoi(val)>0)?TRUE:FALSE;
1104
else if(!strcmp(var,"passive_checks_enabled"))
1105
temp_hoststatus->accept_passive_host_checks=(atoi(val)>0)?TRUE:FALSE;
1106
else if(!strcmp(var,"event_handler_enabled"))
1107
temp_hoststatus->event_handler_enabled=(atoi(val)>0)?TRUE:FALSE;
1108
else if(!strcmp(var,"flap_detection_enabled"))
1109
temp_hoststatus->flap_detection_enabled=(atoi(val)>0)?TRUE:FALSE;
1110
else if(!strcmp(var,"failure_prediction_enabled"))
1111
temp_hoststatus->failure_prediction_enabled=(atoi(val)>0)?TRUE:FALSE;
1112
else if(!strcmp(var,"process_performance_data"))
1113
temp_hoststatus->process_performance_data=(atoi(val)>0)?TRUE:FALSE;
1114
else if(!strcmp(var,"obsess_over_host"))
1115
temp_hoststatus->obsess_over_host=(atoi(val)>0)?TRUE:FALSE;
1116
else if(!strcmp(var,"last_update"))
1117
temp_hoststatus->last_update=strtoul(val,NULL,10);
1118
else if(!strcmp(var,"is_flapping"))
1119
temp_hoststatus->is_flapping=(atoi(val)>0)?TRUE:FALSE;
1120
else if(!strcmp(var,"percent_state_change"))
1121
temp_hoststatus->percent_state_change=strtod(val,NULL);
1122
else if(!strcmp(var,"scheduled_downtime_depth"))
1123
temp_hoststatus->scheduled_downtime_depth=atoi(val);
1125
else if(!strcmp(var,"state_history")){
1127
for(x=0;x<MAX_STATE_HISTORY_ENTRIES;x++)
1128
temp_hoststatus->state_history[x]=atoi(my_strsep(&temp_ptr,","));
1129
temp_hoststatus->state_history_index=0;
1135
case XSDDEFAULT_SERVICESTATUS_DATA:
1136
/* NOTE: some vars are not read, as they are not used by the CGIs (modified attributes, event handler commands, etc.) */
1137
if(temp_servicestatus!=NULL){
1138
if(!strcmp(var,"host_name"))
1139
temp_servicestatus->host_name=(char *)strdup(val);
1140
else if(!strcmp(var,"service_description"))
1141
temp_servicestatus->description=(char *)strdup(val);
1142
else if(!strcmp(var,"has_been_checked"))
1143
temp_servicestatus->has_been_checked=(atoi(val)>0)?TRUE:FALSE;
1144
else if(!strcmp(var,"should_be_scheduled"))
1145
temp_servicestatus->should_be_scheduled=(atoi(val)>0)?TRUE:FALSE;
1146
else if(!strcmp(var,"check_execution_time"))
1147
temp_servicestatus->execution_time=strtod(val,NULL);
1148
else if(!strcmp(var,"check_latency"))
1149
temp_servicestatus->latency=strtod(val,NULL);
1150
else if(!strcmp(var,"check_type"))
1151
temp_servicestatus->check_type=atoi(val);
1152
else if(!strcmp(var,"current_state"))
1153
temp_servicestatus->status=atoi(val);
1154
else if(!strcmp(var,"last_hard_state"))
1155
temp_servicestatus->last_hard_state=atoi(val);
1156
else if(!strcmp(var,"current_attempt"))
1157
temp_servicestatus->current_attempt=atoi(val);
1158
else if(!strcmp(var,"max_attempts"))
1159
temp_servicestatus->max_attempts=atoi(val);
1160
else if(!strcmp(var,"state_type"))
1161
temp_servicestatus->state_type=atoi(val);
1162
else if(!strcmp(var,"last_state_change"))
1163
temp_servicestatus->last_state_change=strtoul(val,NULL,10);
1164
else if(!strcmp(var,"last_hard_state_change"))
1165
temp_servicestatus->last_hard_state_change=strtoul(val,NULL,10);
1166
else if(!strcmp(var,"last_time_ok"))
1167
temp_servicestatus->last_time_ok=strtoul(val,NULL,10);
1168
else if(!strcmp(var,"last_time_warning"))
1169
temp_servicestatus->last_time_warning=strtoul(val,NULL,10);
1170
else if(!strcmp(var,"last_time_unknown"))
1171
temp_servicestatus->last_time_unknown=strtoul(val,NULL,10);
1172
else if(!strcmp(var,"last_time_critical"))
1173
temp_servicestatus->last_time_critical=strtoul(val,NULL,10);
1174
else if(!strcmp(var,"plugin_output")){
1175
temp_servicestatus->plugin_output=(char *)strdup(val);
1176
unescape_newlines(temp_servicestatus->plugin_output);
1178
else if(!strcmp(var,"long_plugin_output")){
1179
temp_servicestatus->long_plugin_output=(char *)strdup(val);
1180
unescape_newlines(temp_servicestatus->long_plugin_output);
1182
else if(!strcmp(var,"performance_data"))
1183
temp_servicestatus->perf_data=(char *)strdup(val);
1184
else if(!strcmp(var,"last_check"))
1185
temp_servicestatus->last_check=strtoul(val,NULL,10);
1186
else if(!strcmp(var,"next_check"))
1187
temp_servicestatus->next_check=strtoul(val,NULL,10);
1188
else if(!strcmp(var,"check_options"))
1189
temp_servicestatus->check_options=atoi(val);
1190
else if(!strcmp(var,"current_notification_number"))
1191
temp_servicestatus->current_notification_number=atoi(val);
1192
else if(!strcmp(var,"last_notification"))
1193
temp_servicestatus->last_notification=strtoul(val,NULL,10);
1194
else if(!strcmp(var,"next_notification"))
1195
temp_servicestatus->next_notification=strtoul(val,NULL,10);
1196
else if(!strcmp(var,"no_more_notifications"))
1197
temp_servicestatus->no_more_notifications=(atoi(val)>0)?TRUE:FALSE;
1198
else if(!strcmp(var,"notifications_enabled"))
1199
temp_servicestatus->notifications_enabled=(atoi(val)>0)?TRUE:FALSE;
1200
else if(!strcmp(var,"active_checks_enabled"))
1201
temp_servicestatus->checks_enabled=(atoi(val)>0)?TRUE:FALSE;
1202
else if(!strcmp(var,"passive_checks_enabled"))
1203
temp_servicestatus->accept_passive_service_checks=(atoi(val)>0)?TRUE:FALSE;
1204
else if(!strcmp(var,"event_handler_enabled"))
1205
temp_servicestatus->event_handler_enabled=(atoi(val)>0)?TRUE:FALSE;
1206
else if(!strcmp(var,"problem_has_been_acknowledged"))
1207
temp_servicestatus->problem_has_been_acknowledged=(atoi(val)>0)?TRUE:FALSE;
1208
else if(!strcmp(var,"acknowledgement_type"))
1209
temp_servicestatus->acknowledgement_type=atoi(val);
1210
else if(!strcmp(var,"flap_detection_enabled"))
1211
temp_servicestatus->flap_detection_enabled=(atoi(val)>0)?TRUE:FALSE;
1212
else if(!strcmp(var,"failure_prediction_enabled"))
1213
temp_servicestatus->failure_prediction_enabled=(atoi(val)>0)?TRUE:FALSE;
1214
else if(!strcmp(var,"process_performance_data"))
1215
temp_servicestatus->process_performance_data=(atoi(val)>0)?TRUE:FALSE;
1216
else if(!strcmp(var,"obsess_over_service"))
1217
temp_servicestatus->obsess_over_service=(atoi(val)>0)?TRUE:FALSE;
1218
else if(!strcmp(var,"last_update"))
1219
temp_servicestatus->last_update=strtoul(val,NULL,10);
1220
else if(!strcmp(var,"is_flapping"))
1221
temp_servicestatus->is_flapping=(atoi(val)>0)?TRUE:FALSE;
1222
else if(!strcmp(var,"percent_state_change"))
1223
temp_servicestatus->percent_state_change=strtod(val,NULL);
1224
else if(!strcmp(var,"scheduled_downtime_depth"))
1225
temp_servicestatus->scheduled_downtime_depth=atoi(val);
1227
else if(!strcmp(var,"state_history")){
1229
for(x=0;x<MAX_STATE_HISTORY_ENTRIES;x++)
1230
temp_servicestatus->state_history[x]=atoi(my_strsep(&temp_ptr,","));
1231
temp_servicestatus->state_history_index=0;
1237
case XSDDEFAULT_CONTACTSTATUS_DATA:
1241
case XSDDEFAULT_HOSTCOMMENT_DATA:
1242
case XSDDEFAULT_SERVICECOMMENT_DATA:
1243
if(!strcmp(var,"host_name"))
1244
host_name=(char *)strdup(val);
1245
else if(!strcmp(var,"service_description"))
1246
service_description=(char *)strdup(val);
1247
else if(!strcmp(var,"entry_type"))
1248
entry_type=atoi(val);
1249
else if(!strcmp(var,"comment_id"))
1250
comment_id=strtoul(val,NULL,10);
1251
else if(!strcmp(var,"source"))
1253
else if(!strcmp(var,"persistent"))
1254
persistent=(atoi(val)>0)?TRUE:FALSE;
1255
else if(!strcmp(var,"entry_time"))
1256
entry_time=strtoul(val,NULL,10);
1257
else if(!strcmp(var,"expires"))
1258
expires=(atoi(val)>0)?TRUE:FALSE;
1259
else if(!strcmp(var,"expire_time"))
1260
expire_time=strtoul(val,NULL,10);
1261
else if(!strcmp(var,"author"))
1262
author=(char *)strdup(val);
1263
else if(!strcmp(var,"comment_data"))
1264
comment_data=(char *)strdup(val);
1267
case XSDDEFAULT_HOSTDOWNTIME_DATA:
1268
case XSDDEFAULT_SERVICEDOWNTIME_DATA:
1269
if(!strcmp(var,"host_name"))
1270
host_name=(char *)strdup(val);
1271
else if(!strcmp(var,"service_description"))
1272
service_description=(char *)strdup(val);
1273
else if(!strcmp(var,"downtime_id"))
1274
downtime_id=strtoul(val,NULL,10);
1275
else if(!strcmp(var,"entry_time"))
1276
entry_time=strtoul(val,NULL,10);
1277
else if(!strcmp(var,"start_time"))
1278
start_time=strtoul(val,NULL,10);
1279
else if(!strcmp(var,"end_time"))
1280
end_time=strtoul(val,NULL,10);
1281
else if(!strcmp(var,"fixed"))
1282
fixed=(atoi(val)>0)?TRUE:FALSE;
1283
else if(!strcmp(var,"triggered_by"))
1284
triggered_by=strtoul(val,NULL,10);
1285
else if(!strcmp(var,"duration"))
1286
duration=strtoul(val,NULL,10);
1287
else if(!strcmp(var,"author"))
1288
author=(char *)strdup(val);
1289
else if(!strcmp(var,"comment"))
1290
comment_data=(char *)strdup(val);
1018
case XSDDEFAULT_HOSTSTATUS_DATA:
1019
/* NOTE: some vars are not read, as they are not used by the CGIs (modified attributes, event handler commands, etc.) */
1020
if(temp_hoststatus != NULL) {
1021
if(!strcmp(var, "host_name"))
1022
temp_hoststatus->host_name = (char *)strdup(val);
1023
else if(!strcmp(var, "has_been_checked"))
1024
temp_hoststatus->has_been_checked = (atoi(val) > 0) ? TRUE : FALSE;
1025
else if(!strcmp(var, "should_be_scheduled"))
1026
temp_hoststatus->should_be_scheduled = (atoi(val) > 0) ? TRUE : FALSE;
1027
else if(!strcmp(var, "check_execution_time"))
1028
temp_hoststatus->execution_time = strtod(val, NULL);
1029
else if(!strcmp(var, "check_latency"))
1030
temp_hoststatus->latency = strtod(val, NULL);
1031
else if(!strcmp(var, "check_type"))
1032
temp_hoststatus->check_type = atoi(val);
1033
else if(!strcmp(var, "current_state"))
1034
temp_hoststatus->status = atoi(val);
1035
else if(!strcmp(var, "last_hard_state"))
1036
temp_hoststatus->last_hard_state = atoi(val);
1037
else if(!strcmp(var, "plugin_output")) {
1038
temp_hoststatus->plugin_output = (char *)strdup(val);
1039
unescape_newlines(temp_hoststatus->plugin_output);
1041
else if(!strcmp(var, "long_plugin_output")) {
1042
temp_hoststatus->long_plugin_output = (char *)strdup(val);
1043
unescape_newlines(temp_hoststatus->long_plugin_output);
1045
else if(!strcmp(var, "performance_data"))
1046
temp_hoststatus->perf_data = (char *)strdup(val);
1047
else if(!strcmp(var, "current_attempt"))
1048
temp_hoststatus->current_attempt = atoi(val);
1049
else if(!strcmp(var, "max_attempts"))
1050
temp_hoststatus->max_attempts = atoi(val);
1051
else if(!strcmp(var, "last_check"))
1052
temp_hoststatus->last_check = strtoul(val, NULL, 10);
1053
else if(!strcmp(var, "next_check"))
1054
temp_hoststatus->next_check = strtoul(val, NULL, 10);
1055
else if(!strcmp(var, "check_options"))
1056
temp_hoststatus->check_options = atoi(val);
1057
else if(!strcmp(var, "current_attempt"))
1058
temp_hoststatus->current_attempt = (atoi(val) > 0) ? TRUE : FALSE;
1059
else if(!strcmp(var, "state_type"))
1060
temp_hoststatus->state_type = atoi(val);
1061
else if(!strcmp(var, "last_state_change"))
1062
temp_hoststatus->last_state_change = strtoul(val, NULL, 10);
1063
else if(!strcmp(var, "last_hard_state_change"))
1064
temp_hoststatus->last_hard_state_change = strtoul(val, NULL, 10);
1065
else if(!strcmp(var, "last_time_up"))
1066
temp_hoststatus->last_time_up = strtoul(val, NULL, 10);
1067
else if(!strcmp(var, "last_time_down"))
1068
temp_hoststatus->last_time_down = strtoul(val, NULL, 10);
1069
else if(!strcmp(var, "last_time_unreachable"))
1070
temp_hoststatus->last_time_unreachable = strtoul(val, NULL, 10);
1071
else if(!strcmp(var, "last_notification"))
1072
temp_hoststatus->last_notification = strtoul(val, NULL, 10);
1073
else if(!strcmp(var, "next_notification"))
1074
temp_hoststatus->next_notification = strtoul(val, NULL, 10);
1075
else if(!strcmp(var, "no_more_notifications"))
1076
temp_hoststatus->no_more_notifications = (atoi(val) > 0) ? TRUE : FALSE;
1077
else if(!strcmp(var, "current_notification_number"))
1078
temp_hoststatus->current_notification_number = atoi(val);
1079
else if(!strcmp(var, "notifications_enabled"))
1080
temp_hoststatus->notifications_enabled = (atoi(val) > 0) ? TRUE : FALSE;
1081
else if(!strcmp(var, "problem_has_been_acknowledged"))
1082
temp_hoststatus->problem_has_been_acknowledged = (atoi(val) > 0) ? TRUE : FALSE;
1083
else if(!strcmp(var, "acknowledgement_type"))
1084
temp_hoststatus->acknowledgement_type = atoi(val);
1085
else if(!strcmp(var, "active_checks_enabled"))
1086
temp_hoststatus->checks_enabled = (atoi(val) > 0) ? TRUE : FALSE;
1087
else if(!strcmp(var, "passive_checks_enabled"))
1088
temp_hoststatus->accept_passive_host_checks = (atoi(val) > 0) ? TRUE : FALSE;
1089
else if(!strcmp(var, "event_handler_enabled"))
1090
temp_hoststatus->event_handler_enabled = (atoi(val) > 0) ? TRUE : FALSE;
1091
else if(!strcmp(var, "flap_detection_enabled"))
1092
temp_hoststatus->flap_detection_enabled = (atoi(val) > 0) ? TRUE : FALSE;
1093
else if(!strcmp(var, "failure_prediction_enabled"))
1094
temp_hoststatus->failure_prediction_enabled = (atoi(val) > 0) ? TRUE : FALSE;
1095
else if(!strcmp(var, "process_performance_data"))
1096
temp_hoststatus->process_performance_data = (atoi(val) > 0) ? TRUE : FALSE;
1097
else if(!strcmp(var, "obsess_over_host"))
1098
temp_hoststatus->obsess_over_host = (atoi(val) > 0) ? TRUE : FALSE;
1099
else if(!strcmp(var, "last_update"))
1100
temp_hoststatus->last_update = strtoul(val, NULL, 10);
1101
else if(!strcmp(var, "is_flapping"))
1102
temp_hoststatus->is_flapping = (atoi(val) > 0) ? TRUE : FALSE;
1103
else if(!strcmp(var, "percent_state_change"))
1104
temp_hoststatus->percent_state_change = strtod(val, NULL);
1105
else if(!strcmp(var, "scheduled_downtime_depth"))
1106
temp_hoststatus->scheduled_downtime_depth = atoi(val);
1108
else if(!strcmp(var,"state_history")){
1110
for(x=0;x<MAX_STATE_HISTORY_ENTRIES;x++)
1111
temp_hoststatus->state_history[x]=atoi(my_strsep(&temp_ptr,","));
1112
temp_hoststatus->state_history_index=0;
1118
case XSDDEFAULT_SERVICESTATUS_DATA:
1119
/* NOTE: some vars are not read, as they are not used by the CGIs (modified attributes, event handler commands, etc.) */
1120
if(temp_servicestatus != NULL) {
1121
if(!strcmp(var, "host_name"))
1122
temp_servicestatus->host_name = (char *)strdup(val);
1123
else if(!strcmp(var, "service_description"))
1124
temp_servicestatus->description = (char *)strdup(val);
1125
else if(!strcmp(var, "has_been_checked"))
1126
temp_servicestatus->has_been_checked = (atoi(val) > 0) ? TRUE : FALSE;
1127
else if(!strcmp(var, "should_be_scheduled"))
1128
temp_servicestatus->should_be_scheduled = (atoi(val) > 0) ? TRUE : FALSE;
1129
else if(!strcmp(var, "check_execution_time"))
1130
temp_servicestatus->execution_time = strtod(val, NULL);
1131
else if(!strcmp(var, "check_latency"))
1132
temp_servicestatus->latency = strtod(val, NULL);
1133
else if(!strcmp(var, "check_type"))
1134
temp_servicestatus->check_type = atoi(val);
1135
else if(!strcmp(var, "current_state"))
1136
temp_servicestatus->status = atoi(val);
1137
else if(!strcmp(var, "last_hard_state"))
1138
temp_servicestatus->last_hard_state = atoi(val);
1139
else if(!strcmp(var, "current_attempt"))
1140
temp_servicestatus->current_attempt = atoi(val);
1141
else if(!strcmp(var, "max_attempts"))
1142
temp_servicestatus->max_attempts = atoi(val);
1143
else if(!strcmp(var, "state_type"))
1144
temp_servicestatus->state_type = atoi(val);
1145
else if(!strcmp(var, "last_state_change"))
1146
temp_servicestatus->last_state_change = strtoul(val, NULL, 10);
1147
else if(!strcmp(var, "last_hard_state_change"))
1148
temp_servicestatus->last_hard_state_change = strtoul(val, NULL, 10);
1149
else if(!strcmp(var, "last_time_ok"))
1150
temp_servicestatus->last_time_ok = strtoul(val, NULL, 10);
1151
else if(!strcmp(var, "last_time_warning"))
1152
temp_servicestatus->last_time_warning = strtoul(val, NULL, 10);
1153
else if(!strcmp(var, "last_time_unknown"))
1154
temp_servicestatus->last_time_unknown = strtoul(val, NULL, 10);
1155
else if(!strcmp(var, "last_time_critical"))
1156
temp_servicestatus->last_time_critical = strtoul(val, NULL, 10);
1157
else if(!strcmp(var, "plugin_output")) {
1158
temp_servicestatus->plugin_output = (char *)strdup(val);
1159
unescape_newlines(temp_servicestatus->plugin_output);
1161
else if(!strcmp(var, "long_plugin_output")) {
1162
temp_servicestatus->long_plugin_output = (char *)strdup(val);
1163
unescape_newlines(temp_servicestatus->long_plugin_output);
1165
else if(!strcmp(var, "performance_data"))
1166
temp_servicestatus->perf_data = (char *)strdup(val);
1167
else if(!strcmp(var, "last_check"))
1168
temp_servicestatus->last_check = strtoul(val, NULL, 10);
1169
else if(!strcmp(var, "next_check"))
1170
temp_servicestatus->next_check = strtoul(val, NULL, 10);
1171
else if(!strcmp(var, "check_options"))
1172
temp_servicestatus->check_options = atoi(val);
1173
else if(!strcmp(var, "current_notification_number"))
1174
temp_servicestatus->current_notification_number = atoi(val);
1175
else if(!strcmp(var, "last_notification"))
1176
temp_servicestatus->last_notification = strtoul(val, NULL, 10);
1177
else if(!strcmp(var, "next_notification"))
1178
temp_servicestatus->next_notification = strtoul(val, NULL, 10);
1179
else if(!strcmp(var, "no_more_notifications"))
1180
temp_servicestatus->no_more_notifications = (atoi(val) > 0) ? TRUE : FALSE;
1181
else if(!strcmp(var, "notifications_enabled"))
1182
temp_servicestatus->notifications_enabled = (atoi(val) > 0) ? TRUE : FALSE;
1183
else if(!strcmp(var, "active_checks_enabled"))
1184
temp_servicestatus->checks_enabled = (atoi(val) > 0) ? TRUE : FALSE;
1185
else if(!strcmp(var, "passive_checks_enabled"))
1186
temp_servicestatus->accept_passive_service_checks = (atoi(val) > 0) ? TRUE : FALSE;
1187
else if(!strcmp(var, "event_handler_enabled"))
1188
temp_servicestatus->event_handler_enabled = (atoi(val) > 0) ? TRUE : FALSE;
1189
else if(!strcmp(var, "problem_has_been_acknowledged"))
1190
temp_servicestatus->problem_has_been_acknowledged = (atoi(val) > 0) ? TRUE : FALSE;
1191
else if(!strcmp(var, "acknowledgement_type"))
1192
temp_servicestatus->acknowledgement_type = atoi(val);
1193
else if(!strcmp(var, "flap_detection_enabled"))
1194
temp_servicestatus->flap_detection_enabled = (atoi(val) > 0) ? TRUE : FALSE;
1195
else if(!strcmp(var, "failure_prediction_enabled"))
1196
temp_servicestatus->failure_prediction_enabled = (atoi(val) > 0) ? TRUE : FALSE;
1197
else if(!strcmp(var, "process_performance_data"))
1198
temp_servicestatus->process_performance_data = (atoi(val) > 0) ? TRUE : FALSE;
1199
else if(!strcmp(var, "obsess_over_service"))
1200
temp_servicestatus->obsess_over_service = (atoi(val) > 0) ? TRUE : FALSE;
1201
else if(!strcmp(var, "last_update"))
1202
temp_servicestatus->last_update = strtoul(val, NULL, 10);
1203
else if(!strcmp(var, "is_flapping"))
1204
temp_servicestatus->is_flapping = (atoi(val) > 0) ? TRUE : FALSE;
1205
else if(!strcmp(var, "percent_state_change"))
1206
temp_servicestatus->percent_state_change = strtod(val, NULL);
1207
else if(!strcmp(var, "scheduled_downtime_depth"))
1208
temp_servicestatus->scheduled_downtime_depth = atoi(val);
1210
else if(!strcmp(var,"state_history")){
1212
for(x=0;x<MAX_STATE_HISTORY_ENTRIES;x++)
1213
temp_servicestatus->state_history[x]=atoi(my_strsep(&temp_ptr,","));
1214
temp_servicestatus->state_history_index=0;
1220
case XSDDEFAULT_CONTACTSTATUS_DATA:
1224
case XSDDEFAULT_HOSTCOMMENT_DATA:
1225
case XSDDEFAULT_SERVICECOMMENT_DATA:
1226
if(!strcmp(var, "host_name"))
1227
host_name = (char *)strdup(val);
1228
else if(!strcmp(var, "service_description"))
1229
service_description = (char *)strdup(val);
1230
else if(!strcmp(var, "entry_type"))
1231
entry_type = atoi(val);
1232
else if(!strcmp(var, "comment_id"))
1233
comment_id = strtoul(val, NULL, 10);
1234
else if(!strcmp(var, "source"))
1236
else if(!strcmp(var, "persistent"))
1237
persistent = (atoi(val) > 0) ? TRUE : FALSE;
1238
else if(!strcmp(var, "entry_time"))
1239
entry_time = strtoul(val, NULL, 10);
1240
else if(!strcmp(var, "expires"))
1241
expires = (atoi(val) > 0) ? TRUE : FALSE;
1242
else if(!strcmp(var, "expire_time"))
1243
expire_time = strtoul(val, NULL, 10);
1244
else if(!strcmp(var, "author"))
1245
author = (char *)strdup(val);
1246
else if(!strcmp(var, "comment_data"))
1247
comment_data = (char *)strdup(val);
1250
case XSDDEFAULT_HOSTDOWNTIME_DATA:
1251
case XSDDEFAULT_SERVICEDOWNTIME_DATA:
1252
if(!strcmp(var, "host_name"))
1253
host_name = (char *)strdup(val);
1254
else if(!strcmp(var, "service_description"))
1255
service_description = (char *)strdup(val);
1256
else if(!strcmp(var, "downtime_id"))
1257
downtime_id = strtoul(val, NULL, 10);
1258
else if(!strcmp(var, "entry_time"))
1259
entry_time = strtoul(val, NULL, 10);
1260
else if(!strcmp(var, "start_time"))
1261
start_time = strtoul(val, NULL, 10);
1262
else if(!strcmp(var, "end_time"))
1263
end_time = strtoul(val, NULL, 10);
1264
else if(!strcmp(var, "fixed"))
1265
fixed = (atoi(val) > 0) ? TRUE : FALSE;
1266
else if(!strcmp(var, "triggered_by"))
1267
triggered_by = strtoul(val, NULL, 10);
1268
else if(!strcmp(var, "duration"))
1269
duration = strtoul(val, NULL, 10);
1270
else if(!strcmp(var, "is_in_effect"))
1271
is_in_effect = (atoi(val) > 0) ? TRUE : FALSE;
1272
else if(!strcmp(var, "author"))
1273
author = (char *)strdup(val);
1274
else if(!strcmp(var, "comment"))
1275
comment_data = (char *)strdup(val);
1300
1285
/* free memory and close the file */