forked from naemon/naemon-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobjects_service.h
More file actions
186 lines (170 loc) · 6.61 KB
/
objects_service.h
File metadata and controls
186 lines (170 loc) · 6.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#ifndef INCLUDE_objects_service_h__
#define INCLUDE_objects_service_h__
#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION)
#error "Only <naemon/naemon.h> can be included directly."
#endif
#include <time.h>
#include "lib/lnae-utils.h"
#include "defaults.h"
#include "objects_common.h"
#include "objects_contact.h"
#include "objects_host.h"
NAGIOS_BEGIN_DECL
struct service;
typedef struct service service;
struct servicemember;
typedef struct servicesmember servicesmember;
extern struct service *service_list;
extern struct service **service_ary;
struct service {
unsigned int id;
char *host_name;
char *description;
char *display_name;
struct servicesmember *parents;
struct servicesmember *children;
char *check_command;
char *event_handler;
int initial_state;
int check_timeout;
double check_interval;
double retry_interval;
int max_attempts;
struct contactgroupsmember *contact_groups;
struct contactsmember *contacts;
double notification_interval;
double first_notification_delay;
unsigned int notification_options;
unsigned int stalking_options;
unsigned int hourly_value;
int is_volatile;
char *notification_period;
char *check_period;
int flap_detection_enabled;
double low_flap_threshold;
double high_flap_threshold;
unsigned int flap_detection_options;
int process_performance_data;
int check_freshness;
int freshness_threshold;
int accept_passive_checks;
int event_handler_enabled;
int checks_enabled;
const char *check_source;
int retain_status_information;
int retain_nonstatus_information;
int notifications_enabled;
int obsess;
char *notes;
char *notes_url;
char *action_url;
char *icon_image;
char *icon_image_alt;
struct customvariablesmember *custom_variables;
int problem_has_been_acknowledged;
int acknowledgement_type;
time_t acknowledgement_end_time;
int host_problem_at_last_check;
int check_type;
int current_state;
int last_state;
int last_hard_state;
char *plugin_output;
char *long_plugin_output;
char *perf_data;
int state_type;
time_t next_check;
time_t last_check;
int current_attempt;
unsigned long current_event_id;
unsigned long last_event_id;
char *current_problem_id;
char *last_problem_id;
time_t problem_start;
time_t problem_end;
time_t last_notification;
time_t next_notification;
int no_more_notifications;
int check_flapping_recovery_notification;
time_t last_state_change;
time_t last_hard_state_change;
time_t last_time_ok;
time_t last_time_warning;
time_t last_time_unknown;
time_t last_time_critical;
int has_been_checked;
int is_being_freshened;
unsigned int notified_on;
int current_notification_number;
char *current_notification_id;
double latency;
double execution_time;
int is_executing;
int check_options;
int scheduled_downtime_depth;
int pending_flex_downtime; /* UNUSED */
int state_history[MAX_STATE_HISTORY_ENTRIES]; /* flap detection */
int state_history_index;
int is_flapping;
unsigned long flapping_comment_id;
struct objectlist *comments_list;
double percent_state_change;
unsigned long modified_attributes;
struct host *host_ptr;
struct command *event_handler_ptr;
char *event_handler_args;
struct command *check_command_ptr;
struct timeperiod *check_period_ptr;
struct timeperiod *notification_period_ptr;
struct objectlist *servicegroups_ptr;
struct objectlist *exec_deps, *notify_deps;
struct objectlist *escalation_list;
struct timeval last_update /* timestamp when object has been updated the last time */;
struct service *next;
struct timed_event *next_check_event;
};
struct servicesmember {
char *host_name;
char *service_description;
struct service *service_ptr;
struct servicesmember *next;
};
static const struct flag_map service_flag_map[] = {
{ OPT_WARNING, 'w', "warning" },
{ OPT_UNKNOWN, 'u', "unknown" },
{ OPT_CRITICAL, 'c', "critical" },
{ OPT_FLAPPING, 'f', "flapping" },
{ OPT_DOWNTIME, 's', "downtime" },
{ OPT_OK, 'o', "ok" },
{ OPT_RECOVERY, 'r', "recovery" },
{ OPT_PENDING, 'p', "pending" },
{ 0, 0, NULL },
};
int init_objects_service(int elems);
void destroy_objects_service(int truncate_lists);
service *create_service(host *hst, const char *description);
int setup_service_variables(service *svc, const char *display_name, const char *check_period, const char *check_command, int initial_state, int check_timeout, int max_attempts, 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, const char *event_handler, int event_handler_enabled, 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, const char *notes, const char *notes_url, const char *action_url, const char *icon_image, const char *icon_image_alt, int retain_status_information, int retain_nonstatus_information, int obsess, unsigned int hourly_value);
int register_service(service *new_service);
void destroy_service(service *svc, int truncate_lists);
struct contactgroupsmember *add_contactgroup_to_service(service *, char *); /* adds a contact group to a service definition */
struct contactsmember *add_contact_to_service(service *, char *); /* adds a contact to a host definition */
struct servicesmember *add_parent_to_service(service *svc, service *parent);
struct customvariablesmember *add_custom_variable_to_service(service *, char *, char *); /* adds a custom variable to a service definition */
struct service *find_service(const char *, const char *);
int is_contact_for_service(struct service *, struct contact *); /* tests whether or not a contact is a contact member for a specific service */
int is_escalated_contact_for_service(struct service *, struct contact *); /* checks whether or not a contact is an escalated contact for a specific service */
int get_service_count(void);
/**
* Get the check interval for this service, in seconds
*/
time_t get_service_check_interval_s(const service *svc);
/**
* Get the retry interval for this service, in seconds
*/
time_t get_service_retry_interval_s(const service *svc);
const char *service_state_name(int state);
int log_service_event(service *);
int log_service_states(int, time_t *);
void fcache_service(FILE *fp, const struct service *temp_service);
NAGIOS_END_DECL
#endif