1 /*****************************************************************************
3 * STATUSDATA.H - Header for external status data routines
5 * Copyright (c) 2000-2007 Ethan Galstad (nagios@nagios.org)
6 * Last Modified: 10-19-2007
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *****************************************************************************/
38 #define READ_PROGRAM_STATUS 1
39 #define READ_HOST_STATUS 2
40 #define READ_SERVICE_STATUS 4
41 #define READ_CONTACT_STATUS 8
43 #define READ_ALL_STATUS_DATA READ_PROGRAM_STATUS | READ_HOST_STATUS | READ_SERVICE_STATUS | READ_CONTACT_STATUS
47 /*************************** CHAINED HASH LIMITS ***************************/
49 #define SERVICESTATUS_HASHSLOTS 1024
50 #define HOSTSTATUS_HASHSLOTS 1024
53 /**************************** DATA STRUCTURES ******************************/
56 /* HOST STATUS structure */
57 typedef struct hoststatus_struct
{
60 char *long_plugin_output
;
65 int should_be_scheduled
;
72 time_t last_state_change
;
73 time_t last_hard_state_change
;
76 time_t last_time_down
;
77 time_t last_time_unreachable
;
79 time_t last_notification
;
80 time_t next_notification
;
81 int no_more_notifications
;
82 int notifications_enabled
;
83 int problem_has_been_acknowledged
;
84 int acknowledgement_type
;
85 int current_notification_number
;
86 int accept_passive_host_checks
;
87 int event_handler_enabled
;
89 int flap_detection_enabled
;
91 double percent_state_change
;
93 double execution_time
;
94 int scheduled_downtime_depth
;
95 int failure_prediction_enabled
;
96 int process_performance_data
;
98 struct hoststatus_struct
*next
;
99 struct hoststatus_struct
*nexthash
;
103 /* SERVICE STATUS structure */
104 typedef struct servicestatus_struct
{
108 char *long_plugin_output
;
114 int has_been_checked
;
115 int should_be_scheduled
;
121 time_t last_state_change
;
122 time_t last_hard_state_change
;
125 time_t last_time_warning
;
126 time_t last_time_unknown
;
127 time_t last_time_critical
;
129 time_t last_notification
;
130 time_t next_notification
;
131 int no_more_notifications
;
132 int notifications_enabled
;
133 int problem_has_been_acknowledged
;
134 int acknowledgement_type
;
135 int current_notification_number
;
136 int accept_passive_service_checks
;
137 int event_handler_enabled
;
138 int flap_detection_enabled
;
140 double percent_state_change
;
142 double execution_time
;
143 int scheduled_downtime_depth
;
144 int failure_prediction_enabled
;
145 int process_performance_data
;
146 int obsess_over_service
;
147 struct servicestatus_struct
*next
;
148 struct servicestatus_struct
*nexthash
;
152 /*************************** SERVICE STATES ***************************/
154 #define SERVICE_PENDING 1
156 #define SERVICE_WARNING 4
157 #define SERVICE_UNKNOWN 8
158 #define SERVICE_CRITICAL 16
162 /**************************** HOST STATES ****************************/
164 #define HOST_PENDING 1
167 #define HOST_UNREACHABLE 8
171 /**************************** FUNCTIONS ******************************/
173 int read_status_data(char *,int); /* reads all status data */
174 int add_host_status(hoststatus
*); /* adds a host status entry to the list in memory */
175 int add_service_status(servicestatus
*); /* adds a service status entry to the list in memory */
177 int add_hoststatus_to_hashlist(hoststatus
*);
178 int add_servicestatus_to_hashlist(servicestatus
*);
180 servicestatus
*find_servicestatus(char *,char *); /* finds status information for a specific service */
181 hoststatus
*find_hoststatus(char *); /* finds status information for a specific host */
182 int get_servicestatus_count(char *,int); /* gets total number of services of a certain type for a specific host */
184 void free_status_data(void); /* free all memory allocated to status data */
188 int initialize_status_data(char *); /* initializes status data at program start */
189 int update_all_status_data(void); /* updates all status data */
190 int cleanup_status_data(char *,int); /* cleans up status data at program termination */
191 int update_program_status(int); /* updates program status data */
192 int update_host_status(host
*,int); /* updates host status data */
193 int update_service_status(service
*,int); /* updates service status data */
194 int update_contact_status(contact
*,int); /* updates contact status data */