1 /* (C) 2006-2010 by folkert@vanheusden.com GPLv2 applies */ 2 3 #define TYPE_IGNORE 0 4 #define TYPE_HOST 1 5 #define TYPE_SERVICE 2 6 7 #define V1_0_MAX_ELEMENTS 32 8 9 #define VARTYPE_PCHAR 0 10 #define VARTYPE_INT 1 11 #define VARTYPE_TIMET 2 12 #define VARTYPE_DOUBLE 3 13 14 #define STATS_OFFSET(x) (int)(offsetof(struct stats, x)) 15 16 #define ST_HARD 1 17 #define ST_SOFT 0 18 19 struct v2_0_config 20 { 21 char *str; 22 int offset; 23 int type; 24 }; 25 26 struct stats 27 { 28 int type; 29 30 char *host_name; 31 int current_state; 32 char *service_description; 33 char *plugin_output; 34 time_t last_state_change; 35 int active_checks_enabled; 36 int passive_checks_enabled; 37 int notifications_enabled; 38 int problem_has_been_acknowledged; 39 double scheduled_downtime_depth; 40 int state_type; 41 int last_hard_state; 42 double percent_state_change; 43 double check_execution_time; 44 double check_latency; 45 int modified_attributes; 46 int event_handler; 47 int has_been_checked; 48 int should_be_scheduled; 49 int current_attempt; 50 int max_attempts; 51 int last_hard_state_change; 52 int last_time_ok; 53 int last_time_warning; 54 int last_time_unknown; 55 int last_time_critical; 56 time_t last_check; 57 time_t next_check; 58 int check_type; 59 double current_notification_number; 60 int last_notification; 61 int next_notification; 62 int no_more_notifications; 63 int event_handler_enabled; 64 int acknowledgement_type; 65 int flap_detection_enabled; 66 int failure_prediction_enabled; 67 int process_performance_data; 68 int obsess_over_service; 69 int obsess_over_host; 70 time_t last_update; 71 int is_flapping; 72 char * performance_data; 73 char * check_command; 74 int last_time_up; 75 int last_time_down; 76 int last_time_unreachable; 77 /* newly added in 3.0 */ 78 char *author; 79 double check_interval; 80 int check_options; 81 char *check_period; 82 char *comment_data; 83 int comment_id; 84 int current_event_id; 85 int current_notification_id; 86 int current_problem_id; 87 time_t entry_time; 88 int entry_type; 89 int expires; 90 time_t expire_time; 91 char *host_notification_period; 92 int last_event_id; 93 int last_problem_id; 94 char *long_plugin_output; 95 int next_comment_id; 96 char *notification_period; 97 int persistent; 98 double retry_interval; 99 char *service_notification_period; 100 int source; 101 int downtime_id; 102 time_t start_time, end_time; 103 int triggered_by; 104 int fixed; 105 int duration; 106 char *comment; 107 }; 108 109 void parse_1_0_statuslog(int fd, struct stats **pstats, int *n_stats); 110 void parse_2_0_statuslog(int fd, struct stats **pstats, int *n_stats); 111 void free_stats_array(struct stats *pstats, int n_stats); 112 void sort_stats_array(struct stats *pstats, int n_stats); 113 int host_is_down(struct stats *pstats, int n_stats, char *host_name); 114 int should_i_show_entry(struct stats *pstats, int n_stats, int cur_index, char list_all_problems, char always_notify, char also_acknowledged, char hide_ok); 115 int find_index_by_host_and_service(struct stats *pstats, int n_stats, char *host_name, char *service_description); 116 int check_max_age_last_check(struct stats *pstats, int n_stats, int max_time_last_host_update, int max_time_oldest_host_update, int max_time_last_host_check, int max_time_oldest_host_check, int max_time_last_service_check, int max_time_oldest_service_check, int max_time_oldest_next_service_check, char **message); 117 void calc_stats_stats(struct stats *pstats, int n_stats, char list_all_problems, char always_notify, char also_acknowledged, char hide_ok, int *n_critical, int *n_warning, int *n_ok, int *n_up, int *n_down, int *n_unreachable, int *n_pending); 118