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