1 /***************************************************************************** 2 * 3 * OBJECTS.H - Header file for object addition/search functions 4 * 5 * 6 * License: 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License version 2 as 10 * published by the Free Software Foundation. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * 21 *****************************************************************************/ 22 23 24 #ifndef NAGIOS_OBJECTS_H_INCLUDED 25 #define NAGIOS_OBJECTS_H_INCLUDED 26 27 #include "common.h" 28 29 NAGIOS_BEGIN_DECL 30 31 32 /*************** CURRENT OBJECT REVISION **************/ 33 34 #define CURRENT_OBJECT_STRUCTURE_VERSION 403 /* increment when changes are made to data structures... */ 35 /* Nagios 3 starts at 300, Nagios 4 at 400, etc. */ 36 37 38 39 /***************** OBJECT SIZE LIMITS *****************/ 40 41 #define MAX_STATE_HISTORY_ENTRIES 21 /* max number of old states to keep track of for flap detection */ 42 #define MAX_CONTACT_ADDRESSES 6 /* max number of custom addresses a contact can have */ 43 44 45 46 /***************** SKIP LISTS ****************/ 47 48 #define NUM_OBJECT_SKIPLISTS 12 49 #define NUM_HASHED_OBJECT_TYPES 8 50 51 #define HOST_SKIPLIST 0 52 #define SERVICE_SKIPLIST 1 53 #define COMMAND_SKIPLIST 2 54 #define TIMEPERIOD_SKIPLIST 3 55 #define CONTACT_SKIPLIST 4 56 #define CONTACTGROUP_SKIPLIST 5 57 #define HOSTGROUP_SKIPLIST 6 58 #define SERVICEGROUP_SKIPLIST 7 59 #define HOSTDEPENDENCY_SKIPLIST 8 60 #define SERVICEDEPENDENCY_SKIPLIST 9 61 #define HOSTESCALATION_SKIPLIST 10 62 #define SERVICEESCALATION_SKIPLIST 11 63 64 65 /***************** DATE RANGE TYPES *******************/ 66 67 #define DATERANGE_CALENDAR_DATE 0 /* 2008-12-25 */ 68 #define DATERANGE_MONTH_DATE 1 /* july 4 (specific month) */ 69 #define DATERANGE_MONTH_DAY 2 /* day 21 (generic month) */ 70 #define DATERANGE_MONTH_WEEK_DAY 3 /* 3rd thursday (specific month) */ 71 #define DATERANGE_WEEK_DAY 4 /* 3rd thursday (generic month) */ 72 #define DATERANGE_TYPES 5 73 74 75 /* 76 * flags for notification_options, flapping_options and other similar 77 * flags. They overlap (hosts and services), so we can't use enum's. 78 */ 79 #define OPT_NOTHING 0 /* no options selected */ 80 #define OPT_ALL (~0) /* everything selected, so all bits set */ 81 #define OPT_DOWN (1 << HOST_DOWN) 82 #define OPT_UP (1 << HOST_UP) 83 #define OPT_UNREACHABLE (1 << HOST_UNREACHABLE) 84 #define OPT_OK (1 << STATE_OK) 85 #define OPT_WARNING (1 << STATE_WARNING) 86 #define OPT_CRITICAL (1 << STATE_CRITICAL) 87 #define OPT_UNKNOWN (1 << STATE_UNKNOWN) 88 #define OPT_RECOVERY OPT_OK 89 /* and now the "unreal" states... */ 90 #define OPT_PENDING (1 << 10) 91 #define OPT_FLAPPING (1 << 11) 92 #define OPT_DOWNTIME (1 << 12) 93 #define OPT_DISABLED (1 << 15) /* will denote disabled checks some day */ 94 95 /* macros useful with both hosts and services */ 96 #define flag_set(c, flag) ((c) |= (flag)) 97 #define flag_get(c, flag) (unsigned int)((c) & (flag)) 98 #define flag_isset(c, flag) (flag_get((c), (flag)) == (unsigned int)(flag)) 99 #define flag_unset(c, flag) (c &= ~(flag)) 100 #define should_stalk(o) flag_isset(o->stalking_options, 1 << o->current_state) 101 #define should_flap_detect(o) flag_isset(o->flap_detection_options, 1 << o->current_state) 102 #define should_notify(o) flag_isset(o->notification_options, 1 << o->current_state) 103 #define add_notified_on(o, f) (o->notified_on |= (1 << f)) 104 105 106 /* Event-related macros */ 107 #define NUDGE_MIN 5 108 #define NUDGE_MAX 17 109 110 /****************** DATA STRUCTURES *******************/ 111 112 /* @todo Remove typedef's of non-opaque types in Nagios 5 */ 113 typedef struct host host; 114 typedef struct service service; 115 typedef struct contact contact; 116 117 /* TIMED_EVENT structure */ 118 typedef struct timed_event { 119 int event_type; 120 time_t run_time; 121 int recurring; 122 unsigned long event_interval; 123 int compensate_for_time_change; 124 void *timing_func; 125 void *event_data; 126 void *event_args; 127 int event_options; 128 unsigned int priority; /* 0 is auto, 1 is highest. n+1 < n */ 129 struct squeue_event *sq_event; 130 } timed_event; 131 132 133 /* NOTIFY_LIST structure */ 134 typedef struct notify_list { 135 struct contact *contact; 136 struct notify_list *next; 137 } notification; 138 139 140 /* 141 * *name can be "Nagios Core", "Merlin", "mod_gearman" or "DNX", fe. 142 * source_name gets passed the 'source' pointer from check_result 143 * and must return a non-free()'able string useful for printing what 144 * we need to determine exactly where the check was received from, 145 * such as "mod_gearman worker@10.11.12.13", or "Nagios Core command 146 * file worker" (for passive checks submitted locally), which will be 147 * stashed with hosts and services and used as the "CHECKSOURCE" macro. 148 */ 149 struct check_engine { 150 char *name; /* "Nagios Core", "Merlin", "Mod Gearman" fe */ 151 const char *(*source_name)( const void *); 152 void (*clean_result)(void *); 153 }; 154 155 /* CHECK_RESULT structure */ 156 typedef struct check_result { 157 int object_check_type; /* is this a service or a host check? */ 158 char *host_name; /* host name */ 159 char *service_description; /* service description */ 160 int check_type; /* was this an active or passive service check? */ 161 int check_options; 162 int scheduled_check; /* was this a scheduled or an on-demand check? */ 163 int reschedule_check; /* should we reschedule the next check */ 164 char *output_file; /* what file is the output stored in? */ 165 FILE *output_file_fp; 166 double latency; 167 struct timeval start_time; /* time the service check was initiated */ 168 struct timeval finish_time; /* time the service check was completed */ 169 int early_timeout; /* did the service check timeout? */ 170 int exited_ok; /* did the plugin check return okay? */ 171 int return_code; /* plugin return code */ 172 char *output; /* plugin output */ 173 struct rusage rusage; /* resource usage by this check */ 174 struct check_engine *engine; /* where did we get this check from? */ 175 const void *source; /* engine handles this */ 176 } check_result; 177 178 179 /* SCHED_INFO structure */ 180 typedef struct sched_info { 181 int total_services; 182 int total_scheduled_services; 183 int total_hosts; 184 int total_scheduled_hosts; 185 double average_services_per_host; 186 double average_scheduled_services_per_host; 187 unsigned long service_check_interval_total; 188 unsigned long host_check_interval_total; 189 double average_service_execution_time; 190 double average_service_check_interval; 191 double average_host_check_interval; 192 double average_service_inter_check_delay; 193 double average_host_inter_check_delay; 194 double service_inter_check_delay; 195 double host_inter_check_delay; 196 int service_interleave_factor; 197 int max_service_check_spread; 198 int max_host_check_spread; 199 time_t first_service_check; 200 time_t last_service_check; 201 time_t first_host_check; 202 time_t last_host_check; 203 } sched_info; 204 205 206 /* DBUF structure - dynamic string storage */ 207 typedef struct dbuf { 208 char *buf; 209 unsigned long used_size; 210 unsigned long allocated_size; 211 unsigned long chunk_size; 212 } dbuf; 213 214 215 #define CHECK_STATS_BUCKETS 15 216 217 /* used for tracking host and service check statistics */ 218 typedef struct check_stats { 219 int current_bucket; 220 int bucket[CHECK_STATS_BUCKETS]; 221 int overflow_bucket; 222 int minute_stats[3]; 223 time_t last_update; 224 } check_stats; 225 226 227 228 /* OBJECT LIST STRUCTURE */ 229 typedef struct objectlist { 230 void *object_ptr; 231 struct objectlist *next; 232 } objectlist; 233 234 235 /* TIMERANGE structure */ 236 typedef struct timerange { 237 unsigned long range_start; 238 unsigned long range_end; 239 struct timerange *next; 240 } timerange; 241 242 243 /* DATERANGE structure */ 244 typedef struct daterange { 245 int type; 246 int syear; /* start year */ 247 int smon; /* start month */ 248 int smday; /* start day of month (may 3rd, last day in feb) */ 249 int swday; /* start day of week (thursday) */ 250 int swday_offset; /* start weekday offset (3rd thursday, last monday in jan) */ 251 int eyear; 252 int emon; 253 int emday; 254 int ewday; 255 int ewday_offset; 256 int skip_interval; 257 struct timerange *times; 258 struct daterange *next; 259 } daterange; 260 261 262 /* TIMEPERIODEXCLUSION structure */ 263 typedef struct timeperiodexclusion { 264 char *timeperiod_name; 265 struct timeperiod *timeperiod_ptr; 266 struct timeperiodexclusion *next; 267 } timeperiodexclusion; 268 269 270 /* TIMEPERIOD structure */ 271 typedef struct timeperiod { 272 unsigned int id; 273 char *name; 274 char *alias; 275 struct timerange *days[7]; 276 struct daterange *exceptions[DATERANGE_TYPES]; 277 struct timeperiodexclusion *exclusions; 278 struct timeperiod *next; 279 } timeperiod; 280 281 282 /* CONTACTSMEMBER structure */ 283 typedef struct contactsmember { 284 char *contact_name; 285 struct contact *contact_ptr; 286 struct contactsmember *next; 287 } contactsmember; 288 289 290 /* CONTACTGROUP structure */ 291 typedef struct contactgroup { 292 unsigned int id; 293 char *group_name; 294 char *alias; 295 struct contactsmember *members; 296 struct contactgroup *next; 297 } contactgroup; 298 299 300 /* CONTACTGROUPSMEMBER structure */ 301 typedef struct contactgroupsmember { 302 char *group_name; 303 struct contactgroup *group_ptr; 304 struct contactgroupsmember *next; 305 } contactgroupsmember; 306 307 308 /* CUSTOMVARIABLESMEMBER structure */ 309 typedef struct customvariablesmember { 310 char *variable_name; 311 char *variable_value; 312 int has_been_modified; 313 struct customvariablesmember *next; 314 } customvariablesmember; 315 316 317 /* COMMAND structure */ 318 typedef struct command { 319 unsigned int id; 320 char *name; 321 char *command_line; 322 struct command *next; 323 } command; 324 325 326 /* COMMANDSMEMBER structure */ 327 typedef struct commandsmember { 328 char *command; 329 struct command *command_ptr; 330 struct commandsmember *next; 331 } commandsmember; 332 333 334 /* CONTACT structure */ 335 struct contact { 336 unsigned int id; 337 char *name; 338 char *alias; 339 char *email; 340 char *pager; 341 char *address[MAX_CONTACT_ADDRESSES]; 342 struct commandsmember *host_notification_commands; 343 struct commandsmember *service_notification_commands; 344 unsigned int host_notification_options; 345 unsigned int service_notification_options; 346 unsigned int minimum_value; 347 char *host_notification_period; 348 char *service_notification_period; 349 int host_notifications_enabled; 350 int service_notifications_enabled; 351 int can_submit_commands; 352 int retain_status_information; 353 int retain_nonstatus_information; 354 struct customvariablesmember *custom_variables; 355 #ifndef NSCGI 356 time_t last_host_notification; 357 time_t last_service_notification; 358 unsigned long modified_attributes; 359 unsigned long modified_host_attributes; 360 unsigned long modified_service_attributes; 361 #endif 362 363 struct timeperiod *host_notification_period_ptr; 364 struct timeperiod *service_notification_period_ptr; 365 struct objectlist *contactgroups_ptr; 366 struct contact *next; 367 }; 368 369 370 /* SERVICESMEMBER structure */ 371 typedef struct servicesmember { 372 char *host_name; 373 char *service_description; 374 struct service *service_ptr; 375 struct servicesmember *next; 376 } servicesmember; 377 378 379 /* HOSTSMEMBER structure */ 380 typedef struct hostsmember { 381 char *host_name; 382 struct host *host_ptr; 383 struct hostsmember *next; 384 } hostsmember; 385 386 387 /* HOSTGROUP structure */ 388 typedef struct hostgroup { 389 unsigned int id; 390 char *group_name; 391 char *alias; 392 struct hostsmember *members; 393 char *notes; 394 char *notes_url; 395 char *action_url; 396 struct hostgroup *next; 397 } hostgroup; 398 399 400 /* HOST structure */ 401 struct host { 402 unsigned int id; 403 char *name; 404 char *display_name; 405 char *alias; 406 char *address; 407 struct hostsmember *parent_hosts; 408 struct hostsmember *child_hosts; 409 struct servicesmember *services; 410 char *check_command; 411 int initial_state; 412 double check_interval; 413 double retry_interval; 414 int max_attempts; 415 char *event_handler; 416 struct contactgroupsmember *contact_groups; 417 struct contactsmember *contacts; 418 double notification_interval; 419 double first_notification_delay; 420 unsigned int notification_options; 421 unsigned int hourly_value; 422 char *notification_period; 423 char *check_period; 424 int flap_detection_enabled; 425 double low_flap_threshold; 426 double high_flap_threshold; 427 int flap_detection_options; 428 unsigned int stalking_options; 429 int check_freshness; 430 int freshness_threshold; 431 int process_performance_data; 432 int checks_enabled; 433 const char *check_source; 434 int accept_passive_checks; 435 int event_handler_enabled; 436 int retain_status_information; 437 int retain_nonstatus_information; 438 int obsess; 439 char *notes; 440 char *notes_url; 441 char *action_url; 442 char *icon_image; 443 char *icon_image_alt; 444 char *statusmap_image; /* used by lots of graphing tools */ 445 /* #ifdef NSCGI */ 446 /* 447 * these are kept in ancillary storage for the daemon and 448 * thrown out as soon as we've created the object cache. 449 * The CGI's still attach them though, since they are the 450 * only users of this utter crap. 451 */ 452 char *vrml_image; 453 int have_2d_coords; 454 int x_2d; 455 int y_2d; 456 int have_3d_coords; 457 double x_3d; 458 double y_3d; 459 double z_3d; 460 int should_be_drawn; 461 /* #endif */ 462 customvariablesmember *custom_variables; 463 #ifndef NSCGI 464 int problem_has_been_acknowledged; 465 int acknowledgement_type; 466 int check_type; 467 int current_state; 468 int last_state; 469 int last_hard_state; 470 char *plugin_output; 471 char *long_plugin_output; 472 char *perf_data; 473 int state_type; 474 int current_attempt; 475 unsigned long current_event_id; 476 unsigned long last_event_id; 477 unsigned long current_problem_id; 478 unsigned long last_problem_id; 479 double latency; 480 double execution_time; 481 int is_executing; 482 int check_options; 483 int notifications_enabled; 484 time_t last_notification; 485 time_t next_notification; 486 time_t next_check; 487 int should_be_scheduled; 488 time_t last_check; 489 time_t last_state_change; 490 time_t last_hard_state_change; 491 time_t last_time_up; 492 time_t last_time_down; 493 time_t last_time_unreachable; 494 int has_been_checked; 495 int is_being_freshened; 496 int notified_on; 497 int current_notification_number; 498 int no_more_notifications; 499 unsigned long current_notification_id; 500 int check_flapping_recovery_notification; 501 int scheduled_downtime_depth; 502 int pending_flex_downtime; 503 int state_history[MAX_STATE_HISTORY_ENTRIES]; /* flap detection */ 504 int state_history_index; 505 time_t last_state_history_update; 506 int is_flapping; 507 unsigned long flapping_comment_id; 508 double percent_state_change; 509 int total_services; 510 unsigned long total_service_check_interval; 511 unsigned long modified_attributes; 512 #endif 513 514 struct command *event_handler_ptr; 515 struct command *check_command_ptr; 516 struct timeperiod *check_period_ptr; 517 struct timeperiod *notification_period_ptr; 518 struct objectlist *hostgroups_ptr; 519 /* objects we depend upon */ 520 struct objectlist *exec_deps, *notify_deps; 521 struct objectlist *escalation_list; 522 struct host *next; 523 struct timed_event *next_check_event; 524 }; 525 526 527 /* SERVICEGROUP structure */ 528 typedef struct servicegroup { 529 unsigned int id; 530 char *group_name; 531 char *alias; 532 struct servicesmember *members; 533 char *notes; 534 char *notes_url; 535 char *action_url; 536 struct servicegroup *next; 537 } servicegroup; 538 539 540 /* SERVICE structure */ 541 struct service { 542 unsigned int id; 543 char *host_name; 544 char *description; 545 char *display_name; 546 struct servicesmember *parents; 547 struct servicesmember *children; 548 char *check_command; 549 char *event_handler; 550 int initial_state; 551 double check_interval; 552 double retry_interval; 553 int max_attempts; 554 int parallelize; 555 struct contactgroupsmember *contact_groups; 556 struct contactsmember *contacts; 557 double notification_interval; 558 double first_notification_delay; 559 unsigned int notification_options; 560 unsigned int stalking_options; 561 unsigned int hourly_value; 562 int is_volatile; 563 char *notification_period; 564 char *check_period; 565 int flap_detection_enabled; 566 double low_flap_threshold; 567 double high_flap_threshold; 568 unsigned int flap_detection_options; 569 int process_performance_data; 570 int check_freshness; 571 int freshness_threshold; 572 int accept_passive_checks; 573 int event_handler_enabled; 574 int checks_enabled; 575 const char *check_source; 576 int retain_status_information; 577 int retain_nonstatus_information; 578 int notifications_enabled; 579 int obsess; 580 char *notes; 581 char *notes_url; 582 char *action_url; 583 char *icon_image; 584 char *icon_image_alt; 585 struct customvariablesmember *custom_variables; 586 #ifndef NSCGI 587 int problem_has_been_acknowledged; 588 int acknowledgement_type; 589 int host_problem_at_last_check; 590 int check_type; 591 int current_state; 592 int last_state; 593 int last_hard_state; 594 char *plugin_output; 595 char *long_plugin_output; 596 char *perf_data; 597 int state_type; 598 time_t next_check; 599 int should_be_scheduled; 600 time_t last_check; 601 int current_attempt; 602 unsigned long current_event_id; 603 unsigned long last_event_id; 604 unsigned long current_problem_id; 605 unsigned long last_problem_id; 606 time_t last_notification; 607 time_t next_notification; 608 int no_more_notifications; 609 int check_flapping_recovery_notification; 610 time_t last_state_change; 611 time_t last_hard_state_change; 612 time_t last_time_ok; 613 time_t last_time_warning; 614 time_t last_time_unknown; 615 time_t last_time_critical; 616 int has_been_checked; 617 int is_being_freshened; 618 unsigned int notified_on; 619 int current_notification_number; 620 unsigned long current_notification_id; 621 double latency; 622 double execution_time; 623 int is_executing; 624 int check_options; 625 int scheduled_downtime_depth; 626 int pending_flex_downtime; 627 int state_history[MAX_STATE_HISTORY_ENTRIES]; /* flap detection */ 628 int state_history_index; 629 int is_flapping; 630 unsigned long flapping_comment_id; 631 double percent_state_change; 632 unsigned long modified_attributes; 633 #endif 634 635 struct host *host_ptr; 636 struct command *event_handler_ptr; 637 char *event_handler_args; 638 struct command *check_command_ptr; 639 char *check_command_args; 640 struct timeperiod *check_period_ptr; 641 struct timeperiod *notification_period_ptr; 642 struct objectlist *servicegroups_ptr; 643 struct objectlist *exec_deps, *notify_deps; 644 struct objectlist *escalation_list; 645 struct service *next; 646 struct timed_event *next_check_event; 647 }; 648 649 650 /* SERVICE ESCALATION structure */ 651 typedef struct serviceescalation { 652 unsigned int id; 653 char *host_name; 654 char *description; 655 int first_notification; 656 int last_notification; 657 double notification_interval; 658 char *escalation_period; 659 int escalation_options; 660 struct contactgroupsmember *contact_groups; 661 struct contactsmember *contacts; 662 struct service *service_ptr; 663 struct timeperiod *escalation_period_ptr; 664 } serviceescalation; 665 666 667 /* SERVICE DEPENDENCY structure */ 668 typedef struct servicedependency { 669 unsigned int id; 670 int dependency_type; 671 char *dependent_host_name; 672 char *dependent_service_description; 673 char *host_name; 674 char *service_description; 675 char *dependency_period; 676 int inherits_parent; 677 int failure_options; 678 struct service *master_service_ptr; 679 struct service *dependent_service_ptr; 680 struct timeperiod *dependency_period_ptr; 681 } servicedependency; 682 683 684 /* HOST ESCALATION structure */ 685 typedef struct hostescalation { 686 unsigned int id; 687 char *host_name; 688 int first_notification; 689 int last_notification; 690 double notification_interval; 691 char *escalation_period; 692 int escalation_options; 693 struct contactgroupsmember *contact_groups; 694 struct contactsmember *contacts; 695 struct host *host_ptr; 696 struct timeperiod *escalation_period_ptr; 697 } hostescalation; 698 699 700 /* HOST DEPENDENCY structure */ 701 typedef struct hostdependency { 702 unsigned int id; 703 int dependency_type; 704 char *dependent_host_name; 705 char *host_name; 706 char *dependency_period; 707 int inherits_parent; 708 int failure_options; 709 struct host *master_host_ptr; 710 struct host *dependent_host_ptr; 711 struct timeperiod *dependency_period_ptr; 712 } hostdependency; 713 714 extern struct command *command_list; 715 extern struct timeperiod *timeperiod_list; 716 extern struct host *host_list; 717 extern struct service *service_list; 718 extern struct contact *contact_list; 719 extern struct hostgroup *hostgroup_list; 720 extern struct servicegroup *servicegroup_list; 721 extern struct contactgroup *contactgroup_list; 722 extern struct hostescalation *hostescalation_list; 723 extern struct serviceescalation *serviceescalation_list; 724 extern struct command **command_ary; 725 extern struct timeperiod **timeperiod_ary; 726 extern struct host **host_ary; 727 extern struct service **service_ary; 728 extern struct contact **contact_ary; 729 extern struct hostgroup **hostgroup_ary; 730 extern struct servicegroup **servicegroup_ary; 731 extern struct contactgroup **contactgroup_ary; 732 extern struct hostescalation **hostescalation_ary; 733 extern struct hostdependency **hostdependency_ary; 734 extern struct serviceescalation **serviceescalation_ary; 735 extern struct servicedependency **servicedependency_ary; 736 737 738 /********************* FUNCTIONS **********************/ 739 740 /**** Top-level input functions ****/ 741 int read_object_config_data(const char *, int); /* reads all external configuration data of specific types */ 742 743 744 /**** Object Creation Functions ****/ 745 struct contact *add_contact(char *name, char *alias, char *email, char *pager, char **addresses, char *svc_notification_period, char *host_notification_period, int service_notification_options, int host_notification_options, int service_notifications_enabled, int host_notifications_enabled, int can_submit_commands, int retain_status_information, int retain_nonstatus_information, unsigned int minimum_value); 746 struct commandsmember *add_service_notification_command_to_contact(contact *, char *); /* adds a service notification command to a contact definition */ 747 struct commandsmember *add_host_notification_command_to_contact(contact *, char *); /* adds a host notification command to a contact definition */ 748 struct customvariablesmember *add_custom_variable_to_contact(contact *, char *, char *); /* adds a custom variable to a service definition */ 749 struct host *add_host(char *name, char *display_name, char *alias, char *address, char *check_period, int initial_state, double check_interval, double retry_interval, int max_attempts, int notification_options, double notification_interval, double first_notification_delay, char *notification_period, int notifications_enabled, char *check_command, int checks_enabled, int accept_passive_checks, char *event_handler, int event_handler_enabled, int flap_detection_enabled, double low_flap_threshold, double high_flap_threshold, int flap_detection_options, int stalking_options, int process_perfdata, int check_freshness, int freshness_threshold, char *notes, char *notes_url, char *action_url, char *icon_image, char *icon_image_alt, char *vrml_image, char *statusmap_image, int x_2d, int y_2d, int have_2d_coords, double x_3d, double y_3d, double z_3d, int have_3d_coords, int should_be_drawn, int retain_status_information, int retain_nonstatus_information, int obsess_over_host, unsigned int hourly_value); 750 struct hostsmember *add_parent_host_to_host(host *, char *); /* adds a parent host to a host definition */ 751 struct servicesmember *add_parent_service_to_service(service *, char *host_name, char *description); 752 struct hostsmember *add_child_link_to_host(host *, host *); /* adds a child host to a host definition */ 753 struct servicesmember *add_child_link_to_service(service *, service *); /* adds a child host to a host definition */ 754 struct contactgroupsmember *add_contactgroup_to_host(host *, char *); /* adds a contactgroup to a host definition */ 755 struct contactsmember *add_contact_to_host(host *, char *); /* adds a contact to a host definition */ 756 struct customvariablesmember *add_custom_variable_to_host(host *, char *, char *); /* adds a custom variable to a host definition */ 757 struct timeperiod *add_timeperiod(char *, char *); /* adds a timeperiod definition */ 758 struct timeperiodexclusion *add_exclusion_to_timeperiod(timeperiod *, char *); /* adds an exclusion to a timeperiod */ 759 struct timerange *add_timerange_to_timeperiod(timeperiod *, int, unsigned long, unsigned long); /* adds a timerange to a timeperiod definition */ 760 struct daterange *add_exception_to_timeperiod(timeperiod *, int, int, int, int, int, int, int, int, int, int, int, int); 761 struct timerange *add_timerange_to_daterange(daterange *, unsigned long, unsigned long); 762 struct hostgroup *add_hostgroup(char *, char *, char *, char *, char *); /* adds a hostgroup definition */ 763 struct hostsmember *add_host_to_hostgroup(hostgroup *, char *); /* adds a host to a hostgroup definition */ 764 struct servicegroup *add_servicegroup(char *, char *, char *, char *, char *); /* adds a servicegroup definition */ 765 struct servicesmember *add_service_to_servicegroup(servicegroup *, char *, char *); /* adds a service to a servicegroup definition */ 766 struct contactgroup *add_contactgroup(char *, char *); /* adds a contactgroup definition */ 767 struct contactsmember *add_contact_to_contactgroup(contactgroup *, char *); /* adds a contact to a contact group definition */ 768 struct command *add_command(char *, char *); /* adds a command definition */ 769 struct service *add_service(char *host_name, char *description, char *display_name, char *check_period, int initial_state, int max_attempts, int parallelize, int accept_passive_checks, double check_interval, double retry_interval, double notification_interval, double first_notification_delay, char *notification_period, int notification_options, int notifications_enabled, int is_volatile, char *event_handler, int event_handler_enabled, char *check_command, int checks_enabled, int flap_detection_enabled, double low_flap_threshold, double high_flap_threshold, int flap_detection_options, int stalking_options, int process_perfdata, int check_freshness, int freshness_threshold, char *notes, char *notes_url, char *action_url, char *icon_image, char *icon_image_alt, int retain_status_information, int retain_nonstatus_information, int obsess_over_service, unsigned int hourly_value); 770 struct contactgroupsmember *add_contactgroup_to_service(service *, char *); /* adds a contact group to a service definition */ 771 struct contactsmember *add_contact_to_service(service *, char *); /* adds a contact to a host definition */ 772 struct serviceescalation *add_serviceescalation(char *host_name, char *description, int first_notification, int last_notification, double notification_interval, char *escalation_period, int escalation_options); 773 struct contactgroupsmember *add_contactgroup_to_serviceescalation(serviceescalation *, char *); /* adds a contact group to a service escalation definition */ 774 struct contactsmember *add_contact_to_serviceescalation(serviceescalation *, char *); /* adds a contact to a service escalation definition */ 775 struct customvariablesmember *add_custom_variable_to_service(service *, char *, char *); /* adds a custom variable to a service definition */ 776 struct servicedependency *add_service_dependency(char *dependent_host_name, char *dependent_service_description, char *host_name, char *service_description, int dependency_type, int inherits_parent, int failure_options, char *dependency_period); 777 struct hostdependency *add_host_dependency(char *dependent_host_name, char *host_name, int dependency_type, int inherits_parent, int failure_options, char *dependency_period); 778 struct hostescalation *add_hostescalation(char *host_name, int first_notification, int last_notification, double notification_interval, char *escalation_period, int escalation_options); 779 struct contactsmember *add_contact_to_hostescalation(hostescalation *, char *); /* adds a contact to a host escalation definition */ 780 struct contactgroupsmember *add_contactgroup_to_hostescalation(hostescalation *, char *); /* adds a contact group to a host escalation definition */ 781 782 struct contactsmember *add_contact_to_object(contactsmember **, char *); /* adds a contact to an object */ 783 struct customvariablesmember *add_custom_variable_to_object(customvariablesmember **, char *, char *); /* adds a custom variable to an object */ 784 785 786 struct servicesmember *add_service_link_to_host(host *, service *); 787 788 789 int skiplist_compare_text(const char *val1a, const char *val1b, const char *val2a, const char *val2b); 790 int get_host_count(void); 791 int get_service_count(void); 792 793 794 int create_object_tables(unsigned int *); 795 796 /**** Object Search Functions ****/ 797 struct timeperiod *find_timeperiod(const char *); 798 struct host *find_host(const char *); 799 struct hostgroup *find_hostgroup(const char *); 800 struct servicegroup *find_servicegroup(const char *); 801 struct contact *find_contact(const char *); 802 struct contactgroup *find_contactgroup(const char *); 803 struct command *find_command(const char *); 804 struct service *find_service(const char *, const char *); 805 806 807 #define OBJECTLIST_DUPE 1 808 int add_object_to_objectlist(struct objectlist **, void *); 809 int prepend_object_to_objectlist(struct objectlist **, void *); 810 int prepend_unique_object_to_objectlist(struct objectlist **, void *, size_t size); 811 int free_objectlist(objectlist **); 812 813 814 /**** Object Query Functions ****/ 815 unsigned int host_services_value(struct host *h); 816 int is_host_immediate_child_of_host(struct host *, struct host *); /* checks if a host is an immediate child of another host */ 817 int is_host_primary_immediate_child_of_host(struct host *, struct host *); /* checks if a host is an immediate child (and primary child) of another host */ 818 int is_host_immediate_parent_of_host(struct host *, struct host *); /* checks if a host is an immediate child of another host */ 819 int is_host_member_of_hostgroup(struct hostgroup *, struct host *); /* tests whether or not a host is a member of a specific hostgroup */ 820 int is_host_member_of_servicegroup(struct servicegroup *, struct host *); /* tests whether or not a service is a member of a specific servicegroup */ 821 int is_service_member_of_servicegroup(struct servicegroup *, struct service *); /* tests whether or not a service is a member of a specific servicegroup */ 822 int is_contact_member_of_contactgroup(struct contactgroup *, struct contact *); /* tests whether or not a contact is a member of a specific contact group */ 823 int is_contact_for_host(struct host *, struct contact *); /* tests whether or not a contact is a contact member for a specific host */ 824 int is_contactgroup_for_host(struct host *, struct contactgroup *); 825 /* tests whether a contact group is a contract group for a specific host */ 826 int is_escalated_contact_for_host(struct host *, struct contact *); /* checks whether or not a contact is an escalated contact for a specific host */ 827 int is_contact_for_host_escalation(hostescalation *, contact *); 828 /* tests whether a contact is an contact for a particular host escalation */ 829 int is_contactgroup_for_host_escalation(hostescalation *, contactgroup *); 830 /* tests whether a contactgroup is a contactgroup for a particular 831 host escalation */ 832 int is_contact_for_service(struct service *, struct contact *); /* tests whether or not a contact is a contact member for a specific service */ 833 int is_contactgroup_for_service(struct service *, struct contactgroup *); 834 /* tests whether a contact group is a contract group for a specific service */ 835 int is_escalated_contact_for_host(struct host *, struct contact *); /* checks whether or not a contact is an escalated contact for a specific host */ 836 int is_escalated_contact_for_service(struct service *, struct contact *); /* checks whether or not a contact is an escalated contact for a specific service */ 837 int is_contact_for_service_escalation(serviceescalation *, contact *); 838 /* tests whether a contact is an contact for a particular service 839 escalation */ 840 int is_contactgroup_for_service_escalation(serviceescalation *, contactgroup *); 841 /* tests whether a contactgroup is a contactgroup for a particular 842 service escalation */ 843 844 int number_of_immediate_child_hosts(struct host *); /* counts the number of immediate child hosts for a particular host */ 845 int number_of_total_child_hosts(struct host *); /* counts the number of total child hosts for a particular host */ 846 int number_of_immediate_parent_hosts(struct host *); /* counts the number of immediate parents hosts for a particular host */ 847 848 #ifndef NSCGI 849 void fcache_contactlist(FILE *fp, const char *prefix, struct contactsmember *list); 850 void fcache_contactgrouplist(FILE *fp, const char *prefix, struct contactgroupsmember *list); 851 void fcache_hostlist(FILE *fp, const char *prefix, struct hostsmember *list); 852 void fcache_customvars(FILE *fp, struct customvariablesmember *cvlist); 853 void fcache_timeperiod(FILE *fp, struct timeperiod *temp_timeperiod); 854 void fcache_command(FILE *fp, struct command *temp_command); 855 void fcache_contactgroup(FILE *fp, struct contactgroup *temp_contactgroup); 856 void fcache_hostgroup(FILE *fp, struct hostgroup *temp_hostgroup); 857 void fcache_servicegroup(FILE *fp, struct servicegroup *temp_servicegroup); 858 void fcache_contact(FILE *fp, struct contact *temp_contact); 859 void fcache_host(FILE *fp, struct host *temp_host); 860 void fcache_service(FILE *fp, struct service *temp_service); 861 void fcache_servicedependency(FILE *fp, struct servicedependency *temp_servicedependency); 862 void fcache_serviceescalation(FILE *fp, struct serviceescalation *temp_serviceescalation); 863 void fcache_hostdependency(FILE *fp, struct hostdependency *temp_hostdependency); 864 void fcache_hostescalation(FILE *fp, struct hostescalation *temp_hostescalation); 865 int fcache_objects(char *cache_file); 866 #endif 867 868 869 /**** Object Cleanup Functions ****/ 870 int free_object_data(void); /* frees all allocated memory for the object definitions */ 871 872 873 NAGIOS_END_DECL 874 #endif 875