~yolanda.robla/ubuntu/saucy/nagios3/dep-8-tests

« back to all changes in this revision

Viewing changes to xdata/xdddefault.c

  • Committer: Package Import Robot
  • Author(s): Alexander Wirt
  • Date: 2012-06-16 09:05:19 UTC
  • mfrom: (1.1.7)
  • Revision ID: package-import@ubuntu.com-20120616090519-ne14zejkhhyboolc
Tags: 3.4.1-1
* [28e077b] Imported Upstream version 3.3.1
* [d5314e0] don't call updatepo in clean target
* [45b3eb9] Don't remove config foo
* [54e3dff] Don't fix permissions in cgi postinst
* [d7be9db] Build-depend on libpng-dev (Closes: #662441)
* [4c47006] Add dutch po translation (Closes: #654855)
* [2b6573b] Refresh 10_p1_pl_shebang.dpatch
* [316fd7a] Update 40_fix_spurious_dollar_signs_added_to_command_lines
* [5ff2780] Refresh 55_strip_logarchivepath.dpatch
* [811d269] Refresh 60_fix_p1.pl_patch_mini_epn.dpatch
* [39a1e9c] Remove now unneeded patch 98_fix_XSS_CVE-2011-2179
* [785a4e8] Remove unneded patch 99_fix_XSS_CVE-2011-1523
* [6ce98ef] Remove unneeded patchs from 00list
* [1d18266] Imported Upstream version 3.4.0
* [05584c8] Refresh patches
* [58098cd] Imported Upstream version 3.4.1
* [3e9e07a] Bump standards version
* [fe991e2] wrap-and-sort
* [1ba78f7] Also create /var/run/nagios in cgi package (Closes: #626854)

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
#ifdef NSCORE
50
50
extern unsigned long next_downtime_id;
51
51
extern scheduled_downtime *scheduled_downtime_list;
52
 
extern char *macro_x[MACRO_X_COUNT];
53
52
#endif
54
53
 
55
54
 
64
63
 
65
64
 
66
65
/* initialize downtime data */
67
 
int xdddefault_initialize_downtime_data(char *main_config_file){
68
 
        scheduled_downtime *temp_downtime=NULL;
 
66
int xdddefault_initialize_downtime_data(char *main_config_file) {
 
67
        scheduled_downtime *temp_downtime = NULL;
69
68
 
70
69
        /* clean up the old downtime data */
71
70
        xdddefault_validate_downtime_data();
72
71
 
73
72
        /* find the new starting index for downtime id if its missing*/
74
 
        if(next_downtime_id==0L){
75
 
                for(temp_downtime=scheduled_downtime_list;temp_downtime!=NULL;temp_downtime=temp_downtime->next){
76
 
                        if(temp_downtime->downtime_id>=next_downtime_id)
77
 
                                next_downtime_id=temp_downtime->downtime_id+1;
78
 
                        }
79
 
                }
 
73
        if(next_downtime_id == 0L) {
 
74
                for(temp_downtime = scheduled_downtime_list; temp_downtime != NULL; temp_downtime = temp_downtime->next) {
 
75
                        if(temp_downtime->downtime_id >= next_downtime_id)
 
76
                                next_downtime_id = temp_downtime->downtime_id + 1;
 
77
                        }
 
78
                }
80
79
 
81
80
        /* initialize next downtime id if necessary */
82
 
        if(next_downtime_id==0L)
83
 
                next_downtime_id=1;
 
81
        if(next_downtime_id == 0L)
 
82
                next_downtime_id = 1;
84
83
 
85
84
        return OK;
86
 
        }
 
85
        }
87
86
 
88
87
 
89
88
 
90
89
/* removes invalid and old downtime entries from the downtime file */
91
 
int xdddefault_validate_downtime_data(void){
 
90
int xdddefault_validate_downtime_data(void) {
92
91
        scheduled_downtime *temp_downtime;
93
92
        scheduled_downtime *next_downtime;
94
 
        int update_file=FALSE;
95
 
        int save=TRUE;
 
93
        int update_file = FALSE;
 
94
        int save = TRUE;
96
95
 
97
96
        /* remove stale downtimes */
98
 
        for(temp_downtime=scheduled_downtime_list;temp_downtime!=NULL;temp_downtime=next_downtime){
 
97
        for(temp_downtime = scheduled_downtime_list; temp_downtime != NULL; temp_downtime = next_downtime) {
99
98
 
100
 
                next_downtime=temp_downtime->next;
101
 
                save=TRUE;
 
99
                next_downtime = temp_downtime->next;
 
100
                save = TRUE;
102
101
 
103
102
                /* delete downtimes with invalid host names */
104
 
                if(find_host(temp_downtime->host_name)==NULL)
105
 
                        save=FALSE;
 
103
                if(find_host(temp_downtime->host_name) == NULL)
 
104
                        save = FALSE;
106
105
 
107
106
                /* delete downtimes with invalid service descriptions */
108
 
                if(temp_downtime->type==SERVICE_DOWNTIME && find_service(temp_downtime->host_name,temp_downtime->service_description)==NULL)
109
 
                        save=FALSE;
 
107
                if(temp_downtime->type == SERVICE_DOWNTIME && find_service(temp_downtime->host_name, temp_downtime->service_description) == NULL)
 
108
                        save = FALSE;
110
109
 
111
110
                /* delete downtimes that have expired */
112
 
                if(temp_downtime->end_time<time(NULL))
113
 
                        save=FALSE;
 
111
                if(temp_downtime->end_time < time(NULL))
 
112
                        save = FALSE;
114
113
 
115
114
                /* delete the downtime */
116
 
                if(save==FALSE){
117
 
                        update_file=TRUE;
118
 
                        delete_downtime(temp_downtime->type,temp_downtime->downtime_id);
119
 
                        }
120
 
                }
 
115
                if(save == FALSE) {
 
116
                        update_file = TRUE;
 
117
                        delete_downtime(temp_downtime->type, temp_downtime->downtime_id);
 
118
                        }
 
119
                }
121
120
 
122
121
        /* remove triggered downtimes without valid parents */
123
 
        for(temp_downtime=scheduled_downtime_list;temp_downtime!=NULL;temp_downtime=next_downtime){
124
 
 
125
 
                next_downtime=temp_downtime->next;
126
 
                save=TRUE;
127
 
 
128
 
                if(temp_downtime->triggered_by==0)
 
122
        for(temp_downtime = scheduled_downtime_list; temp_downtime != NULL; temp_downtime = next_downtime) {
 
123
 
 
124
                next_downtime = temp_downtime->next;
 
125
                save = TRUE;
 
126
 
 
127
                if(temp_downtime->triggered_by == 0)
129
128
                        continue;
130
129
 
131
 
                if(find_host_downtime(temp_downtime->triggered_by)==NULL && find_service_downtime(temp_downtime->triggered_by)==NULL)
132
 
                        save=FALSE;
 
130
                if(find_host_downtime(temp_downtime->triggered_by) == NULL && find_service_downtime(temp_downtime->triggered_by) == NULL)
 
131
                        save = FALSE;
133
132
 
134
133
                /* delete the downtime */
135
 
                if(save==FALSE){
136
 
                        update_file=TRUE;
137
 
                        delete_downtime(temp_downtime->type,temp_downtime->downtime_id);
138
 
                        }
139
 
                }
 
134
                if(save == FALSE) {
 
135
                        update_file = TRUE;
 
136
                        delete_downtime(temp_downtime->type, temp_downtime->downtime_id);
 
137
                        }
 
138
                }
140
139
 
141
140
        /* update downtime file */
142
 
        if(update_file==TRUE)
 
141
        if(update_file == TRUE)
143
142
                xdddefault_save_downtime_data();
144
143
 
145
144
        return OK;
146
 
        }
 
145
        }
147
146
 
148
147
 
149
148
 
150
149
/* removes invalid and old downtime entries from the downtime file */
151
 
int xdddefault_cleanup_downtime_data(char *main_config_file){
 
150
int xdddefault_cleanup_downtime_data(char *main_config_file) {
152
151
 
153
152
        /* we don't need to do any cleanup... */
154
153
        return OK;
155
 
        }
 
154
        }
156
155
 
157
156
 
158
157
 
161
160
/******************************************************************/
162
161
 
163
162
/* adds a new scheduled host downtime entry */
164
 
int xdddefault_add_new_host_downtime(char *host_name, time_t entry_time, char *author, char *comment, time_t start_time, time_t end_time, int fixed, unsigned long triggered_by, unsigned long duration, unsigned long *downtime_id){
 
163
int xdddefault_add_new_host_downtime(char *host_name, time_t entry_time, char *author, char *comment, time_t start_time, time_t end_time, int fixed, unsigned long triggered_by, unsigned long duration, unsigned long *downtime_id, int is_in_effect){
165
164
 
166
165
        /* find the next valid downtime id */
167
 
        while(find_host_downtime(next_downtime_id)!=NULL)
 
166
        while(find_host_downtime(next_downtime_id) != NULL)
168
167
                next_downtime_id++;
169
168
 
170
169
        /* add downtime to list in memory */
171
 
        add_host_downtime(host_name,entry_time,author,comment,start_time,end_time,fixed,triggered_by,duration,next_downtime_id);
 
170
        add_host_downtime(host_name, entry_time, author, comment, start_time, end_time, fixed, triggered_by, duration, next_downtime_id, is_in_effect);
172
171
 
173
172
        /* update downtime file */
174
173
        xdddefault_save_downtime_data();
175
174
 
176
175
        /* return the id for the downtime we are about to add (this happens in the main code) */
177
 
        if(downtime_id!=NULL)
178
 
                *downtime_id=next_downtime_id;
 
176
        if(downtime_id != NULL)
 
177
                *downtime_id = next_downtime_id;
179
178
 
180
179
        /* increment the downtime id */
181
180
        next_downtime_id++;
182
181
 
183
182
        return OK;
184
 
        }
 
183
        }
185
184
 
186
185
 
187
186
 
188
187
/* adds a new scheduled service downtime entry */
189
 
int xdddefault_add_new_service_downtime(char *host_name, char *service_description, time_t entry_time, char *author, char *comment, time_t start_time, time_t end_time, int fixed, unsigned long triggered_by, unsigned long duration, unsigned long *downtime_id){
 
188
int xdddefault_add_new_service_downtime(char *host_name, char *service_description, time_t entry_time, char *author, char *comment, time_t start_time, time_t end_time, int fixed, unsigned long triggered_by, unsigned long duration, unsigned long *downtime_id, int is_in_effect){
190
189
 
191
190
        /* find the next valid downtime id */
192
 
        while(find_service_downtime(next_downtime_id)!=NULL)
 
191
        while(find_service_downtime(next_downtime_id) != NULL)
193
192
                next_downtime_id++;
194
193
 
195
194
        /* add downtime to list in memory */
196
 
        add_service_downtime(host_name,service_description,entry_time,author,comment,start_time,end_time,fixed,triggered_by,duration,next_downtime_id);
 
195
        add_service_downtime(host_name, service_description, entry_time, author, comment, start_time, end_time, fixed, triggered_by, duration, next_downtime_id, is_in_effect);
197
196
 
198
197
        /* update downtime file */
199
198
        xdddefault_save_downtime_data();
200
199
 
201
200
        /* return the id for the downtime we are about to add (this happens in the main code) */
202
 
        if(downtime_id!=NULL)
203
 
                *downtime_id=next_downtime_id;
 
201
        if(downtime_id != NULL)
 
202
                *downtime_id = next_downtime_id;
204
203
 
205
204
        /* increment the downtime id */
206
205
        next_downtime_id++;
207
206
 
208
207
        return OK;
209
 
        }
 
208
        }
210
209
 
211
210
 
212
211
/******************************************************************/
214
213
/******************************************************************/
215
214
 
216
215
/* deletes a scheduled host downtime entry */
217
 
int xdddefault_delete_host_downtime(unsigned long downtime_id){
 
216
int xdddefault_delete_host_downtime(unsigned long downtime_id) {
218
217
        int result;
219
218
 
220
 
        result=xdddefault_delete_downtime(HOST_DOWNTIME,downtime_id);
 
219
        result = xdddefault_delete_downtime(HOST_DOWNTIME, downtime_id);
221
220
 
222
221
        return result;
223
 
        }
 
222
        }
224
223
 
225
224
 
226
225
/* deletes a scheduled service downtime entry */
227
 
int xdddefault_delete_service_downtime(unsigned long downtime_id){
 
226
int xdddefault_delete_service_downtime(unsigned long downtime_id) {
228
227
        int result;
229
228
 
230
 
        result=xdddefault_delete_downtime(SERVICE_DOWNTIME,downtime_id);
 
229
        result = xdddefault_delete_downtime(SERVICE_DOWNTIME, downtime_id);
231
230
 
232
231
        return result;
233
 
        }
 
232
        }
234
233
 
235
234
 
236
235
/* deletes a scheduled host or service downtime entry */
237
 
int xdddefault_delete_downtime(int type, unsigned long downtime_id){
 
236
int xdddefault_delete_downtime(int type, unsigned long downtime_id) {
238
237
 
239
238
        /* rewrite the downtime file (downtime was already removed from memory) */
240
239
        xdddefault_save_downtime_data();
241
240
 
242
241
        return OK;
243
 
        }
 
242
        }
244
243
 
245
244
 
246
245
 
249
248
/******************************************************************/
250
249
 
251
250
/* writes downtime data to file */
252
 
int xdddefault_save_downtime_data(void){
 
251
int xdddefault_save_downtime_data(void) {
253
252
 
254
253
        /* don't update the status file now (too inefficent), let aggregated status updates do it */
255
 
#ifdef REMOVED_03052007
256
 
        /* update the main status log */
257
 
        update_all_status_data();
258
 
#endif
259
 
 
260
254
        return OK;
261
 
        }
 
255
        }
262
256
 
263
257
#endif
264
258