1 /***************************************************************************** 2 * 3 * OBJECTS.H - Header file for object addition/search functions 4 * 5 * Copyright (c) 1999-2007 Ethan Galstad (egalstad@nagios.org) 6 * Last Modified: 11-10-2007 7 * 8 * License: 9 * 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. 13 * 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. 18 * 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. 22 * 23 *****************************************************************************/ 24 25 26 #ifndef _OBJECTS_H 27 #define _OBJECTS_H 28 29 #include "compat.h" 30 #include "common.h" 31 32 NAGIOS_BEGIN_DECL 33 34 35 /*************** CURRENT OBJECT REVISION **************/ 36 37 #define CURRENT_OBJECT_STRUCTURE_VERSION 307 /* increment when changes are made to data structures... */ 38 /* Nagios 3 starts at 300, Nagios 4 at 400, etc. */ 39 40 41 42 /***************** OBJECT SIZE LIMITS *****************/ 43 44 #define MAX_STATE_HISTORY_ENTRIES 21 /* max number of old states to keep track of for flap detection */ 45 #define MAX_CONTACT_ADDRESSES 6 /* max number of custom addresses a contact can have */ 46 47 48 49 /***************** SKIP LISTS ****************/ 50 51 #define NUM_OBJECT_SKIPLISTS 12 52 53 #define HOST_SKIPLIST 0 54 #define SERVICE_SKIPLIST 1 55 #define COMMAND_SKIPLIST 2 56 #define TIMEPERIOD_SKIPLIST 3 57 #define CONTACT_SKIPLIST 4 58 #define CONTACTGROUP_SKIPLIST 5 59 #define HOSTGROUP_SKIPLIST 6 60 #define SERVICEGROUP_SKIPLIST 7 61 #define HOSTDEPENDENCY_SKIPLIST 8 62 #define SERVICEDEPENDENCY_SKIPLIST 9 63 #define HOSTESCALATION_SKIPLIST 10 64 #define SERVICEESCALATION_SKIPLIST 11 65 66 67 /****************** DATA STRUCTURES *******************/ 68 69 typedef struct host_struct host; 70 typedef struct service_struct service; 71 typedef struct contact_struct contact; 72 73 /* OBJECT LIST STRUCTURE */ 74 typedef struct objectlist_struct { 75 void *object_ptr; 76 struct objectlist_struct *next; 77 } objectlist; 78 79 80 /* TIMERANGE structure */ 81 typedef struct timerange_struct { 82 unsigned long range_start; 83 unsigned long range_end; 84 struct timerange_struct *next; 85 } timerange; 86 87 88 /* DATERANGE structure */ 89 typedef struct daterange_struct { 90 int type; 91 int syear; /* start year */ 92 int smon; /* start month */ 93 int smday; /* start day of month (may 3rd, last day in feb) */ 94 int swday; /* start day of week (thursday) */ 95 int swday_offset; /* start weekday offset (3rd thursday, last monday in jan) */ 96 int eyear; 97 int emon; 98 int emday; 99 int ewday; 100 int ewday_offset; 101 int skip_interval; 102 timerange *times; 103 struct daterange_struct *next; 104 } daterange; 105 106 107 /* TIMEPERIODEXCLUSION structure */ 108 typedef struct timeperiodexclusion_struct { 109 char *timeperiod_name; 110 struct timeperiod_struct *timeperiod_ptr; 111 struct timeperiodexclusion_struct *next; 112 } timeperiodexclusion; 113 114 115 /* TIMEPERIOD structure */ 116 typedef struct timeperiod_struct { 117 char *name; 118 char *alias; 119 timerange *days[7]; 120 daterange *exceptions[DATERANGE_TYPES]; 121 timeperiodexclusion *exclusions; 122 struct timeperiod_struct *next; 123 struct timeperiod_struct *nexthash; 124 } timeperiod; 125 126 127 /* CONTACTSMEMBER structure */ 128 typedef struct contactsmember_struct { 129 char *contact_name; 130 #ifdef NSCORE 131 contact *contact_ptr; 132 #endif 133 struct contactsmember_struct *next; 134 } contactsmember; 135 136 137 /* CONTACTGROUP structure */ 138 typedef struct contactgroup_struct { 139 char *group_name; 140 char *alias; 141 contactsmember *members; 142 struct contactgroup_struct *next; 143 struct contactgroup_struct *nexthash; 144 } contactgroup; 145 146 147 /* CONTACTGROUPSMEMBER structure */ 148 typedef struct contactgroupsmember_struct { 149 char *group_name; 150 #ifdef NSCORE 151 contactgroup *group_ptr; 152 #endif 153 struct contactgroupsmember_struct *next; 154 } contactgroupsmember; 155 156 157 /* CUSTOMVARIABLESMEMBER structure */ 158 typedef struct customvariablesmember_struct { 159 char *variable_name; 160 char *variable_value; 161 int has_been_modified; 162 struct customvariablesmember_struct *next; 163 } customvariablesmember; 164 165 166 /* COMMAND structure */ 167 typedef struct command_struct { 168 char *name; 169 char *command_line; 170 struct command_struct *next; 171 struct command_struct *nexthash; 172 } command; 173 174 175 /* COMMANDSMEMBER structure */ 176 typedef struct commandsmember_struct { 177 char *command; 178 #ifdef NSCORE 179 command *command_ptr; 180 #endif 181 struct commandsmember_struct *next; 182 } commandsmember; 183 184 185 /* CONTACT structure */ 186 struct contact_struct { 187 char *name; 188 char *alias; 189 char *email; 190 char *pager; 191 char *address[MAX_CONTACT_ADDRESSES]; 192 commandsmember *host_notification_commands; 193 commandsmember *service_notification_commands; 194 int notify_on_service_unknown; 195 int notify_on_service_warning; 196 int notify_on_service_critical; 197 int notify_on_service_recovery; 198 int notify_on_service_flapping; 199 int notify_on_service_downtime; 200 int notify_on_host_down; 201 int notify_on_host_unreachable; 202 int notify_on_host_recovery; 203 int notify_on_host_flapping; 204 int notify_on_host_downtime; 205 char *host_notification_period; 206 char *service_notification_period; 207 int host_notifications_enabled; 208 int service_notifications_enabled; 209 int can_submit_commands; 210 int retain_status_information; 211 int retain_nonstatus_information; 212 customvariablesmember *custom_variables; 213 #ifdef NSCORE 214 time_t last_host_notification; 215 time_t last_service_notification; 216 unsigned long modified_attributes; 217 unsigned long modified_host_attributes; 218 unsigned long modified_service_attributes; 219 220 timeperiod *host_notification_period_ptr; 221 timeperiod *service_notification_period_ptr; 222 objectlist *contactgroups_ptr; 223 #endif 224 struct contact_struct *next; 225 struct contact_struct *nexthash; 226 }; 227 228 229 /* SERVICESMEMBER structure */ 230 typedef struct servicesmember_struct { 231 char *host_name; 232 char *service_description; 233 #ifdef NSCORE 234 service *service_ptr; 235 #endif 236 struct servicesmember_struct *next; 237 } servicesmember; 238 239 240 /* HOSTSMEMBER structure */ 241 typedef struct hostsmember_struct { 242 char *host_name; 243 #ifdef NSCORE 244 host *host_ptr; 245 #endif 246 struct hostsmember_struct *next; 247 } hostsmember; 248 249 250 /* HOSTGROUP structure */ 251 typedef struct hostgroup_struct { 252 char *group_name; 253 char *alias; 254 hostsmember *members; 255 char *notes; 256 char *notes_url; 257 char *action_url; 258 struct hostgroup_struct *next; 259 struct hostgroup_struct *nexthash; 260 } hostgroup; 261 262 263 /* HOST structure */ 264 struct host_struct { 265 char *name; 266 char *display_name; 267 char *alias; 268 char *address; 269 hostsmember *parent_hosts; 270 hostsmember *child_hosts; 271 servicesmember *services; 272 char *host_check_command; 273 int initial_state; 274 double check_interval; 275 double retry_interval; 276 int max_attempts; 277 char *event_handler; 278 contactgroupsmember *contact_groups; 279 contactsmember *contacts; 280 double notification_interval; 281 double first_notification_delay; 282 int notify_on_down; 283 int notify_on_unreachable; 284 int notify_on_recovery; 285 int notify_on_flapping; 286 int notify_on_downtime; 287 char *notification_period; 288 char *check_period; 289 int flap_detection_enabled; 290 double low_flap_threshold; 291 double high_flap_threshold; 292 int flap_detection_on_up; 293 int flap_detection_on_down; 294 int flap_detection_on_unreachable; 295 int stalk_on_up; 296 int stalk_on_down; 297 int stalk_on_unreachable; 298 int check_freshness; 299 int freshness_threshold; 300 int process_performance_data; 301 int checks_enabled; 302 int accept_passive_host_checks; 303 int event_handler_enabled; 304 int retain_status_information; 305 int retain_nonstatus_information; 306 int failure_prediction_enabled; 307 char *failure_prediction_options; 308 int obsess_over_host; 309 char *notes; 310 char *notes_url; 311 char *action_url; 312 char *icon_image; 313 char *icon_image_alt; 314 char *vrml_image; 315 char *statusmap_image; 316 int have_2d_coords; 317 int x_2d; 318 int y_2d; 319 int have_3d_coords; 320 double x_3d; 321 double y_3d; 322 double z_3d; 323 int should_be_drawn; 324 customvariablesmember *custom_variables; 325 #ifdef NSCORE 326 int problem_has_been_acknowledged; 327 int acknowledgement_type; 328 int check_type; 329 int current_state; 330 int last_state; 331 int last_hard_state; 332 char *plugin_output; 333 char *long_plugin_output; 334 char *perf_data; 335 int state_type; 336 int current_attempt; 337 unsigned long current_event_id; 338 unsigned long last_event_id; 339 unsigned long current_problem_id; 340 unsigned long last_problem_id; 341 double latency; 342 double execution_time; 343 int is_executing; 344 int check_options; 345 int notifications_enabled; 346 time_t last_host_notification; 347 time_t next_host_notification; 348 time_t next_check; 349 int should_be_scheduled; 350 time_t last_check; 351 time_t last_state_change; 352 time_t last_hard_state_change; 353 time_t last_time_up; 354 time_t last_time_down; 355 time_t last_time_unreachable; 356 int has_been_checked; 357 int is_being_freshened; 358 int notified_on_down; 359 int notified_on_unreachable; 360 int current_notification_number; 361 int no_more_notifications; 362 unsigned long current_notification_id; 363 int check_flapping_recovery_notification; 364 int scheduled_downtime_depth; 365 int pending_flex_downtime; 366 int state_history[MAX_STATE_HISTORY_ENTRIES]; /* flap detection */ 367 int state_history_index; 368 time_t last_state_history_update; 369 int is_flapping; 370 unsigned long flapping_comment_id; 371 double percent_state_change; 372 int total_services; 373 unsigned long total_service_check_interval; 374 unsigned long modified_attributes; 375 int circular_path_checked; 376 int contains_circular_path; 377 378 command *event_handler_ptr; 379 command *check_command_ptr; 380 timeperiod *check_period_ptr; 381 timeperiod *notification_period_ptr; 382 objectlist *hostgroups_ptr; 383 #endif 384 struct host_struct *next; 385 void *next_check_event; 386 }; 387 388 389 /* SERVICEGROUP structure */ 390 typedef struct servicegroup_struct { 391 char *group_name; 392 char *alias; 393 servicesmember *members; 394 char *notes; 395 char *notes_url; 396 char *action_url; 397 struct servicegroup_struct *next; 398 struct servicegroup_struct *nexthash; 399 } servicegroup; 400 401 402 /* SERVICE structure */ 403 struct service_struct { 404 char *host_name; 405 char *description; 406 char *display_name; 407 char *service_check_command; 408 char *event_handler; 409 int initial_state; 410 double check_interval; 411 double retry_interval; 412 int max_attempts; 413 int parallelize; 414 contactgroupsmember *contact_groups; 415 contactsmember *contacts; 416 double notification_interval; 417 double first_notification_delay; 418 int notify_on_unknown; 419 int notify_on_warning; 420 int notify_on_critical; 421 int notify_on_recovery; 422 int notify_on_flapping; 423 int notify_on_downtime; 424 int stalk_on_ok; 425 int stalk_on_warning; 426 int stalk_on_unknown; 427 int stalk_on_critical; 428 int is_volatile; 429 char *notification_period; 430 char *check_period; 431 int flap_detection_enabled; 432 double low_flap_threshold; 433 double high_flap_threshold; 434 int flap_detection_on_ok; 435 int flap_detection_on_warning; 436 int flap_detection_on_unknown; 437 int flap_detection_on_critical; 438 int process_performance_data; 439 int check_freshness; 440 int freshness_threshold; 441 int accept_passive_service_checks; 442 int event_handler_enabled; 443 int checks_enabled; 444 int retain_status_information; 445 int retain_nonstatus_information; 446 int notifications_enabled; 447 int obsess_over_service; 448 int failure_prediction_enabled; 449 char *failure_prediction_options; 450 char *notes; 451 char *notes_url; 452 char *action_url; 453 char *icon_image; 454 char *icon_image_alt; 455 customvariablesmember *custom_variables; 456 #ifdef NSCORE 457 int problem_has_been_acknowledged; 458 int acknowledgement_type; 459 int host_problem_at_last_check; 460 int check_type; 461 int current_state; 462 int last_state; 463 int last_hard_state; 464 char *plugin_output; 465 char *long_plugin_output; 466 char *perf_data; 467 int state_type; 468 time_t next_check; 469 int should_be_scheduled; 470 time_t last_check; 471 int current_attempt; 472 unsigned long current_event_id; 473 unsigned long last_event_id; 474 unsigned long current_problem_id; 475 unsigned long last_problem_id; 476 time_t last_notification; 477 time_t next_notification; 478 int no_more_notifications; 479 int check_flapping_recovery_notification; 480 time_t last_state_change; 481 time_t last_hard_state_change; 482 time_t last_time_ok; 483 time_t last_time_warning; 484 time_t last_time_unknown; 485 time_t last_time_critical; 486 int has_been_checked; 487 int is_being_freshened; 488 int notified_on_unknown; 489 int notified_on_warning; 490 int notified_on_critical; 491 int current_notification_number; 492 unsigned long current_notification_id; 493 double latency; 494 double execution_time; 495 int is_executing; 496 int check_options; 497 int scheduled_downtime_depth; 498 int pending_flex_downtime; 499 int state_history[MAX_STATE_HISTORY_ENTRIES]; /* flap detection */ 500 int state_history_index; 501 int is_flapping; 502 unsigned long flapping_comment_id; 503 double percent_state_change; 504 unsigned long modified_attributes; 505 506 host *host_ptr; 507 command *event_handler_ptr; 508 char *event_handler_args; 509 command *check_command_ptr; 510 char *check_command_args; 511 timeperiod *check_period_ptr; 512 timeperiod *notification_period_ptr; 513 objectlist *servicegroups_ptr; 514 #endif 515 struct service_struct *next; 516 void *next_check_event; 517 }; 518 519 520 /* SERVICE ESCALATION structure */ 521 typedef struct serviceescalation_struct { 522 char *host_name; 523 char *description; 524 int first_notification; 525 int last_notification; 526 double notification_interval; 527 char *escalation_period; 528 int escalate_on_recovery; 529 int escalate_on_warning; 530 int escalate_on_unknown; 531 int escalate_on_critical; 532 contactgroupsmember *contact_groups; 533 contactsmember *contacts; 534 #ifdef NSCORE 535 service *service_ptr; 536 timeperiod *escalation_period_ptr; 537 #endif 538 struct serviceescalation_struct *next; 539 struct serviceescalation_struct *nexthash; 540 } serviceescalation; 541 542 543 /* SERVICE DEPENDENCY structure */ 544 typedef struct servicedependency_struct { 545 int dependency_type; 546 char *dependent_host_name; 547 char *dependent_service_description; 548 char *host_name; 549 char *service_description; 550 char *dependency_period; 551 int inherits_parent; 552 int fail_on_ok; 553 int fail_on_warning; 554 int fail_on_unknown; 555 int fail_on_critical; 556 int fail_on_pending; 557 #ifdef NSCORE 558 int circular_path_checked; 559 int contains_circular_path; 560 561 service *master_service_ptr; 562 service *dependent_service_ptr; 563 timeperiod *dependency_period_ptr; 564 #endif 565 struct servicedependency_struct *next; 566 struct servicedependency_struct *nexthash; 567 } servicedependency; 568 569 570 /* HOST ESCALATION structure */ 571 typedef struct hostescalation_struct { 572 char *host_name; 573 int first_notification; 574 int last_notification; 575 double notification_interval; 576 char *escalation_period; 577 int escalate_on_recovery; 578 int escalate_on_down; 579 int escalate_on_unreachable; 580 contactgroupsmember *contact_groups; 581 contactsmember *contacts; 582 #ifdef NSCORE 583 host *host_ptr; 584 timeperiod *escalation_period_ptr; 585 #endif 586 struct hostescalation_struct *next; 587 struct hostescalation_struct *nexthash; 588 } hostescalation; 589 590 591 /* HOST DEPENDENCY structure */ 592 typedef struct hostdependency_struct { 593 int dependency_type; 594 char *dependent_host_name; 595 char *host_name; 596 char *dependency_period; 597 int inherits_parent; 598 int fail_on_up; 599 int fail_on_down; 600 int fail_on_unreachable; 601 int fail_on_pending; 602 #ifdef NSCORE 603 int circular_path_checked; 604 int contains_circular_path; 605 606 host *master_host_ptr; 607 host *dependent_host_ptr; 608 timeperiod *dependency_period_ptr; 609 #endif 610 struct hostdependency_struct *next; 611 struct hostdependency_struct *nexthash; 612 } hostdependency; 613 614 615 616 617 /****************** HASH STRUCTURES ********************/ 618 619 typedef struct host_cursor_struct { 620 int host_hashchain_iterator; 621 host *current_host_pointer; 622 } host_cursor; 623 624 625 626 /********************* FUNCTIONS **********************/ 627 628 /**** Top-level input functions ****/ 629 int read_object_config_data(char *, int, int, int); /* reads all external configuration data of specific types */ 630 631 632 /**** Object Creation Functions ****/ 633 contact *add_contact(char *, char *, char *, char *, char **, char *, char *, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int); /* adds a contact definition */ 634 commandsmember *add_service_notification_command_to_contact(contact *, char *); /* adds a service notification command to a contact definition */ 635 commandsmember *add_host_notification_command_to_contact(contact *, char *); /* adds a host notification command to a contact definition */ 636 customvariablesmember *add_custom_variable_to_contact(contact *, char *, char *); /* adds a custom variable to a service definition */ 637 host *add_host(char *, char *, char *, char *, char *, int, double, double, int, int, int, int, int, int, double, double, char *, int, char *, int, int, char *, int, int, double, double, int, int, int, int, int, int, int, int, char *, int, int, char *, char *, char *, char *, char *, char *, char *, int, int, int, double, double, double, int, int, int, int, int); /* adds a host definition */ 638 hostsmember *add_parent_host_to_host(host *, char *); /* adds a parent host to a host definition */ 639 hostsmember *add_child_link_to_host(host *, host *); /* adds a child host to a host definition */ 640 contactgroupsmember *add_contactgroup_to_host(host *, char *); /* adds a contactgroup to a host definition */ 641 contactsmember *add_contact_to_host(host *, char *); /* adds a contact to a host definition */ 642 customvariablesmember *add_custom_variable_to_host(host *, char *, char *); /* adds a custom variable to a host definition */ 643 timeperiod *add_timeperiod(char *, char *); /* adds a timeperiod definition */ 644 timeperiodexclusion *add_exclusion_to_timeperiod(timeperiod *, char *); /* adds an exclusion to a timeperiod */ 645 timerange *add_timerange_to_timeperiod(timeperiod *, int, unsigned long, unsigned long); /* adds a timerange to a timeperiod definition */ 646 daterange *add_exception_to_timeperiod(timeperiod *, int, int, int, int, int, int, int, int, int, int, int, int); 647 timerange *add_timerange_to_daterange(daterange *, unsigned long, unsigned long); 648 hostgroup *add_hostgroup(char *, char *, char *, char *, char *); /* adds a hostgroup definition */ 649 hostsmember *add_host_to_hostgroup(hostgroup *, char *); /* adds a host to a hostgroup definition */ 650 servicegroup *add_servicegroup(char *, char *, char *, char *, char *); /* adds a servicegroup definition */ 651 servicesmember *add_service_to_servicegroup(servicegroup *, char *, char *); /* adds a service to a servicegroup definition */ 652 contactgroup *add_contactgroup(char *, char *); /* adds a contactgroup definition */ 653 contactsmember *add_contact_to_contactgroup(contactgroup *, char *); /* adds a contact to a contact group definition */ 654 command *add_command(char *, char *); /* adds a command definition */ 655 service *add_service(char *, char *, char *, char *, int, int, int, int, double, double, double, double, char *, int, int, int, int, int, int, int, int, char *, int, char *, int, int, double, double, int, int, int, int, int, int, int, int, int, int, char *, int, int, char *, char *, char *, char *, char *, int, int, int); /* adds a service definition */ 656 contactgroupsmember *add_contactgroup_to_service(service *, char *); /* adds a contact group to a service definition */ 657 contactsmember *add_contact_to_service(service *, char *); /* adds a contact to a host definition */ 658 serviceescalation *add_serviceescalation(char *, char *, int, int, double, char *, int, int, int, int); /* adds a service escalation definition */ 659 contactgroupsmember *add_contactgroup_to_serviceescalation(serviceescalation *, char *); /* adds a contact group to a service escalation definition */ 660 contactsmember *add_contact_to_serviceescalation(serviceescalation *, char *); /* adds a contact to a service escalation definition */ 661 customvariablesmember *add_custom_variable_to_service(service *, char *, char *); /* adds a custom variable to a service definition */ 662 servicedependency *add_service_dependency(char *, char *, char *, char *, int, int, int, int, int, int, int, char *); /* adds a service dependency definition */ 663 hostdependency *add_host_dependency(char *, char *, int, int, int, int, int, int, char *); /* adds a host dependency definition */ 664 hostescalation *add_hostescalation(char *, int, int, double, char *, int, int, int); /* adds a host escalation definition */ 665 contactsmember *add_contact_to_hostescalation(hostescalation *, char *); /* adds a contact to a host escalation definition */ 666 contactgroupsmember *add_contactgroup_to_hostescalation(hostescalation *, char *); /* adds a contact group to a host escalation definition */ 667 668 contactsmember *add_contact_to_object(contactsmember **, char *); /* adds a contact to an object */ 669 customvariablesmember *add_custom_variable_to_object(customvariablesmember **, char *, char *); /* adds a custom variable to an object */ 670 671 672 servicesmember *add_service_link_to_host(host *, service *); 673 674 675 /*** Object Skiplist Functions ****/ 676 int init_object_skiplists(void); 677 int free_object_skiplists(void); 678 int skiplist_compare_text(const char *val1a, const char *val1b, const char *val2a, const char *val2b); 679 int skiplist_compare_host(void *a, void *b); 680 int skiplist_compare_service(void *a, void *b); 681 int skiplist_compare_command(void *a, void *b); 682 int skiplist_compare_timeperiod(void *a, void *b); 683 int skiplist_compare_contact(void *a, void *b); 684 int skiplist_compare_contactgroup(void *a, void *b); 685 int skiplist_compare_hostgroup(void *a, void *b); 686 int skiplist_compare_servicegroup(void *a, void *b); 687 int skiplist_compare_hostescalation(void *a, void *b); 688 int skiplist_compare_serviceescalation(void *a, void *b); 689 int skiplist_compare_hostdependency(void *a, void *b); 690 int skiplist_compare_servicedependency(void *a, void *b); 691 692 int get_host_count(void); 693 int get_service_count(void); 694 695 696 697 /**** Object Search Functions ****/ 698 timeperiod *find_timeperiod(char *); /* finds a timeperiod object */ 699 host *find_host(char *); /* finds a host object */ 700 hostgroup *find_hostgroup(char *); /* finds a hostgroup object */ 701 servicegroup *find_servicegroup(char *); /* finds a servicegroup object */ 702 contact *find_contact(char *); /* finds a contact object */ 703 contactgroup *find_contactgroup(char *); /* finds a contactgroup object */ 704 command *find_command(char *); /* finds a command object */ 705 service *find_service(char *, char *); /* finds a service object */ 706 707 708 /**** Object Traversal Functions ****/ 709 hostescalation *get_first_hostescalation_by_host(char *, void **); 710 hostescalation *get_next_hostescalation_by_host(char *, void **); 711 serviceescalation *get_first_serviceescalation_by_service(char *, char *, void **); 712 serviceescalation *get_next_serviceescalation_by_service(char *, char *, void **); 713 hostdependency *get_first_hostdependency_by_dependent_host(char *, void **); 714 hostdependency *get_next_hostdependency_by_dependent_host(char *, void **); 715 servicedependency *get_first_servicedependency_by_dependent_service(char *, char *, void **); 716 servicedependency *get_next_servicedependency_by_dependent_service(char *, char *, void **); 717 718 #ifdef NSCORE 719 int add_object_to_objectlist(objectlist **, void *); 720 int free_objectlist(objectlist **); 721 #endif 722 723 724 /**** Object Query Functions ****/ 725 int is_host_immediate_child_of_host(host *, host *); /* checks if a host is an immediate child of another host */ 726 int is_host_primary_immediate_child_of_host(host *, host *); /* checks if a host is an immediate child (and primary child) of another host */ 727 int is_host_immediate_parent_of_host(host *, host *); /* checks if a host is an immediate child of another host */ 728 int is_host_member_of_hostgroup(hostgroup *, host *); /* tests whether or not a host is a member of a specific hostgroup */ 729 int is_host_member_of_servicegroup(servicegroup *, host *); /* tests whether or not a service is a member of a specific servicegroup */ 730 int is_service_member_of_servicegroup(servicegroup *, service *); /* tests whether or not a service is a member of a specific servicegroup */ 731 int is_contact_member_of_contactgroup(contactgroup *, contact *); /* tests whether or not a contact is a member of a specific contact group */ 732 int is_contact_for_host(host *, contact *); /* tests whether or not a contact is a contact member for a specific host */ 733 int is_escalated_contact_for_host(host *, contact *); /* checks whether or not a contact is an escalated contact for a specific host */ 734 int is_contact_for_service(service *, contact *); /* tests whether or not a contact is a contact member for a specific service */ 735 int is_escalated_contact_for_service(service *, contact *); /* checks whether or not a contact is an escalated contact for a specific service */ 736 int is_host_immediate_parent_of_host(host *, host *); /* tests whether or not a host is an immediate parent of another host */ 737 738 int number_of_immediate_child_hosts(host *); /* counts the number of immediate child hosts for a particular host */ 739 int number_of_total_child_hosts(host *); /* counts the number of total child hosts for a particular host */ 740 int number_of_immediate_parent_hosts(host *); /* counts the number of immediate parents hosts for a particular host */ 741 int number_of_total_parent_hosts(host *); /* counts the number of total parents hosts for a particular host */ 742 743 #ifdef NSCORE 744 int check_for_circular_servicedependency_path(servicedependency *, servicedependency *, int); /* checks if a circular dependency exists for a given service */ 745 int check_for_circular_hostdependency_path(hostdependency *, hostdependency *, int); /* checks if a circular dependency exists for a given host */ 746 #endif 747 748 749 /**** Object Cleanup Functions ****/ 750 int free_object_data(void); /* frees all allocated memory for the object definitions */ 751 752 753 NAGIOS_END_DECL 754 #endif 755