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;
69 	int obsess_over_service;
70 	int obsess_over_host;
71 	time_t last_update;
72 	int is_flapping;
73 	char * performance_data;
74 	char * check_command;
75 	int last_time_up;
76 	int last_time_down;
77 	int last_time_unreachable;
78 	/* newly added in 3.0 */
79 	char *author;
80 	double check_interval;
81 	int check_options;
82 	char *check_period;
83 	char *comment_data;
84 	int comment_id;
85 	int current_event_id;
86 	int current_notification_id;
87 	int current_problem_id;
88 	time_t entry_time;
89 	int entry_type;
90 	int expires;
91 	time_t expire_time;
92 	char *host_notification_period;
93 	int last_event_id;
94 	int last_problem_id;
95 	char *long_plugin_output;
96 	int next_comment_id;
97 	char *notification_period;
98 	int persistent;
99 	double retry_interval;
100 	char *service_notification_period;
101 	int source;
102 	int downtime_id;
103 	time_t start_time, end_time;
104 	int triggered_by;
105 	int fixed;
106 	int duration;
107 	char *comment;
108 };
109 
110 void parse_1_0_statuslog(int fd, struct stats **pstats, int *n_stats);
111 void parse_2_0_statuslog(int fd, struct stats **pstats, int *n_stats);
112 void free_stats_array(struct stats *pstats, int n_stats);
113 void sort_stats_array(struct stats *pstats, int n_stats);
114 int host_is_down(struct stats *pstats, int n_stats, char *host_name);
115 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);
116 int find_index_by_host_and_service(struct stats *pstats, int n_stats, char *host_name, char *service_description);
117 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);
118 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);
119