00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef _OBJECTS_H
00027 #define _OBJECTS_H
00028
00029 #include "config.h"
00030 #include "common.h"
00031
00032 #ifdef __cplusplus
00033 extern "C" {
00034 #endif
00035
00036
00037
00038
00039
00040 #define CURRENT_OBJECT_STRUCTURE_VERSION 2
00041
00042
00043
00044
00045
00046 #define MAX_HOSTNAME_LENGTH 64
00047 #define MAX_SERVICEDESC_LENGTH 64
00048 #define MAX_PLUGINOUTPUT_LENGTH 332
00049
00050 #define MAX_STATE_HISTORY_ENTRIES 21
00051
00052 #define MAX_CONTACT_ADDRESSES 6
00053
00054
00055
00056
00057
00058 #define SERVICE_HASHSLOTS 1024
00059 #define HOST_HASHSLOTS 1024
00060 #define COMMAND_HASHSLOTS 256
00061 #define TIMEPERIOD_HASHSLOTS 64
00062 #define CONTACT_HASHSLOTS 128
00063 #define CONTACTGROUP_HASHSLOTS 64
00064 #define HOSTGROUP_HASHSLOTS 128
00065 #define SERVICEGROUP_HASHSLOTS 128
00066 #define HOSTEXTINFO_HASHSLOTS 1024
00067 #define SERVICEEXTINFO_HASHSLOTS 1024
00068
00069 #define HOSTDEPENDENCY_HASHSLOTS 1024
00070 #define SERVICEDEPENDENCY_HASHSLOTS 1024
00071 #define HOSTESCALATION_HASHSLOTS 1024
00072 #define SERVICEESCALATION_HASHSLOTS 1024
00073
00074
00075
00076
00077
00078
00079 typedef struct timerange_struct{
00080 unsigned long range_start;
00081 unsigned long range_end;
00082 struct timerange_struct *next;
00083 }timerange;
00084
00085
00086
00087 typedef struct timeperiod_struct{
00088 char *name;
00089 char *alias;
00090 timerange *days[7];
00091 struct timeperiod_struct *next;
00092 struct timeperiod_struct *nexthash;
00093 }timeperiod;
00094
00095
00096
00097 typedef struct contactgroupmember_struct{
00098 char *contact_name;
00099 struct contactgroupmember_struct *next;
00100 }contactgroupmember;
00101
00102
00103
00104 typedef struct contactgroup_struct{
00105 char *group_name;
00106 char *alias;
00107 contactgroupmember *members;
00108 struct contactgroup_struct *next;
00109 struct contactgroup_struct *nexthash;
00110 }contactgroup;
00111
00112
00113
00114 typedef struct contactgroupsmember_struct{
00115 char *group_name;
00116 struct contactgroupsmember_struct *next;
00117 }contactgroupsmember;
00118
00119
00120
00121 typedef struct hostsmember_struct{
00122 char *host_name;
00123 struct hostsmember_struct *next;
00124 }hostsmember;
00125
00126
00127
00128 typedef struct host_struct{
00129 char *name;
00130 char *alias;
00131 char *address;
00132 hostsmember *parent_hosts;
00133 char *host_check_command;
00134 int check_interval;
00135 int max_attempts;
00136 char *event_handler;
00137 contactgroupsmember *contact_groups;
00138 int notification_interval;
00139 int notify_on_down;
00140 int notify_on_unreachable;
00141 int notify_on_recovery;
00142 int notify_on_flapping;
00143 char *notification_period;
00144 char *check_period;
00145 int flap_detection_enabled;
00146 double low_flap_threshold;
00147 double high_flap_threshold;
00148 int stalk_on_up;
00149 int stalk_on_down;
00150 int stalk_on_unreachable;
00151 int check_freshness;
00152 int freshness_threshold;
00153 int process_performance_data;
00154 int checks_enabled;
00155 int accept_passive_host_checks;
00156 int event_handler_enabled;
00157 int retain_status_information;
00158 int retain_nonstatus_information;
00159 int failure_prediction_enabled;
00160 char *failure_prediction_options;
00161 int obsess_over_host;
00162 #ifdef NSCORE
00163 int problem_has_been_acknowledged;
00164 int acknowledgement_type;
00165 int check_type;
00166 int current_state;
00167 int last_state;
00168 int last_hard_state;
00169 char *plugin_output;
00170 char *perf_data;
00171 int state_type;
00172 int current_attempt;
00173 double latency;
00174 double execution_time;
00175 int check_options;
00176 int notifications_enabled;
00177 time_t last_host_notification;
00178 time_t next_host_notification;
00179 time_t next_check;
00180 int should_be_scheduled;
00181 time_t last_check;
00182 time_t last_state_change;
00183 time_t last_hard_state_change;
00184 time_t last_time_up;
00185 time_t last_time_down;
00186 time_t last_time_unreachable;
00187 int has_been_checked;
00188 int is_being_freshened;
00189 int notified_on_down;
00190 int notified_on_unreachable;
00191 int current_notification_number;
00192 int no_more_notifications;
00193 int check_flapping_recovery_notification;
00194 int scheduled_downtime_depth;
00195 int pending_flex_downtime;
00196 int state_history[MAX_STATE_HISTORY_ENTRIES];
00197 int state_history_index;
00198 time_t last_state_history_update;
00199 int is_flapping;
00200 unsigned long flapping_comment_id;
00201 double percent_state_change;
00202 int total_services;
00203 unsigned long total_service_check_interval;
00204 unsigned long modified_attributes;
00205 int circular_path_checked;
00206 int contains_circular_path;
00207 #endif
00208 struct host_struct *next;
00209 struct host_struct *nexthash;
00210 }host;
00211
00212
00213
00214 typedef struct hostgroupmember_struct{
00215 char *host_name;
00216 struct hostgroupmember_struct *next;
00217 }hostgroupmember;
00218
00219
00220
00221 typedef struct hostgroup_struct{
00222 char *group_name;
00223 char *alias;
00224 hostgroupmember *members;
00225 struct hostgroup_struct *next;
00226 struct hostgroup_struct *nexthash;
00227 }hostgroup;
00228
00229
00230
00231 typedef struct servicegroupmember_struct{
00232 char *host_name;
00233 char *service_description;
00234 struct servicegroupmember_struct *next;
00235 }servicegroupmember;
00236
00237
00238
00239 typedef struct servicegroup_struct{
00240 char *group_name;
00241 char *alias;
00242 double sla_target;
00243 servicegroupmember *members;
00244 struct servicegroup_struct *next;
00245 struct servicegroup_struct *nexthash;
00246 }servicegroup;
00247
00248
00249
00250 typedef struct commandsmember_struct{
00251 char *command;
00252 struct commandsmember_struct *next;
00253 }commandsmember;
00254
00255
00256
00257 typedef struct contact_struct{
00258 char *name;
00259 char *alias;
00260 char *email;
00261 char *pager;
00262 char *address[MAX_CONTACT_ADDRESSES];
00263 commandsmember *host_notification_commands;
00264 commandsmember *service_notification_commands;
00265 int notify_on_service_unknown;
00266 int notify_on_service_warning;
00267 int notify_on_service_critical;
00268 int notify_on_service_recovery;
00269 int notify_on_service_flapping;
00270 int notify_on_host_down;
00271 int notify_on_host_unreachable;
00272 int notify_on_host_recovery;
00273 int notify_on_host_flapping;
00274 char *host_notification_period;
00275 char *service_notification_period;
00276 struct contact_struct *next;
00277 struct contact_struct *nexthash;
00278 }contact;
00279
00280
00281
00282
00283 typedef struct service_struct{
00284 char *host_name;
00285 char *description;
00286 char *service_check_command;
00287 char *event_handler;
00288 int check_interval;
00289 int retry_interval;
00290 int max_attempts;
00291 int parallelize;
00292 contactgroupsmember *contact_groups;
00293 int notification_interval;
00294 int notify_on_unknown;
00295 int notify_on_warning;
00296 int notify_on_critical;
00297 int notify_on_recovery;
00298 int notify_on_flapping;
00299 int stalk_on_ok;
00300 int stalk_on_warning;
00301 int stalk_on_unknown;
00302 int stalk_on_critical;
00303 int is_volatile;
00304 char *notification_period;
00305 char *check_period;
00306 int flap_detection_enabled;
00307 double low_flap_threshold;
00308 double high_flap_threshold;
00309 int process_performance_data;
00310 int check_freshness;
00311 int freshness_threshold;
00312 int accept_passive_service_checks;
00313 int event_handler_enabled;
00314 int checks_enabled;
00315 int retain_status_information;
00316 int retain_nonstatus_information;
00317 int notifications_enabled;
00318 int obsess_over_service;
00319 int failure_prediction_enabled;
00320 char *failure_prediction_options;
00321 #ifdef NSCORE
00322 int problem_has_been_acknowledged;
00323 int acknowledgement_type;
00324 int host_problem_at_last_check;
00325 #ifdef REMOVED_041403
00326 int no_recovery_notification;
00327 #endif
00328 int check_type;
00329 int current_state;
00330 int last_state;
00331 int last_hard_state;
00332 char *plugin_output;
00333 char *perf_data;
00334 int state_type;
00335 time_t next_check;
00336 int should_be_scheduled;
00337 time_t last_check;
00338 int current_attempt;
00339 time_t last_notification;
00340 time_t next_notification;
00341 int no_more_notifications;
00342 int check_flapping_recovery_notification;
00343 time_t last_state_change;
00344 time_t last_hard_state_change;
00345 time_t last_time_ok;
00346 time_t last_time_warning;
00347 time_t last_time_unknown;
00348 time_t last_time_critical;
00349 int has_been_checked;
00350 int is_being_freshened;
00351 int notified_on_unknown;
00352 int notified_on_warning;
00353 int notified_on_critical;
00354 int current_notification_number;
00355 double latency;
00356 double execution_time;
00357 int is_executing;
00358 int check_options;
00359 int scheduled_downtime_depth;
00360 int pending_flex_downtime;
00361 int state_history[MAX_STATE_HISTORY_ENTRIES];
00362 int state_history_index;
00363 int is_flapping;
00364 unsigned long flapping_comment_id;
00365 double percent_state_change;
00366 unsigned long modified_attributes;
00367 #endif
00368 struct service_struct *next;
00369 struct service_struct *nexthash;
00370 }service;
00371
00372
00373
00374 typedef struct command_struct{
00375 char *name;
00376 char *command_line;
00377 struct command_struct *next;
00378 struct command_struct *nexthash;
00379 }command;
00380
00381
00382
00383 typedef struct serviceescalation_struct{
00384 char *host_name;
00385 char *description;
00386 int first_notification;
00387 int last_notification;
00388 int notification_interval;
00389 char *escalation_period;
00390 int escalate_on_recovery;
00391 int escalate_on_warning;
00392 int escalate_on_unknown;
00393 int escalate_on_critical;
00394 contactgroupsmember *contact_groups;
00395 struct serviceescalation_struct *next;
00396 struct serviceescalation_struct *nexthash;
00397 }serviceescalation;
00398
00399
00400
00401 typedef struct servicedependency_struct{
00402 int dependency_type;
00403 char *dependent_host_name;
00404 char *dependent_service_description;
00405 char *host_name;
00406 char *service_description;
00407 int inherits_parent;
00408 int fail_on_ok;
00409 int fail_on_warning;
00410 int fail_on_unknown;
00411 int fail_on_critical;
00412 int fail_on_pending;
00413 #ifdef NSCORE
00414 int circular_path_checked;
00415 int contains_circular_path;
00416 #endif
00417 struct servicedependency_struct *next;
00418 struct servicedependency_struct *nexthash;
00419 }servicedependency;
00420
00421
00422
00423 typedef struct hostescalation_struct{
00424 char *host_name;
00425 int first_notification;
00426 int last_notification;
00427 int notification_interval;
00428 char *escalation_period;
00429 int escalate_on_recovery;
00430 int escalate_on_down;
00431 int escalate_on_unreachable;
00432 contactgroupsmember *contact_groups;
00433 struct hostescalation_struct *next;
00434 struct hostescalation_struct *nexthash;
00435 }hostescalation;
00436
00437
00438
00439 typedef struct hostdependency_struct{
00440 int dependency_type;
00441 char *dependent_host_name;
00442 char *host_name;
00443 int inherits_parent;
00444 int fail_on_up;
00445 int fail_on_down;
00446 int fail_on_unreachable;
00447 int fail_on_pending;
00448 #ifdef NSCORE
00449 int circular_path_checked;
00450 int contains_circular_path;
00451 #endif
00452 struct hostdependency_struct *next;
00453 struct hostdependency_struct *nexthash;
00454 }hostdependency;
00455
00456
00457
00458 typedef struct hostextinfo_struct{
00459 char *host_name;
00460 char *notes;
00461 char *notes_url;
00462 char *action_url;
00463 char *icon_image;
00464 char *vrml_image;
00465 char *statusmap_image;
00466 char *icon_image_alt;
00467 int have_2d_coords;
00468 int x_2d;
00469 int y_2d;
00470 int have_3d_coords;
00471 double x_3d;
00472 double y_3d;
00473 double z_3d;
00474 int should_be_drawn;
00475 struct hostextinfo_struct *next;
00476 struct hostextinfo_struct *nexthash;
00477 }hostextinfo;
00478
00479
00480
00481 typedef struct serviceextinfo_struct{
00482 char *host_name;
00483 char *description;
00484 char *notes;
00485 char *notes_url;
00486 char *action_url;
00487 char *icon_image;
00488 char *icon_image_alt;
00489 struct serviceextinfo_struct *next;
00490 struct serviceextinfo_struct *nexthash;
00491 }serviceextinfo;
00492
00493
00494
00495
00496
00497 typedef struct host_cursor_struct{
00498 int host_hashchain_iterator;
00499 host *current_host_pointer;
00500 }host_cursor;
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522 #if defined(DEBUG0) || defined(DEBUG1) || defined(DEBUG2) || defined(DEBUG3) || defined(DEBUG4) || defined(DEBUG5) || defined(DEBUG6) || defined(DEBUG7) || defined(DEBUG8) || defined(DEBUG9) || defined(DEBUG10) || defined(DEBUG11)
00523 #define dbg_print(args) dbg_print_x args
00524 #else
00525 #define dbg_print(args)
00526 #endif
00527
00528
00529
00530 int read_object_config_data(char *,int,int);
00531
00532
00533 contact *add_contact(char *,char *,char *,char *,char **,char *,char *,int,int,int,int,int,int,int,int,int);
00534 commandsmember *add_service_notification_command_to_contact(contact *,char *);
00535 commandsmember *add_host_notification_command_to_contact(contact *,char *);
00536 host *add_host(char *,char *,char *,char *,int,int,int,int,int,int,int,char *,int,char *,int,int,char *,int,int,double,double,int,int,int,int,int,char *,int,int,int,int,int);
00537 hostsmember *add_parent_host_to_host(host *,char *);
00538 contactgroupsmember *add_contactgroup_to_host(host *,char *);
00539 timeperiod *add_timeperiod(char *,char *);
00540 timerange *add_timerange_to_timeperiod(timeperiod *,int,unsigned long,unsigned long);
00541 hostgroup *add_hostgroup(char *,char *);
00542 hostgroupmember *add_host_to_hostgroup(hostgroup *, char *);
00543 servicegroup *add_servicegroup(char *,char *,double);
00544 servicegroupmember *add_service_to_servicegroup(servicegroup *,char *,char *);
00545 contactgroup *add_contactgroup(char *,char *);
00546 contactgroupmember *add_contact_to_contactgroup(contactgroup *,char *);
00547 command *add_command(char *,char *);
00548 service *add_service(char *,char *,char *,int,int,int,int,int,int,char *,int,int,int,int,int,int,int,char *,int,char *,int,int,double,double,int,int,int,int,int,int,char *,int,int,int,int,int);
00549 contactgroupsmember *add_contactgroup_to_service(service *,char *);
00550 serviceescalation *add_serviceescalation(char *,char *,int,int,int,char *,int,int,int,int);
00551 contactgroupsmember *add_contactgroup_to_serviceescalation(serviceescalation *,char *);
00552 servicedependency *add_service_dependency(char *,char *,char *,char *,int,int,int,int,int,int,int);
00553 hostdependency *add_host_dependency(char *,char *,int,int,int,int,int,int);
00554 hostescalation *add_hostescalation(char *,int,int,int,char *,int,int,int);
00555 contactgroupsmember *add_contactgroup_to_hostescalation(hostescalation *,char *);
00556 hostextinfo *add_hostextinfo(char *,char *,char *,char *,char *,char *,char *,char *,int,int,double,double,double,int,int);
00557 serviceextinfo *add_serviceextinfo(char *,char *,char *,char *,char *,char *,char *);
00558
00559
00560
00561 int add_host_to_hashlist(host *);
00562 int add_service_to_hashlist(service *);
00563 int add_command_to_hashlist(command *);
00564 int add_timeperiod_to_hashlist(timeperiod *);
00565 int add_contact_to_hashlist(contact *);
00566 int add_contactgroup_to_hashlist(contactgroup *);
00567 int add_hostgroup_to_hashlist(hostgroup *);
00568 int add_servicegroup_to_hashlist(servicegroup *);
00569 int add_hostdependency_to_hashlist(hostdependency *);
00570 int add_servicedependency_to_hashlist(servicedependency *);
00571 int add_hostescalation_to_hashlist(hostescalation *);
00572 int add_serviceescalation_to_hashlist(serviceescalation *);
00573 int add_hostextinfo_to_hashlist(hostextinfo *);
00574 int add_serviceextinfo_to_hashlist(serviceextinfo *);
00575
00576
00577
00578 timeperiod * find_timeperiod(char *);
00579 host * find_host(char *);
00580 hostgroup * find_hostgroup(char *);
00581 servicegroup * find_servicegroup(char *);
00582 contact * find_contact(char *);
00583 contactgroup * find_contactgroup(char *);
00584 contactgroupmember *find_contactgroupmember(char *,contactgroup *);
00585 command * find_command(char *);
00586 service * find_service(char *,char *);
00587 service * enum_services(char *,service *);
00588 hostextinfo *find_hostextinfo(char *);
00589 serviceextinfo *find_serviceextinfo(char *,char *);
00590
00591
00592
00593 void move_first_service(void);
00594 service *get_next_service(void);
00595 int find_all_services_by_host(char *);
00596 service *get_next_service_by_host(void);
00597 void move_first_host(void);
00598 host *get_next_host(void);
00599 void *get_host_cursor(void);
00600 host *get_next_host_cursor(void *v_cursor);
00601 void free_host_cursor(void *cursor);
00602 void *get_next_N(void **hashchain, int hashslots, int *iterator, void *current, void *next);
00603
00604 hostescalation *get_first_hostescalation_by_host(char *);
00605 hostescalation *get_next_hostescalation_by_host(char *,hostescalation *);
00606 serviceescalation *get_first_serviceescalation_by_service(char *,char *);
00607 serviceescalation *get_next_serviceescalation_by_service(char *,char *,serviceescalation *);
00608 hostdependency *get_first_hostdependency_by_dependent_host(char *);
00609 hostdependency *get_next_hostdependency_by_dependent_host(char *,hostdependency *);
00610 servicedependency *get_first_servicedependency_by_dependent_service(char *,char *);
00611 servicedependency *get_next_servicedependency_by_dependent_service(char *,char *,servicedependency *);
00612
00613
00614
00615
00616 int is_host_immediate_child_of_host(host *,host *);
00617 int is_host_primary_immediate_child_of_host(host *,host *);
00618 int is_host_immediate_parent_of_host(host *,host *);
00619 int is_host_member_of_hostgroup(hostgroup *,host *);
00620 int is_host_member_of_servicegroup(servicegroup *,host *);
00621 int is_service_member_of_servicegroup(servicegroup *,service *);
00622 int is_contact_member_of_contactgroup(contactgroup *, contact *);
00623 int is_contact_for_hostgroup(hostgroup *,contact *);
00624 int is_contact_for_servicegroup(servicegroup *,contact *);
00625 int is_contact_for_host(host *,contact *);
00626 int is_escalated_contact_for_host(host *,contact *);
00627 int is_contact_for_service(service *,contact *);
00628 int is_escalated_contact_for_service(service *,contact *);
00629 int is_host_immediate_parent_of_host(host *,host *);
00630
00631 int number_of_immediate_child_hosts(host *);
00632 int number_of_total_child_hosts(host *);
00633 int number_of_immediate_parent_hosts(host *);
00634 int number_of_total_parent_hosts(host *);
00635
00636 #ifdef NSCORE
00637 int check_for_circular_path(host *,host *);
00638 int check_for_circular_servicedependency(servicedependency *,servicedependency *,int);
00639 int check_for_circular_hostdependency(hostdependency *,hostdependency *,int);
00640 #endif
00641
00642
00643
00644 int free_object_data(void);
00645 int free_extended_data(void);
00646
00647 #ifdef __cplusplus
00648 }
00649 #endif
00650
00651 #endif