154
154
/* free memory */
158
158
/**** PROCESS ALL PASSIVE HOST AND SERVICE CHECK RESULTS AT ONE TIME ****/
159
if(passive_check_result_list!=NULL)
159
if(passive_check_result_list != NULL)
160
160
process_passive_checks();
167
167
/* processes all external commands in a (regular) file */
168
int process_external_commands_from_file(char *fname, int delete_file){
169
mmapfile *thefile=NULL;
173
log_debug_info(DEBUGL_FUNCTIONS,0,"process_external_commands_from_file()\n");
168
int process_external_commands_from_file(char *fname, int delete_file) {
169
mmapfile *thefile = NULL;
173
log_debug_info(DEBUGL_FUNCTIONS, 0, "process_external_commands_from_file()\n");
178
log_debug_info(DEBUGL_EXTERNALCOMMANDS,1,"Processing commands from file '%s'. File will %s deleted after processing.\n",fname,(delete_file==TRUE)?"be":"NOT be");
178
log_debug_info(DEBUGL_EXTERNALCOMMANDS, 1, "Processing commands from file '%s'. File will %s deleted after processing.\n", fname, (delete_file == TRUE) ? "be" : "NOT be");
180
180
/* open the config file for reading */
181
if((thefile=mmap_fopen(fname))==NULL){
182
logit(NSLOG_INFO_MESSAGE,FALSE,"Error: Cannot open file '%s' to process external commands!",fname);
181
if((thefile = mmap_fopen(fname)) == NULL) {
182
logit(NSLOG_INFO_MESSAGE, FALSE, "Error: Cannot open file '%s' to process external commands!", fname);
186
186
/* process all commands in the file */
189
189
/* free memory */
192
192
/* read the next line */
193
if((input=mmap_fgets(thefile))==NULL)
193
if((input = mmap_fgets(thefile)) == NULL)
196
196
/* process the command */
197
197
process_external_command1(input);
200
200
/* close the file */
201
201
mmap_fclose(thefile);
203
203
/* delete the file */
204
if(delete_file==TRUE)
204
if(delete_file == TRUE)
212
212
/* top-level external command processor */
213
int process_external_command1(char *cmd){
214
char *temp_buffer=NULL;
215
char *command_id=NULL;
217
time_t entry_time=0L;
218
int command_type=CMD_NONE;
221
log_debug_info(DEBUGL_FUNCTIONS,0,"process_external_command1()\n");
213
int process_external_command1(char *cmd) {
214
char *temp_buffer = NULL;
215
char *command_id = NULL;
217
time_t entry_time = 0L;
218
int command_type = CMD_NONE;
219
char *temp_ptr = NULL;
221
log_debug_info(DEBUGL_FUNCTIONS, 0, "process_external_command1()\n");
226
226
/* strip the command of newlines and carriage returns */
229
log_debug_info(DEBUGL_EXTERNALCOMMANDS,2,"Raw command entry: %s\n",cmd);
229
log_debug_info(DEBUGL_EXTERNALCOMMANDS, 2, "Raw command entry: %s\n", cmd);
231
231
/* get the command entry time */
232
if((temp_ptr=my_strtok(cmd,"["))==NULL)
234
if((temp_ptr=my_strtok(NULL,"]"))==NULL)
236
entry_time=(time_t)strtoul(temp_ptr,NULL,10);
232
if((temp_ptr = my_strtok(cmd, "[")) == NULL)
234
if((temp_ptr = my_strtok(NULL, "]")) == NULL)
236
entry_time = (time_t)strtoul(temp_ptr, NULL, 10);
238
238
/* get the command identifier */
239
if((temp_ptr=my_strtok(NULL,";"))==NULL)
239
if((temp_ptr = my_strtok(NULL, ";")) == NULL)
241
if((command_id=(char *)strdup(temp_ptr+1))==NULL)
241
if((command_id = (char *)strdup(temp_ptr + 1)) == NULL)
244
244
/* get the command arguments */
245
if((temp_ptr=my_strtok(NULL,"\n"))==NULL)
246
args=(char *)strdup("");
245
if((temp_ptr = my_strtok(NULL, "\n")) == NULL)
246
args = (char *)strdup("");
248
args=(char *)strdup(temp_ptr);
248
args = (char *)strdup(temp_ptr);
250
250
my_free(command_id);
254
254
/* decide what type of command this is... */
256
256
/**************************/
257
257
/**** PROCESS COMMANDS ****/
258
258
/**************************/
260
if(!strcmp(command_id,"ENTER_STANDBY_MODE") || !strcmp(command_id,"DISABLE_NOTIFICATIONS"))
261
command_type=CMD_DISABLE_NOTIFICATIONS;
262
else if(!strcmp(command_id,"ENTER_ACTIVE_MODE") || !strcmp(command_id,"ENABLE_NOTIFICATIONS"))
263
command_type=CMD_ENABLE_NOTIFICATIONS;
265
else if(!strcmp(command_id,"SHUTDOWN_PROGRAM") || !strcmp(command_id,"SHUTDOWN_PROCESS"))
266
command_type=CMD_SHUTDOWN_PROCESS;
267
else if(!strcmp(command_id,"RESTART_PROGRAM") || !strcmp(command_id,"RESTART_PROCESS"))
268
command_type=CMD_RESTART_PROCESS;
270
else if(!strcmp(command_id,"SAVE_STATE_INFORMATION"))
271
command_type=CMD_SAVE_STATE_INFORMATION;
272
else if(!strcmp(command_id,"READ_STATE_INFORMATION"))
273
command_type=CMD_READ_STATE_INFORMATION;
275
else if(!strcmp(command_id,"ENABLE_EVENT_HANDLERS"))
276
command_type=CMD_ENABLE_EVENT_HANDLERS;
277
else if(!strcmp(command_id,"DISABLE_EVENT_HANDLERS"))
278
command_type=CMD_DISABLE_EVENT_HANDLERS;
280
else if(!strcmp(command_id,"FLUSH_PENDING_COMMANDS"))
281
command_type=CMD_FLUSH_PENDING_COMMANDS;
283
else if(!strcmp(command_id,"ENABLE_FAILURE_PREDICTION"))
284
command_type=CMD_ENABLE_FAILURE_PREDICTION;
285
else if(!strcmp(command_id,"DISABLE_FAILURE_PREDICTION"))
286
command_type=CMD_DISABLE_FAILURE_PREDICTION;
288
else if(!strcmp(command_id,"ENABLE_PERFORMANCE_DATA"))
289
command_type=CMD_ENABLE_PERFORMANCE_DATA;
290
else if(!strcmp(command_id,"DISABLE_PERFORMANCE_DATA"))
291
command_type=CMD_DISABLE_PERFORMANCE_DATA;
293
else if(!strcmp(command_id,"START_EXECUTING_HOST_CHECKS"))
294
command_type=CMD_START_EXECUTING_HOST_CHECKS;
295
else if(!strcmp(command_id,"STOP_EXECUTING_HOST_CHECKS"))
296
command_type=CMD_STOP_EXECUTING_HOST_CHECKS;
298
else if(!strcmp(command_id,"START_EXECUTING_SVC_CHECKS"))
299
command_type=CMD_START_EXECUTING_SVC_CHECKS;
300
else if(!strcmp(command_id,"STOP_EXECUTING_SVC_CHECKS"))
301
command_type=CMD_STOP_EXECUTING_SVC_CHECKS;
303
else if(!strcmp(command_id,"START_ACCEPTING_PASSIVE_HOST_CHECKS"))
304
command_type=CMD_START_ACCEPTING_PASSIVE_HOST_CHECKS;
305
else if(!strcmp(command_id,"STOP_ACCEPTING_PASSIVE_HOST_CHECKS"))
306
command_type=CMD_STOP_ACCEPTING_PASSIVE_HOST_CHECKS;
308
else if(!strcmp(command_id,"START_ACCEPTING_PASSIVE_SVC_CHECKS"))
309
command_type=CMD_START_ACCEPTING_PASSIVE_SVC_CHECKS;
310
else if(!strcmp(command_id,"STOP_ACCEPTING_PASSIVE_SVC_CHECKS"))
311
command_type=CMD_STOP_ACCEPTING_PASSIVE_SVC_CHECKS;
313
else if(!strcmp(command_id,"START_OBSESSING_OVER_HOST_CHECKS"))
314
command_type=CMD_START_OBSESSING_OVER_HOST_CHECKS;
315
else if(!strcmp(command_id,"STOP_OBSESSING_OVER_HOST_CHECKS"))
316
command_type=CMD_STOP_OBSESSING_OVER_HOST_CHECKS;
318
else if(!strcmp(command_id,"START_OBSESSING_OVER_SVC_CHECKS"))
319
command_type=CMD_START_OBSESSING_OVER_SVC_CHECKS;
320
else if(!strcmp(command_id,"STOP_OBSESSING_OVER_SVC_CHECKS"))
321
command_type=CMD_STOP_OBSESSING_OVER_SVC_CHECKS;
323
else if(!strcmp(command_id,"ENABLE_FLAP_DETECTION"))
324
command_type=CMD_ENABLE_FLAP_DETECTION;
325
else if(!strcmp(command_id,"DISABLE_FLAP_DETECTION"))
326
command_type=CMD_DISABLE_FLAP_DETECTION;
328
else if(!strcmp(command_id,"CHANGE_GLOBAL_HOST_EVENT_HANDLER"))
329
command_type=CMD_CHANGE_GLOBAL_HOST_EVENT_HANDLER;
330
else if(!strcmp(command_id,"CHANGE_GLOBAL_SVC_EVENT_HANDLER"))
331
command_type=CMD_CHANGE_GLOBAL_SVC_EVENT_HANDLER;
333
else if(!strcmp(command_id,"ENABLE_SERVICE_FRESHNESS_CHECKS"))
334
command_type=CMD_ENABLE_SERVICE_FRESHNESS_CHECKS;
335
else if(!strcmp(command_id,"DISABLE_SERVICE_FRESHNESS_CHECKS"))
336
command_type=CMD_DISABLE_SERVICE_FRESHNESS_CHECKS;
338
else if(!strcmp(command_id,"ENABLE_HOST_FRESHNESS_CHECKS"))
339
command_type=CMD_ENABLE_HOST_FRESHNESS_CHECKS;
340
else if(!strcmp(command_id,"DISABLE_HOST_FRESHNESS_CHECKS"))
341
command_type=CMD_DISABLE_HOST_FRESHNESS_CHECKS;
260
if(!strcmp(command_id, "ENTER_STANDBY_MODE") || !strcmp(command_id, "DISABLE_NOTIFICATIONS"))
261
command_type = CMD_DISABLE_NOTIFICATIONS;
262
else if(!strcmp(command_id, "ENTER_ACTIVE_MODE") || !strcmp(command_id, "ENABLE_NOTIFICATIONS"))
263
command_type = CMD_ENABLE_NOTIFICATIONS;
265
else if(!strcmp(command_id, "SHUTDOWN_PROGRAM") || !strcmp(command_id, "SHUTDOWN_PROCESS"))
266
command_type = CMD_SHUTDOWN_PROCESS;
267
else if(!strcmp(command_id, "RESTART_PROGRAM") || !strcmp(command_id, "RESTART_PROCESS"))
268
command_type = CMD_RESTART_PROCESS;
270
else if(!strcmp(command_id, "SAVE_STATE_INFORMATION"))
271
command_type = CMD_SAVE_STATE_INFORMATION;
272
else if(!strcmp(command_id, "READ_STATE_INFORMATION"))
273
command_type = CMD_READ_STATE_INFORMATION;
275
else if(!strcmp(command_id, "ENABLE_EVENT_HANDLERS"))
276
command_type = CMD_ENABLE_EVENT_HANDLERS;
277
else if(!strcmp(command_id, "DISABLE_EVENT_HANDLERS"))
278
command_type = CMD_DISABLE_EVENT_HANDLERS;
280
else if(!strcmp(command_id, "FLUSH_PENDING_COMMANDS"))
281
command_type = CMD_FLUSH_PENDING_COMMANDS;
283
else if(!strcmp(command_id, "ENABLE_FAILURE_PREDICTION"))
284
command_type = CMD_ENABLE_FAILURE_PREDICTION;
285
else if(!strcmp(command_id, "DISABLE_FAILURE_PREDICTION"))
286
command_type = CMD_DISABLE_FAILURE_PREDICTION;
288
else if(!strcmp(command_id, "ENABLE_PERFORMANCE_DATA"))
289
command_type = CMD_ENABLE_PERFORMANCE_DATA;
290
else if(!strcmp(command_id, "DISABLE_PERFORMANCE_DATA"))
291
command_type = CMD_DISABLE_PERFORMANCE_DATA;
293
else if(!strcmp(command_id, "START_EXECUTING_HOST_CHECKS"))
294
command_type = CMD_START_EXECUTING_HOST_CHECKS;
295
else if(!strcmp(command_id, "STOP_EXECUTING_HOST_CHECKS"))
296
command_type = CMD_STOP_EXECUTING_HOST_CHECKS;
298
else if(!strcmp(command_id, "START_EXECUTING_SVC_CHECKS"))
299
command_type = CMD_START_EXECUTING_SVC_CHECKS;
300
else if(!strcmp(command_id, "STOP_EXECUTING_SVC_CHECKS"))
301
command_type = CMD_STOP_EXECUTING_SVC_CHECKS;
303
else if(!strcmp(command_id, "START_ACCEPTING_PASSIVE_HOST_CHECKS"))
304
command_type = CMD_START_ACCEPTING_PASSIVE_HOST_CHECKS;
305
else if(!strcmp(command_id, "STOP_ACCEPTING_PASSIVE_HOST_CHECKS"))
306
command_type = CMD_STOP_ACCEPTING_PASSIVE_HOST_CHECKS;
308
else if(!strcmp(command_id, "START_ACCEPTING_PASSIVE_SVC_CHECKS"))
309
command_type = CMD_START_ACCEPTING_PASSIVE_SVC_CHECKS;
310
else if(!strcmp(command_id, "STOP_ACCEPTING_PASSIVE_SVC_CHECKS"))
311
command_type = CMD_STOP_ACCEPTING_PASSIVE_SVC_CHECKS;
313
else if(!strcmp(command_id, "START_OBSESSING_OVER_HOST_CHECKS"))
314
command_type = CMD_START_OBSESSING_OVER_HOST_CHECKS;
315
else if(!strcmp(command_id, "STOP_OBSESSING_OVER_HOST_CHECKS"))
316
command_type = CMD_STOP_OBSESSING_OVER_HOST_CHECKS;
318
else if(!strcmp(command_id, "START_OBSESSING_OVER_SVC_CHECKS"))
319
command_type = CMD_START_OBSESSING_OVER_SVC_CHECKS;
320
else if(!strcmp(command_id, "STOP_OBSESSING_OVER_SVC_CHECKS"))
321
command_type = CMD_STOP_OBSESSING_OVER_SVC_CHECKS;
323
else if(!strcmp(command_id, "ENABLE_FLAP_DETECTION"))
324
command_type = CMD_ENABLE_FLAP_DETECTION;
325
else if(!strcmp(command_id, "DISABLE_FLAP_DETECTION"))
326
command_type = CMD_DISABLE_FLAP_DETECTION;
328
else if(!strcmp(command_id, "CHANGE_GLOBAL_HOST_EVENT_HANDLER"))
329
command_type = CMD_CHANGE_GLOBAL_HOST_EVENT_HANDLER;
330
else if(!strcmp(command_id, "CHANGE_GLOBAL_SVC_EVENT_HANDLER"))
331
command_type = CMD_CHANGE_GLOBAL_SVC_EVENT_HANDLER;
333
else if(!strcmp(command_id, "ENABLE_SERVICE_FRESHNESS_CHECKS"))
334
command_type = CMD_ENABLE_SERVICE_FRESHNESS_CHECKS;
335
else if(!strcmp(command_id, "DISABLE_SERVICE_FRESHNESS_CHECKS"))
336
command_type = CMD_DISABLE_SERVICE_FRESHNESS_CHECKS;
338
else if(!strcmp(command_id, "ENABLE_HOST_FRESHNESS_CHECKS"))
339
command_type = CMD_ENABLE_HOST_FRESHNESS_CHECKS;
340
else if(!strcmp(command_id, "DISABLE_HOST_FRESHNESS_CHECKS"))
341
command_type = CMD_DISABLE_HOST_FRESHNESS_CHECKS;
344
344
/*******************************/
345
345
/**** HOST-RELATED COMMANDS ****/
346
346
/*******************************/
348
else if(!strcmp(command_id,"ADD_HOST_COMMENT"))
349
command_type=CMD_ADD_HOST_COMMENT;
350
else if(!strcmp(command_id,"DEL_HOST_COMMENT"))
351
command_type=CMD_DEL_HOST_COMMENT;
352
else if(!strcmp(command_id,"DEL_ALL_HOST_COMMENTS"))
353
command_type=CMD_DEL_ALL_HOST_COMMENTS;
355
else if(!strcmp(command_id,"DELAY_HOST_NOTIFICATION"))
356
command_type=CMD_DELAY_HOST_NOTIFICATION;
358
else if(!strcmp(command_id,"ENABLE_HOST_NOTIFICATIONS"))
359
command_type=CMD_ENABLE_HOST_NOTIFICATIONS;
360
else if(!strcmp(command_id,"DISABLE_HOST_NOTIFICATIONS"))
361
command_type=CMD_DISABLE_HOST_NOTIFICATIONS;
363
else if(!strcmp(command_id,"ENABLE_ALL_NOTIFICATIONS_BEYOND_HOST"))
364
command_type=CMD_ENABLE_ALL_NOTIFICATIONS_BEYOND_HOST;
365
else if(!strcmp(command_id,"DISABLE_ALL_NOTIFICATIONS_BEYOND_HOST"))
366
command_type=CMD_DISABLE_ALL_NOTIFICATIONS_BEYOND_HOST;
368
else if(!strcmp(command_id,"ENABLE_HOST_AND_CHILD_NOTIFICATIONS"))
369
command_type=CMD_ENABLE_HOST_AND_CHILD_NOTIFICATIONS;
370
else if(!strcmp(command_id,"DISABLE_HOST_AND_CHILD_NOTIFICATIONS"))
371
command_type=CMD_DISABLE_HOST_AND_CHILD_NOTIFICATIONS;
373
else if(!strcmp(command_id,"ENABLE_HOST_SVC_NOTIFICATIONS"))
374
command_type=CMD_ENABLE_HOST_SVC_NOTIFICATIONS;
375
else if(!strcmp(command_id,"DISABLE_HOST_SVC_NOTIFICATIONS"))
376
command_type=CMD_DISABLE_HOST_SVC_NOTIFICATIONS;
378
else if(!strcmp(command_id,"ENABLE_HOST_SVC_CHECKS"))
379
command_type=CMD_ENABLE_HOST_SVC_CHECKS;
380
else if(!strcmp(command_id,"DISABLE_HOST_SVC_CHECKS"))
381
command_type=CMD_DISABLE_HOST_SVC_CHECKS;
383
else if(!strcmp(command_id,"ENABLE_PASSIVE_HOST_CHECKS"))
384
command_type=CMD_ENABLE_PASSIVE_HOST_CHECKS;
385
else if(!strcmp(command_id,"DISABLE_PASSIVE_HOST_CHECKS"))
386
command_type=CMD_DISABLE_PASSIVE_HOST_CHECKS;
388
else if(!strcmp(command_id,"SCHEDULE_HOST_SVC_CHECKS"))
389
command_type=CMD_SCHEDULE_HOST_SVC_CHECKS;
390
else if(!strcmp(command_id,"SCHEDULE_FORCED_HOST_SVC_CHECKS"))
391
command_type=CMD_SCHEDULE_FORCED_HOST_SVC_CHECKS;
393
else if(!strcmp(command_id,"ACKNOWLEDGE_HOST_PROBLEM"))
394
command_type=CMD_ACKNOWLEDGE_HOST_PROBLEM;
395
else if(!strcmp(command_id,"REMOVE_HOST_ACKNOWLEDGEMENT"))
396
command_type=CMD_REMOVE_HOST_ACKNOWLEDGEMENT;
398
else if(!strcmp(command_id,"ENABLE_HOST_EVENT_HANDLER"))
399
command_type=CMD_ENABLE_HOST_EVENT_HANDLER;
400
else if(!strcmp(command_id,"DISABLE_HOST_EVENT_HANDLER"))
401
command_type=CMD_DISABLE_HOST_EVENT_HANDLER;
403
else if(!strcmp(command_id,"ENABLE_HOST_CHECK"))
404
command_type=CMD_ENABLE_HOST_CHECK;
405
else if(!strcmp(command_id,"DISABLE_HOST_CHECK"))
406
command_type=CMD_DISABLE_HOST_CHECK;
408
else if(!strcmp(command_id,"SCHEDULE_HOST_CHECK"))
409
command_type=CMD_SCHEDULE_HOST_CHECK;
410
else if(!strcmp(command_id,"SCHEDULE_FORCED_HOST_CHECK"))
411
command_type=CMD_SCHEDULE_FORCED_HOST_CHECK;
413
else if(!strcmp(command_id,"SCHEDULE_HOST_DOWNTIME"))
414
command_type=CMD_SCHEDULE_HOST_DOWNTIME;
415
else if(!strcmp(command_id,"SCHEDULE_HOST_SVC_DOWNTIME"))
416
command_type=CMD_SCHEDULE_HOST_SVC_DOWNTIME;
417
else if(!strcmp(command_id,"DEL_HOST_DOWNTIME"))
418
command_type=CMD_DEL_HOST_DOWNTIME;
420
else if(!strcmp(command_id,"ENABLE_HOST_FLAP_DETECTION"))
421
command_type=CMD_ENABLE_HOST_FLAP_DETECTION;
422
else if(!strcmp(command_id,"DISABLE_HOST_FLAP_DETECTION"))
423
command_type=CMD_DISABLE_HOST_FLAP_DETECTION;
425
else if(!strcmp(command_id,"START_OBSESSING_OVER_HOST"))
426
command_type=CMD_START_OBSESSING_OVER_HOST;
427
else if(!strcmp(command_id,"STOP_OBSESSING_OVER_HOST"))
428
command_type=CMD_STOP_OBSESSING_OVER_HOST;
430
else if(!strcmp(command_id,"CHANGE_HOST_EVENT_HANDLER"))
431
command_type=CMD_CHANGE_HOST_EVENT_HANDLER;
432
else if(!strcmp(command_id,"CHANGE_HOST_CHECK_COMMAND"))
433
command_type=CMD_CHANGE_HOST_CHECK_COMMAND;
435
else if(!strcmp(command_id,"CHANGE_NORMAL_HOST_CHECK_INTERVAL"))
436
command_type=CMD_CHANGE_NORMAL_HOST_CHECK_INTERVAL;
437
else if(!strcmp(command_id,"CHANGE_RETRY_HOST_CHECK_INTERVAL"))
438
command_type=CMD_CHANGE_RETRY_HOST_CHECK_INTERVAL;
440
else if(!strcmp(command_id,"CHANGE_MAX_HOST_CHECK_ATTEMPTS"))
441
command_type=CMD_CHANGE_MAX_HOST_CHECK_ATTEMPTS;
443
else if(!strcmp(command_id,"SCHEDULE_AND_PROPAGATE_TRIGGERED_HOST_DOWNTIME"))
444
command_type=CMD_SCHEDULE_AND_PROPAGATE_TRIGGERED_HOST_DOWNTIME;
446
else if(!strcmp(command_id,"SCHEDULE_AND_PROPAGATE_HOST_DOWNTIME"))
447
command_type=CMD_SCHEDULE_AND_PROPAGATE_HOST_DOWNTIME;
449
else if(!strcmp(command_id,"SET_HOST_NOTIFICATION_NUMBER"))
450
command_type=CMD_SET_HOST_NOTIFICATION_NUMBER;
452
else if(!strcmp(command_id,"CHANGE_HOST_CHECK_TIMEPERIOD"))
453
command_type=CMD_CHANGE_HOST_CHECK_TIMEPERIOD;
455
else if (!strcmp(command_id,"CHANGE_CUSTOM_HOST_VAR"))
456
command_type=CMD_CHANGE_CUSTOM_HOST_VAR;
458
else if (!strcmp(command_id,"SEND_CUSTOM_HOST_NOTIFICATION"))
459
command_type=CMD_SEND_CUSTOM_HOST_NOTIFICATION;
461
else if(!strcmp(command_id,"CHANGE_HOST_NOTIFICATION_TIMEPERIOD"))
462
command_type=CMD_CHANGE_HOST_NOTIFICATION_TIMEPERIOD;
464
else if(!strcmp(command_id,"CHANGE_HOST_MODATTR"))
465
command_type=CMD_CHANGE_HOST_MODATTR;
348
else if(!strcmp(command_id, "ADD_HOST_COMMENT"))
349
command_type = CMD_ADD_HOST_COMMENT;
350
else if(!strcmp(command_id, "DEL_HOST_COMMENT"))
351
command_type = CMD_DEL_HOST_COMMENT;
352
else if(!strcmp(command_id, "DEL_ALL_HOST_COMMENTS"))
353
command_type = CMD_DEL_ALL_HOST_COMMENTS;
355
else if(!strcmp(command_id, "DELAY_HOST_NOTIFICATION"))
356
command_type = CMD_DELAY_HOST_NOTIFICATION;
358
else if(!strcmp(command_id, "ENABLE_HOST_NOTIFICATIONS"))
359
command_type = CMD_ENABLE_HOST_NOTIFICATIONS;
360
else if(!strcmp(command_id, "DISABLE_HOST_NOTIFICATIONS"))
361
command_type = CMD_DISABLE_HOST_NOTIFICATIONS;
363
else if(!strcmp(command_id, "ENABLE_ALL_NOTIFICATIONS_BEYOND_HOST"))
364
command_type = CMD_ENABLE_ALL_NOTIFICATIONS_BEYOND_HOST;
365
else if(!strcmp(command_id, "DISABLE_ALL_NOTIFICATIONS_BEYOND_HOST"))
366
command_type = CMD_DISABLE_ALL_NOTIFICATIONS_BEYOND_HOST;
368
else if(!strcmp(command_id, "ENABLE_HOST_AND_CHILD_NOTIFICATIONS"))
369
command_type = CMD_ENABLE_HOST_AND_CHILD_NOTIFICATIONS;
370
else if(!strcmp(command_id, "DISABLE_HOST_AND_CHILD_NOTIFICATIONS"))
371
command_type = CMD_DISABLE_HOST_AND_CHILD_NOTIFICATIONS;
373
else if(!strcmp(command_id, "ENABLE_HOST_SVC_NOTIFICATIONS"))
374
command_type = CMD_ENABLE_HOST_SVC_NOTIFICATIONS;
375
else if(!strcmp(command_id, "DISABLE_HOST_SVC_NOTIFICATIONS"))
376
command_type = CMD_DISABLE_HOST_SVC_NOTIFICATIONS;
378
else if(!strcmp(command_id, "ENABLE_HOST_SVC_CHECKS"))
379
command_type = CMD_ENABLE_HOST_SVC_CHECKS;
380
else if(!strcmp(command_id, "DISABLE_HOST_SVC_CHECKS"))
381
command_type = CMD_DISABLE_HOST_SVC_CHECKS;
383
else if(!strcmp(command_id, "ENABLE_PASSIVE_HOST_CHECKS"))
384
command_type = CMD_ENABLE_PASSIVE_HOST_CHECKS;
385
else if(!strcmp(command_id, "DISABLE_PASSIVE_HOST_CHECKS"))
386
command_type = CMD_DISABLE_PASSIVE_HOST_CHECKS;
388
else if(!strcmp(command_id, "SCHEDULE_HOST_SVC_CHECKS"))
389
command_type = CMD_SCHEDULE_HOST_SVC_CHECKS;
390
else if(!strcmp(command_id, "SCHEDULE_FORCED_HOST_SVC_CHECKS"))
391
command_type = CMD_SCHEDULE_FORCED_HOST_SVC_CHECKS;
393
else if(!strcmp(command_id, "ACKNOWLEDGE_HOST_PROBLEM"))
394
command_type = CMD_ACKNOWLEDGE_HOST_PROBLEM;
395
else if(!strcmp(command_id, "REMOVE_HOST_ACKNOWLEDGEMENT"))
396
command_type = CMD_REMOVE_HOST_ACKNOWLEDGEMENT;
398
else if(!strcmp(command_id, "ENABLE_HOST_EVENT_HANDLER"))
399
command_type = CMD_ENABLE_HOST_EVENT_HANDLER;
400
else if(!strcmp(command_id, "DISABLE_HOST_EVENT_HANDLER"))
401
command_type = CMD_DISABLE_HOST_EVENT_HANDLER;
403
else if(!strcmp(command_id, "ENABLE_HOST_CHECK"))
404
command_type = CMD_ENABLE_HOST_CHECK;
405
else if(!strcmp(command_id, "DISABLE_HOST_CHECK"))
406
command_type = CMD_DISABLE_HOST_CHECK;
408
else if(!strcmp(command_id, "SCHEDULE_HOST_CHECK"))
409
command_type = CMD_SCHEDULE_HOST_CHECK;
410
else if(!strcmp(command_id, "SCHEDULE_FORCED_HOST_CHECK"))
411
command_type = CMD_SCHEDULE_FORCED_HOST_CHECK;
413
else if(!strcmp(command_id, "SCHEDULE_HOST_DOWNTIME"))
414
command_type = CMD_SCHEDULE_HOST_DOWNTIME;
415
else if(!strcmp(command_id, "SCHEDULE_HOST_SVC_DOWNTIME"))
416
command_type = CMD_SCHEDULE_HOST_SVC_DOWNTIME;
417
else if(!strcmp(command_id, "DEL_HOST_DOWNTIME"))
418
command_type = CMD_DEL_HOST_DOWNTIME;
419
else if(!strcmp(command_id, "DEL_DOWNTIME_BY_HOST_NAME"))
420
command_type = CMD_DEL_DOWNTIME_BY_HOST_NAME;
421
else if(!strcmp(command_id, "DEL_DOWNTIME_BY_HOSTGROUP_NAME"))
422
command_type = CMD_DEL_DOWNTIME_BY_HOSTGROUP_NAME;
423
else if(!strcmp(command_id, "DEL_DOWNTIME_BY_START_TIME_COMMENT"))
424
command_type = CMD_DEL_DOWNTIME_BY_START_TIME_COMMENT;
426
else if(!strcmp(command_id, "ENABLE_HOST_FLAP_DETECTION"))
427
command_type = CMD_ENABLE_HOST_FLAP_DETECTION;
428
else if(!strcmp(command_id, "DISABLE_HOST_FLAP_DETECTION"))
429
command_type = CMD_DISABLE_HOST_FLAP_DETECTION;
431
else if(!strcmp(command_id, "START_OBSESSING_OVER_HOST"))
432
command_type = CMD_START_OBSESSING_OVER_HOST;
433
else if(!strcmp(command_id, "STOP_OBSESSING_OVER_HOST"))
434
command_type = CMD_STOP_OBSESSING_OVER_HOST;
436
else if(!strcmp(command_id, "CHANGE_HOST_EVENT_HANDLER"))
437
command_type = CMD_CHANGE_HOST_EVENT_HANDLER;
438
else if(!strcmp(command_id, "CHANGE_HOST_CHECK_COMMAND"))
439
command_type = CMD_CHANGE_HOST_CHECK_COMMAND;
441
else if(!strcmp(command_id, "CHANGE_NORMAL_HOST_CHECK_INTERVAL"))
442
command_type = CMD_CHANGE_NORMAL_HOST_CHECK_INTERVAL;
443
else if(!strcmp(command_id, "CHANGE_RETRY_HOST_CHECK_INTERVAL"))
444
command_type = CMD_CHANGE_RETRY_HOST_CHECK_INTERVAL;
446
else if(!strcmp(command_id, "CHANGE_MAX_HOST_CHECK_ATTEMPTS"))
447
command_type = CMD_CHANGE_MAX_HOST_CHECK_ATTEMPTS;
449
else if(!strcmp(command_id, "SCHEDULE_AND_PROPAGATE_TRIGGERED_HOST_DOWNTIME"))
450
command_type = CMD_SCHEDULE_AND_PROPAGATE_TRIGGERED_HOST_DOWNTIME;
452
else if(!strcmp(command_id, "SCHEDULE_AND_PROPAGATE_HOST_DOWNTIME"))
453
command_type = CMD_SCHEDULE_AND_PROPAGATE_HOST_DOWNTIME;
455
else if(!strcmp(command_id, "SET_HOST_NOTIFICATION_NUMBER"))
456
command_type = CMD_SET_HOST_NOTIFICATION_NUMBER;
458
else if(!strcmp(command_id, "CHANGE_HOST_CHECK_TIMEPERIOD"))
459
command_type = CMD_CHANGE_HOST_CHECK_TIMEPERIOD;
461
else if(!strcmp(command_id, "CHANGE_CUSTOM_HOST_VAR"))
462
command_type = CMD_CHANGE_CUSTOM_HOST_VAR;
464
else if(!strcmp(command_id, "SEND_CUSTOM_HOST_NOTIFICATION"))
465
command_type = CMD_SEND_CUSTOM_HOST_NOTIFICATION;
467
else if(!strcmp(command_id, "CHANGE_HOST_NOTIFICATION_TIMEPERIOD"))
468
command_type = CMD_CHANGE_HOST_NOTIFICATION_TIMEPERIOD;
470
else if(!strcmp(command_id, "CHANGE_HOST_MODATTR"))
471
command_type = CMD_CHANGE_HOST_MODATTR;
468
474
/************************************/
469
475
/**** HOSTGROUP-RELATED COMMANDS ****/
470
476
/************************************/
472
else if(!strcmp(command_id,"ENABLE_HOSTGROUP_HOST_NOTIFICATIONS"))
473
command_type=CMD_ENABLE_HOSTGROUP_HOST_NOTIFICATIONS;
474
else if(!strcmp(command_id,"DISABLE_HOSTGROUP_HOST_NOTIFICATIONS"))
475
command_type=CMD_DISABLE_HOSTGROUP_HOST_NOTIFICATIONS;
477
else if(!strcmp(command_id,"ENABLE_HOSTGROUP_SVC_NOTIFICATIONS"))
478
command_type=CMD_ENABLE_HOSTGROUP_SVC_NOTIFICATIONS;
479
else if(!strcmp(command_id,"DISABLE_HOSTGROUP_SVC_NOTIFICATIONS"))
480
command_type=CMD_DISABLE_HOSTGROUP_SVC_NOTIFICATIONS;
482
else if(!strcmp(command_id,"ENABLE_HOSTGROUP_HOST_CHECKS"))
483
command_type=CMD_ENABLE_HOSTGROUP_HOST_CHECKS;
484
else if(!strcmp(command_id,"DISABLE_HOSTGROUP_HOST_CHECKS"))
485
command_type=CMD_DISABLE_HOSTGROUP_HOST_CHECKS;
487
else if(!strcmp(command_id,"ENABLE_HOSTGROUP_PASSIVE_HOST_CHECKS"))
488
command_type=CMD_ENABLE_HOSTGROUP_PASSIVE_HOST_CHECKS;
489
else if(!strcmp(command_id,"DISABLE_HOSTGROUP_PASSIVE_HOST_CHECKS"))
490
command_type=CMD_DISABLE_HOSTGROUP_PASSIVE_HOST_CHECKS;
492
else if(!strcmp(command_id,"ENABLE_HOSTGROUP_SVC_CHECKS"))
493
command_type=CMD_ENABLE_HOSTGROUP_SVC_CHECKS;
494
else if(!strcmp(command_id,"DISABLE_HOSTGROUP_SVC_CHECKS"))
495
command_type=CMD_DISABLE_HOSTGROUP_SVC_CHECKS;
497
else if(!strcmp(command_id,"ENABLE_HOSTGROUP_PASSIVE_SVC_CHECKS"))
498
command_type=CMD_ENABLE_HOSTGROUP_PASSIVE_SVC_CHECKS;
499
else if(!strcmp(command_id,"DISABLE_HOSTGROUP_PASSIVE_SVC_CHECKS"))
500
command_type=CMD_DISABLE_HOSTGROUP_PASSIVE_SVC_CHECKS;
502
else if(!strcmp(command_id,"SCHEDULE_HOSTGROUP_HOST_DOWNTIME"))
503
command_type=CMD_SCHEDULE_HOSTGROUP_HOST_DOWNTIME;
504
else if(!strcmp(command_id,"SCHEDULE_HOSTGROUP_SVC_DOWNTIME"))
505
command_type=CMD_SCHEDULE_HOSTGROUP_SVC_DOWNTIME;
478
else if(!strcmp(command_id, "ENABLE_HOSTGROUP_HOST_NOTIFICATIONS"))
479
command_type = CMD_ENABLE_HOSTGROUP_HOST_NOTIFICATIONS;
480
else if(!strcmp(command_id, "DISABLE_HOSTGROUP_HOST_NOTIFICATIONS"))
481
command_type = CMD_DISABLE_HOSTGROUP_HOST_NOTIFICATIONS;
483
else if(!strcmp(command_id, "ENABLE_HOSTGROUP_SVC_NOTIFICATIONS"))
484
command_type = CMD_ENABLE_HOSTGROUP_SVC_NOTIFICATIONS;
485
else if(!strcmp(command_id, "DISABLE_HOSTGROUP_SVC_NOTIFICATIONS"))
486
command_type = CMD_DISABLE_HOSTGROUP_SVC_NOTIFICATIONS;
488
else if(!strcmp(command_id, "ENABLE_HOSTGROUP_HOST_CHECKS"))
489
command_type = CMD_ENABLE_HOSTGROUP_HOST_CHECKS;
490
else if(!strcmp(command_id, "DISABLE_HOSTGROUP_HOST_CHECKS"))
491
command_type = CMD_DISABLE_HOSTGROUP_HOST_CHECKS;
493
else if(!strcmp(command_id, "ENABLE_HOSTGROUP_PASSIVE_HOST_CHECKS"))
494
command_type = CMD_ENABLE_HOSTGROUP_PASSIVE_HOST_CHECKS;
495
else if(!strcmp(command_id, "DISABLE_HOSTGROUP_PASSIVE_HOST_CHECKS"))
496
command_type = CMD_DISABLE_HOSTGROUP_PASSIVE_HOST_CHECKS;
498
else if(!strcmp(command_id, "ENABLE_HOSTGROUP_SVC_CHECKS"))
499
command_type = CMD_ENABLE_HOSTGROUP_SVC_CHECKS;
500
else if(!strcmp(command_id, "DISABLE_HOSTGROUP_SVC_CHECKS"))
501
command_type = CMD_DISABLE_HOSTGROUP_SVC_CHECKS;
503
else if(!strcmp(command_id, "ENABLE_HOSTGROUP_PASSIVE_SVC_CHECKS"))
504
command_type = CMD_ENABLE_HOSTGROUP_PASSIVE_SVC_CHECKS;
505
else if(!strcmp(command_id, "DISABLE_HOSTGROUP_PASSIVE_SVC_CHECKS"))
506
command_type = CMD_DISABLE_HOSTGROUP_PASSIVE_SVC_CHECKS;
508
else if(!strcmp(command_id, "SCHEDULE_HOSTGROUP_HOST_DOWNTIME"))
509
command_type = CMD_SCHEDULE_HOSTGROUP_HOST_DOWNTIME;
510
else if(!strcmp(command_id, "SCHEDULE_HOSTGROUP_SVC_DOWNTIME"))
511
command_type = CMD_SCHEDULE_HOSTGROUP_SVC_DOWNTIME;
508
514
/**********************************/
509
515
/**** SERVICE-RELATED COMMANDS ****/
510
516
/**********************************/
512
else if(!strcmp(command_id,"ADD_SVC_COMMENT"))
513
command_type=CMD_ADD_SVC_COMMENT;
514
else if(!strcmp(command_id,"DEL_SVC_COMMENT"))
515
command_type=CMD_DEL_SVC_COMMENT;
516
else if(!strcmp(command_id,"DEL_ALL_SVC_COMMENTS"))
517
command_type=CMD_DEL_ALL_SVC_COMMENTS;
519
else if(!strcmp(command_id,"SCHEDULE_SVC_CHECK"))
520
command_type=CMD_SCHEDULE_SVC_CHECK;
521
else if(!strcmp(command_id,"SCHEDULE_FORCED_SVC_CHECK"))
522
command_type=CMD_SCHEDULE_FORCED_SVC_CHECK;
524
else if(!strcmp(command_id,"ENABLE_SVC_CHECK"))
525
command_type=CMD_ENABLE_SVC_CHECK;
526
else if(!strcmp(command_id,"DISABLE_SVC_CHECK"))
527
command_type=CMD_DISABLE_SVC_CHECK;
529
else if(!strcmp(command_id,"ENABLE_PASSIVE_SVC_CHECKS"))
530
command_type=CMD_ENABLE_PASSIVE_SVC_CHECKS;
531
else if(!strcmp(command_id,"DISABLE_PASSIVE_SVC_CHECKS"))
532
command_type=CMD_DISABLE_PASSIVE_SVC_CHECKS;
534
else if(!strcmp(command_id,"DELAY_SVC_NOTIFICATION"))
535
command_type=CMD_DELAY_SVC_NOTIFICATION;
536
else if(!strcmp(command_id,"ENABLE_SVC_NOTIFICATIONS"))
537
command_type=CMD_ENABLE_SVC_NOTIFICATIONS;
538
else if(!strcmp(command_id,"DISABLE_SVC_NOTIFICATIONS"))
539
command_type=CMD_DISABLE_SVC_NOTIFICATIONS;
541
else if(!strcmp(command_id,"PROCESS_SERVICE_CHECK_RESULT"))
542
command_type=CMD_PROCESS_SERVICE_CHECK_RESULT;
543
else if(!strcmp(command_id,"PROCESS_HOST_CHECK_RESULT"))
544
command_type=CMD_PROCESS_HOST_CHECK_RESULT;
546
else if(!strcmp(command_id,"ENABLE_SVC_EVENT_HANDLER"))
547
command_type=CMD_ENABLE_SVC_EVENT_HANDLER;
548
else if(!strcmp(command_id,"DISABLE_SVC_EVENT_HANDLER"))
549
command_type=CMD_DISABLE_SVC_EVENT_HANDLER;
551
else if(!strcmp(command_id,"ENABLE_SVC_FLAP_DETECTION"))
552
command_type=CMD_ENABLE_SVC_FLAP_DETECTION;
553
else if(!strcmp(command_id,"DISABLE_SVC_FLAP_DETECTION"))
554
command_type=CMD_DISABLE_SVC_FLAP_DETECTION;
556
else if(!strcmp(command_id,"SCHEDULE_SVC_DOWNTIME"))
557
command_type=CMD_SCHEDULE_SVC_DOWNTIME;
558
else if(!strcmp(command_id,"DEL_SVC_DOWNTIME"))
559
command_type=CMD_DEL_SVC_DOWNTIME;
561
else if(!strcmp(command_id,"ACKNOWLEDGE_SVC_PROBLEM"))
562
command_type=CMD_ACKNOWLEDGE_SVC_PROBLEM;
563
else if(!strcmp(command_id,"REMOVE_SVC_ACKNOWLEDGEMENT"))
564
command_type=CMD_REMOVE_SVC_ACKNOWLEDGEMENT;
566
else if(!strcmp(command_id,"START_OBSESSING_OVER_SVC"))
567
command_type=CMD_START_OBSESSING_OVER_SVC;
568
else if(!strcmp(command_id,"STOP_OBSESSING_OVER_SVC"))
569
command_type=CMD_STOP_OBSESSING_OVER_SVC;
571
else if(!strcmp(command_id,"CHANGE_SVC_EVENT_HANDLER"))
572
command_type=CMD_CHANGE_SVC_EVENT_HANDLER;
573
else if(!strcmp(command_id,"CHANGE_SVC_CHECK_COMMAND"))
574
command_type=CMD_CHANGE_SVC_CHECK_COMMAND;
576
else if(!strcmp(command_id,"CHANGE_NORMAL_SVC_CHECK_INTERVAL"))
577
command_type=CMD_CHANGE_NORMAL_SVC_CHECK_INTERVAL;
578
else if(!strcmp(command_id,"CHANGE_RETRY_SVC_CHECK_INTERVAL"))
579
command_type=CMD_CHANGE_RETRY_SVC_CHECK_INTERVAL;
581
else if(!strcmp(command_id,"CHANGE_MAX_SVC_CHECK_ATTEMPTS"))
582
command_type=CMD_CHANGE_MAX_SVC_CHECK_ATTEMPTS;
584
else if(!strcmp(command_id,"SET_SVC_NOTIFICATION_NUMBER"))
585
command_type=CMD_SET_SVC_NOTIFICATION_NUMBER;
587
else if(!strcmp(command_id,"CHANGE_SVC_CHECK_TIMEPERIOD"))
588
command_type=CMD_CHANGE_SVC_CHECK_TIMEPERIOD;
590
else if (!strcmp(command_id,"CHANGE_CUSTOM_SVC_VAR"))
591
command_type=CMD_CHANGE_CUSTOM_SVC_VAR;
593
else if (!strcmp(command_id,"CHANGE_CUSTOM_CONTACT_VAR"))
594
command_type=CMD_CHANGE_CUSTOM_CONTACT_VAR;
596
else if (!strcmp(command_id,"SEND_CUSTOM_SVC_NOTIFICATION"))
597
command_type=CMD_SEND_CUSTOM_SVC_NOTIFICATION;
599
else if(!strcmp(command_id,"CHANGE_SVC_NOTIFICATION_TIMEPERIOD"))
600
command_type=CMD_CHANGE_SVC_NOTIFICATION_TIMEPERIOD;
602
else if(!strcmp(command_id,"CHANGE_SVC_MODATTR"))
603
command_type=CMD_CHANGE_SVC_MODATTR;
518
else if(!strcmp(command_id, "ADD_SVC_COMMENT"))
519
command_type = CMD_ADD_SVC_COMMENT;
520
else if(!strcmp(command_id, "DEL_SVC_COMMENT"))
521
command_type = CMD_DEL_SVC_COMMENT;
522
else if(!strcmp(command_id, "DEL_ALL_SVC_COMMENTS"))
523
command_type = CMD_DEL_ALL_SVC_COMMENTS;
525
else if(!strcmp(command_id, "SCHEDULE_SVC_CHECK"))
526
command_type = CMD_SCHEDULE_SVC_CHECK;
527
else if(!strcmp(command_id, "SCHEDULE_FORCED_SVC_CHECK"))
528
command_type = CMD_SCHEDULE_FORCED_SVC_CHECK;
530
else if(!strcmp(command_id, "ENABLE_SVC_CHECK"))
531
command_type = CMD_ENABLE_SVC_CHECK;
532
else if(!strcmp(command_id, "DISABLE_SVC_CHECK"))
533
command_type = CMD_DISABLE_SVC_CHECK;
535
else if(!strcmp(command_id, "ENABLE_PASSIVE_SVC_CHECKS"))
536
command_type = CMD_ENABLE_PASSIVE_SVC_CHECKS;
537
else if(!strcmp(command_id, "DISABLE_PASSIVE_SVC_CHECKS"))
538
command_type = CMD_DISABLE_PASSIVE_SVC_CHECKS;
540
else if(!strcmp(command_id, "DELAY_SVC_NOTIFICATION"))
541
command_type = CMD_DELAY_SVC_NOTIFICATION;
542
else if(!strcmp(command_id, "ENABLE_SVC_NOTIFICATIONS"))
543
command_type = CMD_ENABLE_SVC_NOTIFICATIONS;
544
else if(!strcmp(command_id, "DISABLE_SVC_NOTIFICATIONS"))
545
command_type = CMD_DISABLE_SVC_NOTIFICATIONS;
547
else if(!strcmp(command_id, "PROCESS_SERVICE_CHECK_RESULT"))
548
command_type = CMD_PROCESS_SERVICE_CHECK_RESULT;
549
else if(!strcmp(command_id, "PROCESS_HOST_CHECK_RESULT"))
550
command_type = CMD_PROCESS_HOST_CHECK_RESULT;
552
else if(!strcmp(command_id, "ENABLE_SVC_EVENT_HANDLER"))
553
command_type = CMD_ENABLE_SVC_EVENT_HANDLER;
554
else if(!strcmp(command_id, "DISABLE_SVC_EVENT_HANDLER"))
555
command_type = CMD_DISABLE_SVC_EVENT_HANDLER;
557
else if(!strcmp(command_id, "ENABLE_SVC_FLAP_DETECTION"))
558
command_type = CMD_ENABLE_SVC_FLAP_DETECTION;
559
else if(!strcmp(command_id, "DISABLE_SVC_FLAP_DETECTION"))
560
command_type = CMD_DISABLE_SVC_FLAP_DETECTION;
562
else if(!strcmp(command_id, "SCHEDULE_SVC_DOWNTIME"))
563
command_type = CMD_SCHEDULE_SVC_DOWNTIME;
564
else if(!strcmp(command_id, "DEL_SVC_DOWNTIME"))
565
command_type = CMD_DEL_SVC_DOWNTIME;
567
else if(!strcmp(command_id, "ACKNOWLEDGE_SVC_PROBLEM"))
568
command_type = CMD_ACKNOWLEDGE_SVC_PROBLEM;
569
else if(!strcmp(command_id, "REMOVE_SVC_ACKNOWLEDGEMENT"))
570
command_type = CMD_REMOVE_SVC_ACKNOWLEDGEMENT;
572
else if(!strcmp(command_id, "START_OBSESSING_OVER_SVC"))
573
command_type = CMD_START_OBSESSING_OVER_SVC;
574
else if(!strcmp(command_id, "STOP_OBSESSING_OVER_SVC"))
575
command_type = CMD_STOP_OBSESSING_OVER_SVC;
577
else if(!strcmp(command_id, "CHANGE_SVC_EVENT_HANDLER"))
578
command_type = CMD_CHANGE_SVC_EVENT_HANDLER;
579
else if(!strcmp(command_id, "CHANGE_SVC_CHECK_COMMAND"))
580
command_type = CMD_CHANGE_SVC_CHECK_COMMAND;
582
else if(!strcmp(command_id, "CHANGE_NORMAL_SVC_CHECK_INTERVAL"))
583
command_type = CMD_CHANGE_NORMAL_SVC_CHECK_INTERVAL;
584
else if(!strcmp(command_id, "CHANGE_RETRY_SVC_CHECK_INTERVAL"))
585
command_type = CMD_CHANGE_RETRY_SVC_CHECK_INTERVAL;
587
else if(!strcmp(command_id, "CHANGE_MAX_SVC_CHECK_ATTEMPTS"))
588
command_type = CMD_CHANGE_MAX_SVC_CHECK_ATTEMPTS;
590
else if(!strcmp(command_id, "SET_SVC_NOTIFICATION_NUMBER"))
591
command_type = CMD_SET_SVC_NOTIFICATION_NUMBER;
593
else if(!strcmp(command_id, "CHANGE_SVC_CHECK_TIMEPERIOD"))
594
command_type = CMD_CHANGE_SVC_CHECK_TIMEPERIOD;
596
else if(!strcmp(command_id, "CHANGE_CUSTOM_SVC_VAR"))
597
command_type = CMD_CHANGE_CUSTOM_SVC_VAR;
599
else if(!strcmp(command_id, "CHANGE_CUSTOM_CONTACT_VAR"))
600
command_type = CMD_CHANGE_CUSTOM_CONTACT_VAR;
602
else if(!strcmp(command_id, "SEND_CUSTOM_SVC_NOTIFICATION"))
603
command_type = CMD_SEND_CUSTOM_SVC_NOTIFICATION;
605
else if(!strcmp(command_id, "CHANGE_SVC_NOTIFICATION_TIMEPERIOD"))
606
command_type = CMD_CHANGE_SVC_NOTIFICATION_TIMEPERIOD;
608
else if(!strcmp(command_id, "CHANGE_SVC_MODATTR"))
609
command_type = CMD_CHANGE_SVC_MODATTR;
606
612
/***************************************/
607
613
/**** SERVICEGROUP-RELATED COMMANDS ****/
608
614
/***************************************/
610
else if(!strcmp(command_id,"ENABLE_SERVICEGROUP_HOST_NOTIFICATIONS"))
611
command_type=CMD_ENABLE_SERVICEGROUP_HOST_NOTIFICATIONS;
612
else if(!strcmp(command_id,"DISABLE_SERVICEGROUP_HOST_NOTIFICATIONS"))
613
command_type=CMD_DISABLE_SERVICEGROUP_HOST_NOTIFICATIONS;
615
else if(!strcmp(command_id,"ENABLE_SERVICEGROUP_SVC_NOTIFICATIONS"))
616
command_type=CMD_ENABLE_SERVICEGROUP_SVC_NOTIFICATIONS;
617
else if(!strcmp(command_id,"DISABLE_SERVICEGROUP_SVC_NOTIFICATIONS"))
618
command_type=CMD_DISABLE_SERVICEGROUP_SVC_NOTIFICATIONS;
620
else if(!strcmp(command_id,"ENABLE_SERVICEGROUP_HOST_CHECKS"))
621
command_type=CMD_ENABLE_SERVICEGROUP_HOST_CHECKS;
622
else if(!strcmp(command_id,"DISABLE_SERVICEGROUP_HOST_CHECKS"))
623
command_type=CMD_DISABLE_SERVICEGROUP_HOST_CHECKS;
625
else if(!strcmp(command_id,"ENABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS"))
626
command_type=CMD_ENABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS;
627
else if(!strcmp(command_id,"DISABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS"))
628
command_type=CMD_DISABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS;
630
else if(!strcmp(command_id,"ENABLE_SERVICEGROUP_SVC_CHECKS"))
631
command_type=CMD_ENABLE_SERVICEGROUP_SVC_CHECKS;
632
else if(!strcmp(command_id,"DISABLE_SERVICEGROUP_SVC_CHECKS"))
633
command_type=CMD_DISABLE_SERVICEGROUP_SVC_CHECKS;
635
else if(!strcmp(command_id,"ENABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS"))
636
command_type=CMD_ENABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS;
637
else if(!strcmp(command_id,"DISABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS"))
638
command_type=CMD_DISABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS;
640
else if(!strcmp(command_id,"SCHEDULE_SERVICEGROUP_HOST_DOWNTIME"))
641
command_type=CMD_SCHEDULE_SERVICEGROUP_HOST_DOWNTIME;
642
else if(!strcmp(command_id,"SCHEDULE_SERVICEGROUP_SVC_DOWNTIME"))
643
command_type=CMD_SCHEDULE_SERVICEGROUP_SVC_DOWNTIME;
616
else if(!strcmp(command_id, "ENABLE_SERVICEGROUP_HOST_NOTIFICATIONS"))
617
command_type = CMD_ENABLE_SERVICEGROUP_HOST_NOTIFICATIONS;
618
else if(!strcmp(command_id, "DISABLE_SERVICEGROUP_HOST_NOTIFICATIONS"))
619
command_type = CMD_DISABLE_SERVICEGROUP_HOST_NOTIFICATIONS;
621
else if(!strcmp(command_id, "ENABLE_SERVICEGROUP_SVC_NOTIFICATIONS"))
622
command_type = CMD_ENABLE_SERVICEGROUP_SVC_NOTIFICATIONS;
623
else if(!strcmp(command_id, "DISABLE_SERVICEGROUP_SVC_NOTIFICATIONS"))
624
command_type = CMD_DISABLE_SERVICEGROUP_SVC_NOTIFICATIONS;
626
else if(!strcmp(command_id, "ENABLE_SERVICEGROUP_HOST_CHECKS"))
627
command_type = CMD_ENABLE_SERVICEGROUP_HOST_CHECKS;
628
else if(!strcmp(command_id, "DISABLE_SERVICEGROUP_HOST_CHECKS"))
629
command_type = CMD_DISABLE_SERVICEGROUP_HOST_CHECKS;
631
else if(!strcmp(command_id, "ENABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS"))
632
command_type = CMD_ENABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS;
633
else if(!strcmp(command_id, "DISABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS"))
634
command_type = CMD_DISABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS;
636
else if(!strcmp(command_id, "ENABLE_SERVICEGROUP_SVC_CHECKS"))
637
command_type = CMD_ENABLE_SERVICEGROUP_SVC_CHECKS;
638
else if(!strcmp(command_id, "DISABLE_SERVICEGROUP_SVC_CHECKS"))
639
command_type = CMD_DISABLE_SERVICEGROUP_SVC_CHECKS;
641
else if(!strcmp(command_id, "ENABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS"))
642
command_type = CMD_ENABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS;
643
else if(!strcmp(command_id, "DISABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS"))
644
command_type = CMD_DISABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS;
646
else if(!strcmp(command_id, "SCHEDULE_SERVICEGROUP_HOST_DOWNTIME"))
647
command_type = CMD_SCHEDULE_SERVICEGROUP_HOST_DOWNTIME;
648
else if(!strcmp(command_id, "SCHEDULE_SERVICEGROUP_SVC_DOWNTIME"))
649
command_type = CMD_SCHEDULE_SERVICEGROUP_SVC_DOWNTIME;
646
652
/**********************************/
647
653
/**** CONTACT-RELATED COMMANDS ****/
648
654
/**********************************/
650
else if(!strcmp(command_id,"ENABLE_CONTACT_HOST_NOTIFICATIONS"))
651
command_type=CMD_ENABLE_CONTACT_HOST_NOTIFICATIONS;
652
else if(!strcmp(command_id,"DISABLE_CONTACT_HOST_NOTIFICATIONS"))
653
command_type=CMD_DISABLE_CONTACT_HOST_NOTIFICATIONS;
655
else if(!strcmp(command_id,"ENABLE_CONTACT_SVC_NOTIFICATIONS"))
656
command_type=CMD_ENABLE_CONTACT_SVC_NOTIFICATIONS;
657
else if(!strcmp(command_id,"DISABLE_CONTACT_SVC_NOTIFICATIONS"))
658
command_type=CMD_DISABLE_CONTACT_SVC_NOTIFICATIONS;
660
else if(!strcmp(command_id,"CHANGE_CONTACT_HOST_NOTIFICATION_TIMEPERIOD"))
661
command_type=CMD_CHANGE_CONTACT_HOST_NOTIFICATION_TIMEPERIOD;
663
else if(!strcmp(command_id,"CHANGE_CONTACT_SVC_NOTIFICATION_TIMEPERIOD"))
664
command_type=CMD_CHANGE_CONTACT_SVC_NOTIFICATION_TIMEPERIOD;
666
else if(!strcmp(command_id,"CHANGE_CONTACT_MODATTR"))
667
command_type=CMD_CHANGE_CONTACT_MODATTR;
668
else if(!strcmp(command_id,"CHANGE_CONTACT_MODHATTR"))
669
command_type=CMD_CHANGE_CONTACT_MODHATTR;
670
else if(!strcmp(command_id,"CHANGE_CONTACT_MODSATTR"))
671
command_type=CMD_CHANGE_CONTACT_MODSATTR;
656
else if(!strcmp(command_id, "ENABLE_CONTACT_HOST_NOTIFICATIONS"))
657
command_type = CMD_ENABLE_CONTACT_HOST_NOTIFICATIONS;
658
else if(!strcmp(command_id, "DISABLE_CONTACT_HOST_NOTIFICATIONS"))
659
command_type = CMD_DISABLE_CONTACT_HOST_NOTIFICATIONS;
661
else if(!strcmp(command_id, "ENABLE_CONTACT_SVC_NOTIFICATIONS"))
662
command_type = CMD_ENABLE_CONTACT_SVC_NOTIFICATIONS;
663
else if(!strcmp(command_id, "DISABLE_CONTACT_SVC_NOTIFICATIONS"))
664
command_type = CMD_DISABLE_CONTACT_SVC_NOTIFICATIONS;
666
else if(!strcmp(command_id, "CHANGE_CONTACT_HOST_NOTIFICATION_TIMEPERIOD"))
667
command_type = CMD_CHANGE_CONTACT_HOST_NOTIFICATION_TIMEPERIOD;
669
else if(!strcmp(command_id, "CHANGE_CONTACT_SVC_NOTIFICATION_TIMEPERIOD"))
670
command_type = CMD_CHANGE_CONTACT_SVC_NOTIFICATION_TIMEPERIOD;
672
else if(!strcmp(command_id, "CHANGE_CONTACT_MODATTR"))
673
command_type = CMD_CHANGE_CONTACT_MODATTR;
674
else if(!strcmp(command_id, "CHANGE_CONTACT_MODHATTR"))
675
command_type = CMD_CHANGE_CONTACT_MODHATTR;
676
else if(!strcmp(command_id, "CHANGE_CONTACT_MODSATTR"))
677
command_type = CMD_CHANGE_CONTACT_MODSATTR;
673
679
/***************************************/
674
680
/**** CONTACTGROUP-RELATED COMMANDS ****/
675
681
/***************************************/
677
else if(!strcmp(command_id,"ENABLE_CONTACTGROUP_HOST_NOTIFICATIONS"))
678
command_type=CMD_ENABLE_CONTACTGROUP_HOST_NOTIFICATIONS;
679
else if(!strcmp(command_id,"DISABLE_CONTACTGROUP_HOST_NOTIFICATIONS"))
680
command_type=CMD_DISABLE_CONTACTGROUP_HOST_NOTIFICATIONS;
683
else if(!strcmp(command_id, "ENABLE_CONTACTGROUP_HOST_NOTIFICATIONS"))
684
command_type = CMD_ENABLE_CONTACTGROUP_HOST_NOTIFICATIONS;
685
else if(!strcmp(command_id, "DISABLE_CONTACTGROUP_HOST_NOTIFICATIONS"))
686
command_type = CMD_DISABLE_CONTACTGROUP_HOST_NOTIFICATIONS;
682
else if(!strcmp(command_id,"ENABLE_CONTACTGROUP_SVC_NOTIFICATIONS"))
683
command_type=CMD_ENABLE_CONTACTGROUP_SVC_NOTIFICATIONS;
684
else if(!strcmp(command_id,"DISABLE_CONTACTGROUP_SVC_NOTIFICATIONS"))
685
command_type=CMD_DISABLE_CONTACTGROUP_SVC_NOTIFICATIONS;
688
else if(!strcmp(command_id, "ENABLE_CONTACTGROUP_SVC_NOTIFICATIONS"))
689
command_type = CMD_ENABLE_CONTACTGROUP_SVC_NOTIFICATIONS;
690
else if(!strcmp(command_id, "DISABLE_CONTACTGROUP_SVC_NOTIFICATIONS"))
691
command_type = CMD_DISABLE_CONTACTGROUP_SVC_NOTIFICATIONS;
688
694
/**************************/
689
695
/****** MISC COMMANDS *****/
690
696
/**************************/
692
else if(!strcmp(command_id,"PROCESS_FILE"))
693
command_type=CMD_PROCESS_FILE;
698
else if(!strcmp(command_id, "PROCESS_FILE"))
699
command_type = CMD_PROCESS_FILE;
697
703
/****************************/
698
704
/****** CUSTOM COMMANDS *****/
699
705
/****************************/
701
else if(command_id[0]=='_')
702
command_type=CMD_CUSTOM_COMMAND;
707
else if(command_id[0] == '_')
708
command_type = CMD_CUSTOM_COMMAND;
706
712
/**** UNKNOWN COMMAND ****/
708
714
/* log the bad external command */
709
logit(NSLOG_EXTERNAL_COMMAND | NSLOG_RUNTIME_WARNING,TRUE,"Warning: Unrecognized external command -> %s;%s\n",command_id,args);
715
logit(NSLOG_EXTERNAL_COMMAND | NSLOG_RUNTIME_WARNING, TRUE, "Warning: Unrecognized external command -> %s;%s\n", command_id, args);
711
717
/* free memory */
712
718
my_free(command_id);
718
724
/* update statistics for external commands */
719
update_check_stats(EXTERNAL_COMMAND_STATS,time(NULL));
725
update_check_stats(EXTERNAL_COMMAND_STATS, time(NULL));
721
727
/* log the external command */
722
asprintf(&temp_buffer,"EXTERNAL COMMAND: %s;%s\n",command_id,args);
723
if(command_type==CMD_PROCESS_SERVICE_CHECK_RESULT || command_type==CMD_PROCESS_HOST_CHECK_RESULT){
728
asprintf(&temp_buffer, "EXTERNAL COMMAND: %s;%s\n", command_id, args);
729
if(command_type == CMD_PROCESS_SERVICE_CHECK_RESULT || command_type == CMD_PROCESS_HOST_CHECK_RESULT) {
724
730
/* passive checks are logged in checks.c as well, as some my bypass external commands by getting dropped in checkresults dir */
725
if(log_passive_checks==TRUE)
726
write_to_all_logs(temp_buffer,NSLOG_PASSIVE_CHECK);
729
if(log_external_commands==TRUE)
730
write_to_all_logs(temp_buffer,NSLOG_EXTERNAL_COMMAND);
731
if(log_passive_checks == TRUE)
732
write_to_all_logs(temp_buffer, NSLOG_PASSIVE_CHECK);
735
if(log_external_commands == TRUE)
736
write_to_all_logs(temp_buffer, NSLOG_EXTERNAL_COMMAND);
732
738
my_free(temp_buffer);
734
740
#ifdef USE_EVENT_BROKER
735
741
/* send data to event broker */
736
broker_external_command(NEBTYPE_EXTERNALCOMMAND_START,NEBFLAG_NONE,NEBATTR_NONE,command_type,entry_time,command_id,args,NULL);
742
broker_external_command(NEBTYPE_EXTERNALCOMMAND_START, NEBFLAG_NONE, NEBATTR_NONE, command_type, entry_time, command_id, args, NULL);
739
745
/* process the command */
740
process_external_command2(command_type,entry_time,args);
746
process_external_command2(command_type, entry_time, args);
742
748
#ifdef USE_EVENT_BROKER
743
749
/* send data to event broker */
744
broker_external_command(NEBTYPE_EXTERNALCOMMAND_END,NEBFLAG_NONE,NEBATTR_NONE,command_type,entry_time,command_id,args,NULL);
750
broker_external_command(NEBTYPE_EXTERNALCOMMAND_END, NEBFLAG_NONE, NEBATTR_NONE, command_type, entry_time, command_id, args, NULL);
747
753
/* free memory */
756
762
/* top-level processor for a single external command */
757
int process_external_command2(int cmd, time_t entry_time, char *args){
759
log_debug_info(DEBUGL_FUNCTIONS,0,"process_external_command2()\n");
761
log_debug_info(DEBUGL_EXTERNALCOMMANDS,1,"External Command Type: %d\n",cmd);
762
log_debug_info(DEBUGL_EXTERNALCOMMANDS,1,"Command Entry Time: %lu\n",(unsigned long)entry_time);
763
log_debug_info(DEBUGL_EXTERNALCOMMANDS,1,"Command Arguments: %s\n",(args==NULL)?"":args);
763
int process_external_command2(int cmd, time_t entry_time, char *args) {
765
log_debug_info(DEBUGL_FUNCTIONS, 0, "process_external_command2()\n");
767
log_debug_info(DEBUGL_EXTERNALCOMMANDS, 1, "External Command Type: %d\n", cmd);
768
log_debug_info(DEBUGL_EXTERNALCOMMANDS, 1, "Command Entry Time: %lu\n", (unsigned long)entry_time);
769
log_debug_info(DEBUGL_EXTERNALCOMMANDS, 1, "Command Arguments: %s\n", (args == NULL) ? "" : args);
765
771
/* how shall we execute the command? */
768
/***************************/
769
/***** SYSTEM COMMANDS *****/
770
/***************************/
772
case CMD_SHUTDOWN_PROCESS:
773
case CMD_RESTART_PROCESS:
774
cmd_signal_process(cmd,args);
777
case CMD_SAVE_STATE_INFORMATION:
778
save_state_information(FALSE);
781
case CMD_READ_STATE_INFORMATION:
782
read_initial_state_information();
785
case CMD_ENABLE_NOTIFICATIONS:
786
enable_all_notifications();
789
case CMD_DISABLE_NOTIFICATIONS:
790
disable_all_notifications();
793
case CMD_START_EXECUTING_SVC_CHECKS:
794
start_executing_service_checks();
797
case CMD_STOP_EXECUTING_SVC_CHECKS:
798
stop_executing_service_checks();
801
case CMD_START_ACCEPTING_PASSIVE_SVC_CHECKS:
802
start_accepting_passive_service_checks();
805
case CMD_STOP_ACCEPTING_PASSIVE_SVC_CHECKS:
806
stop_accepting_passive_service_checks();
809
case CMD_START_OBSESSING_OVER_SVC_CHECKS:
810
start_obsessing_over_service_checks();
813
case CMD_STOP_OBSESSING_OVER_SVC_CHECKS:
814
stop_obsessing_over_service_checks();
817
case CMD_START_EXECUTING_HOST_CHECKS:
818
start_executing_host_checks();
821
case CMD_STOP_EXECUTING_HOST_CHECKS:
822
stop_executing_host_checks();
825
case CMD_START_ACCEPTING_PASSIVE_HOST_CHECKS:
826
start_accepting_passive_host_checks();
829
case CMD_STOP_ACCEPTING_PASSIVE_HOST_CHECKS:
830
stop_accepting_passive_host_checks();
833
case CMD_START_OBSESSING_OVER_HOST_CHECKS:
834
start_obsessing_over_host_checks();
837
case CMD_STOP_OBSESSING_OVER_HOST_CHECKS:
838
stop_obsessing_over_host_checks();
841
case CMD_ENABLE_EVENT_HANDLERS:
842
start_using_event_handlers();
845
case CMD_DISABLE_EVENT_HANDLERS:
846
stop_using_event_handlers();
849
case CMD_ENABLE_FLAP_DETECTION:
850
enable_flap_detection_routines();
853
case CMD_DISABLE_FLAP_DETECTION:
854
disable_flap_detection_routines();
857
case CMD_ENABLE_SERVICE_FRESHNESS_CHECKS:
858
enable_service_freshness_checks();
861
case CMD_DISABLE_SERVICE_FRESHNESS_CHECKS:
862
disable_service_freshness_checks();
865
case CMD_ENABLE_HOST_FRESHNESS_CHECKS:
866
enable_host_freshness_checks();
869
case CMD_DISABLE_HOST_FRESHNESS_CHECKS:
870
disable_host_freshness_checks();
873
case CMD_ENABLE_FAILURE_PREDICTION:
874
enable_all_failure_prediction();
877
case CMD_DISABLE_FAILURE_PREDICTION:
878
disable_all_failure_prediction();
881
case CMD_ENABLE_PERFORMANCE_DATA:
882
enable_performance_data();
885
case CMD_DISABLE_PERFORMANCE_DATA:
886
disable_performance_data();
890
/***************************/
891
/***** HOST COMMANDS *****/
892
/***************************/
894
case CMD_ENABLE_HOST_CHECK:
895
case CMD_DISABLE_HOST_CHECK:
896
case CMD_ENABLE_PASSIVE_HOST_CHECKS:
897
case CMD_DISABLE_PASSIVE_HOST_CHECKS:
898
case CMD_ENABLE_HOST_SVC_CHECKS:
899
case CMD_DISABLE_HOST_SVC_CHECKS:
900
case CMD_ENABLE_HOST_NOTIFICATIONS:
901
case CMD_DISABLE_HOST_NOTIFICATIONS:
902
case CMD_ENABLE_ALL_NOTIFICATIONS_BEYOND_HOST:
903
case CMD_DISABLE_ALL_NOTIFICATIONS_BEYOND_HOST:
904
case CMD_ENABLE_HOST_AND_CHILD_NOTIFICATIONS:
905
case CMD_DISABLE_HOST_AND_CHILD_NOTIFICATIONS:
906
case CMD_ENABLE_HOST_SVC_NOTIFICATIONS:
907
case CMD_DISABLE_HOST_SVC_NOTIFICATIONS:
908
case CMD_ENABLE_HOST_FLAP_DETECTION:
909
case CMD_DISABLE_HOST_FLAP_DETECTION:
910
case CMD_ENABLE_HOST_EVENT_HANDLER:
911
case CMD_DISABLE_HOST_EVENT_HANDLER:
912
case CMD_START_OBSESSING_OVER_HOST:
913
case CMD_STOP_OBSESSING_OVER_HOST:
914
case CMD_SET_HOST_NOTIFICATION_NUMBER:
915
case CMD_SEND_CUSTOM_HOST_NOTIFICATION:
916
process_host_command(cmd,entry_time,args);
920
/*****************************/
921
/***** HOSTGROUP COMMANDS ****/
922
/*****************************/
924
case CMD_ENABLE_HOSTGROUP_HOST_NOTIFICATIONS:
925
case CMD_DISABLE_HOSTGROUP_HOST_NOTIFICATIONS:
926
case CMD_ENABLE_HOSTGROUP_SVC_NOTIFICATIONS:
927
case CMD_DISABLE_HOSTGROUP_SVC_NOTIFICATIONS:
928
case CMD_ENABLE_HOSTGROUP_HOST_CHECKS:
929
case CMD_DISABLE_HOSTGROUP_HOST_CHECKS:
930
case CMD_ENABLE_HOSTGROUP_PASSIVE_HOST_CHECKS:
931
case CMD_DISABLE_HOSTGROUP_PASSIVE_HOST_CHECKS:
932
case CMD_ENABLE_HOSTGROUP_SVC_CHECKS:
933
case CMD_DISABLE_HOSTGROUP_SVC_CHECKS:
934
case CMD_ENABLE_HOSTGROUP_PASSIVE_SVC_CHECKS:
935
case CMD_DISABLE_HOSTGROUP_PASSIVE_SVC_CHECKS:
936
process_hostgroup_command(cmd,entry_time,args);
940
/***************************/
941
/***** SERVICE COMMANDS ****/
942
/***************************/
944
case CMD_ENABLE_SVC_CHECK:
945
case CMD_DISABLE_SVC_CHECK:
946
case CMD_ENABLE_PASSIVE_SVC_CHECKS:
947
case CMD_DISABLE_PASSIVE_SVC_CHECKS:
948
case CMD_ENABLE_SVC_NOTIFICATIONS:
949
case CMD_DISABLE_SVC_NOTIFICATIONS:
950
case CMD_ENABLE_SVC_FLAP_DETECTION:
951
case CMD_DISABLE_SVC_FLAP_DETECTION:
952
case CMD_ENABLE_SVC_EVENT_HANDLER:
953
case CMD_DISABLE_SVC_EVENT_HANDLER:
954
case CMD_START_OBSESSING_OVER_SVC:
955
case CMD_STOP_OBSESSING_OVER_SVC:
956
case CMD_SET_SVC_NOTIFICATION_NUMBER:
957
case CMD_SEND_CUSTOM_SVC_NOTIFICATION:
958
process_service_command(cmd,entry_time,args);
962
/********************************/
963
/***** SERVICEGROUP COMMANDS ****/
964
/********************************/
966
case CMD_ENABLE_SERVICEGROUP_HOST_NOTIFICATIONS:
967
case CMD_DISABLE_SERVICEGROUP_HOST_NOTIFICATIONS:
968
case CMD_ENABLE_SERVICEGROUP_SVC_NOTIFICATIONS:
969
case CMD_DISABLE_SERVICEGROUP_SVC_NOTIFICATIONS:
970
case CMD_ENABLE_SERVICEGROUP_HOST_CHECKS:
971
case CMD_DISABLE_SERVICEGROUP_HOST_CHECKS:
972
case CMD_ENABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS:
973
case CMD_DISABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS:
974
case CMD_ENABLE_SERVICEGROUP_SVC_CHECKS:
975
case CMD_DISABLE_SERVICEGROUP_SVC_CHECKS:
976
case CMD_ENABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS:
977
case CMD_DISABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS:
978
process_servicegroup_command(cmd,entry_time,args);
982
/**********************************/
983
/**** CONTACT-RELATED COMMANDS ****/
984
/**********************************/
986
case CMD_ENABLE_CONTACT_HOST_NOTIFICATIONS:
987
case CMD_DISABLE_CONTACT_HOST_NOTIFICATIONS:
988
case CMD_ENABLE_CONTACT_SVC_NOTIFICATIONS:
989
case CMD_DISABLE_CONTACT_SVC_NOTIFICATIONS:
990
process_contact_command(cmd,entry_time,args);
994
/***************************************/
995
/**** CONTACTGROUP-RELATED COMMANDS ****/
996
/***************************************/
998
case CMD_ENABLE_CONTACTGROUP_HOST_NOTIFICATIONS:
999
case CMD_DISABLE_CONTACTGROUP_HOST_NOTIFICATIONS:
1000
case CMD_ENABLE_CONTACTGROUP_SVC_NOTIFICATIONS:
1001
case CMD_DISABLE_CONTACTGROUP_SVC_NOTIFICATIONS:
1002
process_contactgroup_command(cmd,entry_time,args);
1006
/***************************/
1007
/**** UNSORTED COMMANDS ****/
1008
/***************************/
1011
case CMD_ADD_HOST_COMMENT:
1012
case CMD_ADD_SVC_COMMENT:
1013
cmd_add_comment(cmd,entry_time,args);
1016
case CMD_DEL_HOST_COMMENT:
1017
case CMD_DEL_SVC_COMMENT:
1018
cmd_delete_comment(cmd,args);
1021
case CMD_DELAY_HOST_NOTIFICATION:
1022
case CMD_DELAY_SVC_NOTIFICATION:
1023
cmd_delay_notification(cmd,args);
1026
case CMD_SCHEDULE_SVC_CHECK:
1027
case CMD_SCHEDULE_FORCED_SVC_CHECK:
1028
cmd_schedule_check(cmd,args);
1031
case CMD_SCHEDULE_HOST_SVC_CHECKS:
1032
case CMD_SCHEDULE_FORCED_HOST_SVC_CHECKS:
1033
cmd_schedule_check(cmd,args);
1036
case CMD_DEL_ALL_HOST_COMMENTS:
1037
case CMD_DEL_ALL_SVC_COMMENTS:
1038
cmd_delete_all_comments(cmd,args);
1041
case CMD_PROCESS_SERVICE_CHECK_RESULT:
1042
cmd_process_service_check_result(cmd,entry_time,args);
1045
case CMD_PROCESS_HOST_CHECK_RESULT:
1046
cmd_process_host_check_result(cmd,entry_time,args);
1049
case CMD_ACKNOWLEDGE_HOST_PROBLEM:
1050
case CMD_ACKNOWLEDGE_SVC_PROBLEM:
1051
cmd_acknowledge_problem(cmd,args);
1054
case CMD_REMOVE_HOST_ACKNOWLEDGEMENT:
1055
case CMD_REMOVE_SVC_ACKNOWLEDGEMENT:
1056
cmd_remove_acknowledgement(cmd,args);
1059
case CMD_SCHEDULE_HOST_DOWNTIME:
1060
case CMD_SCHEDULE_SVC_DOWNTIME:
1061
case CMD_SCHEDULE_HOST_SVC_DOWNTIME:
1062
case CMD_SCHEDULE_HOSTGROUP_HOST_DOWNTIME:
1063
case CMD_SCHEDULE_HOSTGROUP_SVC_DOWNTIME:
1064
case CMD_SCHEDULE_SERVICEGROUP_HOST_DOWNTIME:
1065
case CMD_SCHEDULE_SERVICEGROUP_SVC_DOWNTIME:
1066
case CMD_SCHEDULE_AND_PROPAGATE_HOST_DOWNTIME:
1067
case CMD_SCHEDULE_AND_PROPAGATE_TRIGGERED_HOST_DOWNTIME:
1068
cmd_schedule_downtime(cmd,entry_time,args);
1071
case CMD_DEL_HOST_DOWNTIME:
1072
case CMD_DEL_SVC_DOWNTIME:
1073
cmd_delete_downtime(cmd,args);
1076
case CMD_CANCEL_ACTIVE_HOST_SVC_DOWNTIME:
1077
case CMD_CANCEL_PENDING_HOST_SVC_DOWNTIME:
1080
case CMD_SCHEDULE_HOST_CHECK:
1081
case CMD_SCHEDULE_FORCED_HOST_CHECK:
1082
cmd_schedule_check(cmd,args);
1085
case CMD_CHANGE_GLOBAL_HOST_EVENT_HANDLER:
1086
case CMD_CHANGE_GLOBAL_SVC_EVENT_HANDLER:
1087
case CMD_CHANGE_HOST_EVENT_HANDLER:
1088
case CMD_CHANGE_SVC_EVENT_HANDLER:
1089
case CMD_CHANGE_HOST_CHECK_COMMAND:
1090
case CMD_CHANGE_SVC_CHECK_COMMAND:
1091
case CMD_CHANGE_HOST_CHECK_TIMEPERIOD:
1092
case CMD_CHANGE_SVC_CHECK_TIMEPERIOD:
1093
case CMD_CHANGE_HOST_NOTIFICATION_TIMEPERIOD:
1094
case CMD_CHANGE_SVC_NOTIFICATION_TIMEPERIOD:
1095
case CMD_CHANGE_CONTACT_HOST_NOTIFICATION_TIMEPERIOD:
1096
case CMD_CHANGE_CONTACT_SVC_NOTIFICATION_TIMEPERIOD:
1097
cmd_change_object_char_var(cmd,args);
1100
case CMD_CHANGE_NORMAL_HOST_CHECK_INTERVAL:
1101
case CMD_CHANGE_RETRY_HOST_CHECK_INTERVAL:
1102
case CMD_CHANGE_NORMAL_SVC_CHECK_INTERVAL:
1103
case CMD_CHANGE_RETRY_SVC_CHECK_INTERVAL:
1104
case CMD_CHANGE_MAX_HOST_CHECK_ATTEMPTS:
1105
case CMD_CHANGE_MAX_SVC_CHECK_ATTEMPTS:
1106
case CMD_CHANGE_HOST_MODATTR:
1107
case CMD_CHANGE_SVC_MODATTR:
1108
case CMD_CHANGE_CONTACT_MODATTR:
1109
case CMD_CHANGE_CONTACT_MODHATTR:
1110
case CMD_CHANGE_CONTACT_MODSATTR:
1111
cmd_change_object_int_var(cmd,args);
1114
case CMD_CHANGE_CUSTOM_HOST_VAR:
1115
case CMD_CHANGE_CUSTOM_SVC_VAR:
1116
case CMD_CHANGE_CUSTOM_CONTACT_VAR:
1117
cmd_change_object_custom_var(cmd,args);
1121
/***********************/
1122
/**** MISC COMMANDS ****/
1123
/***********************/
1126
case CMD_PROCESS_FILE:
1127
cmd_process_external_commands_from_file(cmd,args);
1131
/*************************/
1132
/**** CUSTOM COMMANDS ****/
1133
/*************************/
1136
case CMD_CUSTOM_COMMAND:
1137
/* custom commands aren't handled internally by Nagios, but may be by NEB modules */
1149
/* processes an external host command */
1150
int process_host_command(int cmd, time_t entry_time, char *args){
1151
char *host_name=NULL;
1152
host *temp_host=NULL;
1153
service *temp_service=NULL;
1154
servicesmember *temp_servicesmember=NULL;
1156
char *buf[2]={NULL,NULL};
1159
printf("ARGS: %s\n",args);
1161
/* get the host name */
1162
if((host_name=my_strtok(args,";"))==NULL)
1166
if((temp_host=find_host(host_name))==NULL)
1171
case CMD_ENABLE_HOST_NOTIFICATIONS:
1172
enable_host_notifications(temp_host);
1175
case CMD_DISABLE_HOST_NOTIFICATIONS:
1176
disable_host_notifications(temp_host);
1179
case CMD_ENABLE_HOST_AND_CHILD_NOTIFICATIONS:
1180
enable_and_propagate_notifications(temp_host,0,TRUE,TRUE,FALSE);
1183
case CMD_DISABLE_HOST_AND_CHILD_NOTIFICATIONS:
1184
disable_and_propagate_notifications(temp_host,0,TRUE,TRUE,FALSE);
1187
case CMD_ENABLE_ALL_NOTIFICATIONS_BEYOND_HOST:
1188
enable_and_propagate_notifications(temp_host,0,FALSE,TRUE,TRUE);
1191
case CMD_DISABLE_ALL_NOTIFICATIONS_BEYOND_HOST:
1192
disable_and_propagate_notifications(temp_host,0,FALSE,TRUE,TRUE);
1195
case CMD_ENABLE_HOST_SVC_NOTIFICATIONS:
1196
case CMD_DISABLE_HOST_SVC_NOTIFICATIONS:
1197
for(temp_servicesmember=temp_host->services;temp_servicesmember!=NULL;temp_servicesmember=temp_servicesmember->next){
1198
if((temp_service=temp_servicesmember->service_ptr)==NULL)
1200
if(cmd==CMD_ENABLE_HOST_SVC_NOTIFICATIONS)
1201
enable_service_notifications(temp_service);
1203
disable_service_notifications(temp_service);
1207
case CMD_ENABLE_HOST_SVC_CHECKS:
1208
case CMD_DISABLE_HOST_SVC_CHECKS:
1209
for(temp_servicesmember=temp_host->services;temp_servicesmember!=NULL;temp_servicesmember=temp_servicesmember->next){
1210
if((temp_service=temp_servicesmember->service_ptr)==NULL)
1212
if(cmd==CMD_ENABLE_HOST_SVC_CHECKS)
1213
enable_service_checks(temp_service);
1215
disable_service_checks(temp_service);
1219
case CMD_ENABLE_HOST_CHECK:
1220
enable_host_checks(temp_host);
1223
case CMD_DISABLE_HOST_CHECK:
1224
disable_host_checks(temp_host);
1227
case CMD_ENABLE_HOST_EVENT_HANDLER:
1228
enable_host_event_handler(temp_host);
1231
case CMD_DISABLE_HOST_EVENT_HANDLER:
1232
disable_host_event_handler(temp_host);
1235
case CMD_ENABLE_HOST_FLAP_DETECTION:
1236
enable_host_flap_detection(temp_host);
1239
case CMD_DISABLE_HOST_FLAP_DETECTION:
1240
disable_host_flap_detection(temp_host);
1243
case CMD_ENABLE_PASSIVE_HOST_CHECKS:
1244
enable_passive_host_checks(temp_host);
1247
case CMD_DISABLE_PASSIVE_HOST_CHECKS:
1248
disable_passive_host_checks(temp_host);
1251
case CMD_START_OBSESSING_OVER_HOST:
1252
start_obsessing_over_host(temp_host);
1255
case CMD_STOP_OBSESSING_OVER_HOST:
1256
stop_obsessing_over_host(temp_host);
1259
case CMD_SET_HOST_NOTIFICATION_NUMBER:
1260
if((str=my_strtok(NULL,";"))){
1262
set_host_notification_number(temp_host,intval);
1266
case CMD_SEND_CUSTOM_HOST_NOTIFICATION:
1267
if((str=my_strtok(NULL,";")))
1269
str=my_strtok(NULL,";");
1272
str=my_strtok(NULL,";");
1275
if(buf[0] && buf[1])
1276
host_notification(temp_host,NOTIFICATION_CUSTOM,buf[0],buf[1],intval);
1287
/* processes an external hostgroup command */
1288
int process_hostgroup_command(int cmd, time_t entry_time, char *args){
1289
char *hostgroup_name=NULL;
1290
hostgroup *temp_hostgroup=NULL;
1291
hostsmember *temp_member=NULL;
1292
host *temp_host=NULL;
1293
service *temp_service=NULL;
1294
servicesmember *temp_servicesmember=NULL;
1296
/* get the hostgroup name */
1297
if((hostgroup_name=my_strtok(args,";"))==NULL)
1300
/* find the hostgroup */
1301
if((temp_hostgroup=find_hostgroup(hostgroup_name))==NULL)
1304
/* loop through all hosts in the hostgroup */
1305
for(temp_member=temp_hostgroup->members;temp_member!=NULL;temp_member=temp_member->next){
1307
if((temp_host=(host *)temp_member->host_ptr)==NULL)
774
/***************************/
775
/***** SYSTEM COMMANDS *****/
776
/***************************/
778
case CMD_SHUTDOWN_PROCESS:
779
case CMD_RESTART_PROCESS:
780
cmd_signal_process(cmd, args);
783
case CMD_SAVE_STATE_INFORMATION:
784
save_state_information(FALSE);
787
case CMD_READ_STATE_INFORMATION:
788
read_initial_state_information();
791
case CMD_ENABLE_NOTIFICATIONS:
792
enable_all_notifications();
795
case CMD_DISABLE_NOTIFICATIONS:
796
disable_all_notifications();
799
case CMD_START_EXECUTING_SVC_CHECKS:
800
start_executing_service_checks();
803
case CMD_STOP_EXECUTING_SVC_CHECKS:
804
stop_executing_service_checks();
807
case CMD_START_ACCEPTING_PASSIVE_SVC_CHECKS:
808
start_accepting_passive_service_checks();
811
case CMD_STOP_ACCEPTING_PASSIVE_SVC_CHECKS:
812
stop_accepting_passive_service_checks();
815
case CMD_START_OBSESSING_OVER_SVC_CHECKS:
816
start_obsessing_over_service_checks();
819
case CMD_STOP_OBSESSING_OVER_SVC_CHECKS:
820
stop_obsessing_over_service_checks();
823
case CMD_START_EXECUTING_HOST_CHECKS:
824
start_executing_host_checks();
827
case CMD_STOP_EXECUTING_HOST_CHECKS:
828
stop_executing_host_checks();
831
case CMD_START_ACCEPTING_PASSIVE_HOST_CHECKS:
832
start_accepting_passive_host_checks();
835
case CMD_STOP_ACCEPTING_PASSIVE_HOST_CHECKS:
836
stop_accepting_passive_host_checks();
839
case CMD_START_OBSESSING_OVER_HOST_CHECKS:
840
start_obsessing_over_host_checks();
843
case CMD_STOP_OBSESSING_OVER_HOST_CHECKS:
844
stop_obsessing_over_host_checks();
847
case CMD_ENABLE_EVENT_HANDLERS:
848
start_using_event_handlers();
851
case CMD_DISABLE_EVENT_HANDLERS:
852
stop_using_event_handlers();
855
case CMD_ENABLE_FLAP_DETECTION:
856
enable_flap_detection_routines();
859
case CMD_DISABLE_FLAP_DETECTION:
860
disable_flap_detection_routines();
863
case CMD_ENABLE_SERVICE_FRESHNESS_CHECKS:
864
enable_service_freshness_checks();
867
case CMD_DISABLE_SERVICE_FRESHNESS_CHECKS:
868
disable_service_freshness_checks();
871
case CMD_ENABLE_HOST_FRESHNESS_CHECKS:
872
enable_host_freshness_checks();
875
case CMD_DISABLE_HOST_FRESHNESS_CHECKS:
876
disable_host_freshness_checks();
879
case CMD_ENABLE_FAILURE_PREDICTION:
880
enable_all_failure_prediction();
883
case CMD_DISABLE_FAILURE_PREDICTION:
884
disable_all_failure_prediction();
887
case CMD_ENABLE_PERFORMANCE_DATA:
888
enable_performance_data();
891
case CMD_DISABLE_PERFORMANCE_DATA:
892
disable_performance_data();
896
/***************************/
897
/***** HOST COMMANDS *****/
898
/***************************/
900
case CMD_ENABLE_HOST_CHECK:
901
case CMD_DISABLE_HOST_CHECK:
902
case CMD_ENABLE_PASSIVE_HOST_CHECKS:
903
case CMD_DISABLE_PASSIVE_HOST_CHECKS:
904
case CMD_ENABLE_HOST_SVC_CHECKS:
905
case CMD_DISABLE_HOST_SVC_CHECKS:
906
case CMD_ENABLE_HOST_NOTIFICATIONS:
907
case CMD_DISABLE_HOST_NOTIFICATIONS:
908
case CMD_ENABLE_ALL_NOTIFICATIONS_BEYOND_HOST:
909
case CMD_DISABLE_ALL_NOTIFICATIONS_BEYOND_HOST:
910
case CMD_ENABLE_HOST_AND_CHILD_NOTIFICATIONS:
911
case CMD_DISABLE_HOST_AND_CHILD_NOTIFICATIONS:
912
case CMD_ENABLE_HOST_SVC_NOTIFICATIONS:
913
case CMD_DISABLE_HOST_SVC_NOTIFICATIONS:
914
case CMD_ENABLE_HOST_FLAP_DETECTION:
915
case CMD_DISABLE_HOST_FLAP_DETECTION:
916
case CMD_ENABLE_HOST_EVENT_HANDLER:
917
case CMD_DISABLE_HOST_EVENT_HANDLER:
918
case CMD_START_OBSESSING_OVER_HOST:
919
case CMD_STOP_OBSESSING_OVER_HOST:
920
case CMD_SET_HOST_NOTIFICATION_NUMBER:
921
case CMD_SEND_CUSTOM_HOST_NOTIFICATION:
922
process_host_command(cmd, entry_time, args);
926
/*****************************/
927
/***** HOSTGROUP COMMANDS ****/
928
/*****************************/
1312
930
case CMD_ENABLE_HOSTGROUP_HOST_NOTIFICATIONS:
1313
enable_host_notifications(temp_host);
1316
931
case CMD_DISABLE_HOSTGROUP_HOST_NOTIFICATIONS:
1317
disable_host_notifications(temp_host);
932
case CMD_ENABLE_HOSTGROUP_SVC_NOTIFICATIONS:
933
case CMD_DISABLE_HOSTGROUP_SVC_NOTIFICATIONS:
1320
934
case CMD_ENABLE_HOSTGROUP_HOST_CHECKS:
1321
enable_host_checks(temp_host);
1324
935
case CMD_DISABLE_HOSTGROUP_HOST_CHECKS:
1325
disable_host_checks(temp_host);
1328
936
case CMD_ENABLE_HOSTGROUP_PASSIVE_HOST_CHECKS:
1329
enable_passive_host_checks(temp_host);
1332
937
case CMD_DISABLE_HOSTGROUP_PASSIVE_HOST_CHECKS:
1333
disable_passive_host_checks(temp_host);
938
case CMD_ENABLE_HOSTGROUP_SVC_CHECKS:
939
case CMD_DISABLE_HOSTGROUP_SVC_CHECKS:
940
case CMD_ENABLE_HOSTGROUP_PASSIVE_SVC_CHECKS:
941
case CMD_DISABLE_HOSTGROUP_PASSIVE_SVC_CHECKS:
942
process_hostgroup_command(cmd, entry_time, args);
946
/***************************/
947
/***** SERVICE COMMANDS ****/
948
/***************************/
950
case CMD_ENABLE_SVC_CHECK:
951
case CMD_DISABLE_SVC_CHECK:
952
case CMD_ENABLE_PASSIVE_SVC_CHECKS:
953
case CMD_DISABLE_PASSIVE_SVC_CHECKS:
954
case CMD_ENABLE_SVC_NOTIFICATIONS:
955
case CMD_DISABLE_SVC_NOTIFICATIONS:
956
case CMD_ENABLE_SVC_FLAP_DETECTION:
957
case CMD_DISABLE_SVC_FLAP_DETECTION:
958
case CMD_ENABLE_SVC_EVENT_HANDLER:
959
case CMD_DISABLE_SVC_EVENT_HANDLER:
960
case CMD_START_OBSESSING_OVER_SVC:
961
case CMD_STOP_OBSESSING_OVER_SVC:
962
case CMD_SET_SVC_NOTIFICATION_NUMBER:
963
case CMD_SEND_CUSTOM_SVC_NOTIFICATION:
964
process_service_command(cmd, entry_time, args);
968
/********************************/
969
/***** SERVICEGROUP COMMANDS ****/
970
/********************************/
972
case CMD_ENABLE_SERVICEGROUP_HOST_NOTIFICATIONS:
973
case CMD_DISABLE_SERVICEGROUP_HOST_NOTIFICATIONS:
974
case CMD_ENABLE_SERVICEGROUP_SVC_NOTIFICATIONS:
975
case CMD_DISABLE_SERVICEGROUP_SVC_NOTIFICATIONS:
976
case CMD_ENABLE_SERVICEGROUP_HOST_CHECKS:
977
case CMD_DISABLE_SERVICEGROUP_HOST_CHECKS:
978
case CMD_ENABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS:
979
case CMD_DISABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS:
980
case CMD_ENABLE_SERVICEGROUP_SVC_CHECKS:
981
case CMD_DISABLE_SERVICEGROUP_SVC_CHECKS:
982
case CMD_ENABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS:
983
case CMD_DISABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS:
984
process_servicegroup_command(cmd, entry_time, args);
988
/**********************************/
989
/**** CONTACT-RELATED COMMANDS ****/
990
/**********************************/
992
case CMD_ENABLE_CONTACT_HOST_NOTIFICATIONS:
993
case CMD_DISABLE_CONTACT_HOST_NOTIFICATIONS:
994
case CMD_ENABLE_CONTACT_SVC_NOTIFICATIONS:
995
case CMD_DISABLE_CONTACT_SVC_NOTIFICATIONS:
996
process_contact_command(cmd, entry_time, args);
1000
/***************************************/
1001
/**** CONTACTGROUP-RELATED COMMANDS ****/
1002
/***************************************/
1004
case CMD_ENABLE_CONTACTGROUP_HOST_NOTIFICATIONS:
1005
case CMD_DISABLE_CONTACTGROUP_HOST_NOTIFICATIONS:
1006
case CMD_ENABLE_CONTACTGROUP_SVC_NOTIFICATIONS:
1007
case CMD_DISABLE_CONTACTGROUP_SVC_NOTIFICATIONS:
1008
process_contactgroup_command(cmd, entry_time, args);
1012
/***************************/
1013
/**** UNSORTED COMMANDS ****/
1014
/***************************/
1017
case CMD_ADD_HOST_COMMENT:
1018
case CMD_ADD_SVC_COMMENT:
1019
cmd_add_comment(cmd, entry_time, args);
1022
case CMD_DEL_HOST_COMMENT:
1023
case CMD_DEL_SVC_COMMENT:
1024
cmd_delete_comment(cmd, args);
1027
case CMD_DELAY_HOST_NOTIFICATION:
1028
case CMD_DELAY_SVC_NOTIFICATION:
1029
cmd_delay_notification(cmd, args);
1032
case CMD_SCHEDULE_SVC_CHECK:
1033
case CMD_SCHEDULE_FORCED_SVC_CHECK:
1034
cmd_schedule_check(cmd, args);
1037
case CMD_SCHEDULE_HOST_SVC_CHECKS:
1038
case CMD_SCHEDULE_FORCED_HOST_SVC_CHECKS:
1039
cmd_schedule_check(cmd, args);
1042
case CMD_DEL_ALL_HOST_COMMENTS:
1043
case CMD_DEL_ALL_SVC_COMMENTS:
1044
cmd_delete_all_comments(cmd, args);
1047
case CMD_PROCESS_SERVICE_CHECK_RESULT:
1048
cmd_process_service_check_result(cmd, entry_time, args);
1051
case CMD_PROCESS_HOST_CHECK_RESULT:
1052
cmd_process_host_check_result(cmd, entry_time, args);
1055
case CMD_ACKNOWLEDGE_HOST_PROBLEM:
1056
case CMD_ACKNOWLEDGE_SVC_PROBLEM:
1057
cmd_acknowledge_problem(cmd, args);
1060
case CMD_REMOVE_HOST_ACKNOWLEDGEMENT:
1061
case CMD_REMOVE_SVC_ACKNOWLEDGEMENT:
1062
cmd_remove_acknowledgement(cmd, args);
1065
case CMD_SCHEDULE_HOST_DOWNTIME:
1066
case CMD_SCHEDULE_SVC_DOWNTIME:
1067
case CMD_SCHEDULE_HOST_SVC_DOWNTIME:
1068
case CMD_SCHEDULE_HOSTGROUP_HOST_DOWNTIME:
1069
case CMD_SCHEDULE_HOSTGROUP_SVC_DOWNTIME:
1070
case CMD_SCHEDULE_SERVICEGROUP_HOST_DOWNTIME:
1071
case CMD_SCHEDULE_SERVICEGROUP_SVC_DOWNTIME:
1072
case CMD_SCHEDULE_AND_PROPAGATE_HOST_DOWNTIME:
1073
case CMD_SCHEDULE_AND_PROPAGATE_TRIGGERED_HOST_DOWNTIME:
1074
cmd_schedule_downtime(cmd, entry_time, args);
1077
case CMD_DEL_HOST_DOWNTIME:
1078
case CMD_DEL_SVC_DOWNTIME:
1079
cmd_delete_downtime(cmd, args);
1082
case CMD_DEL_DOWNTIME_BY_HOST_NAME:
1083
cmd_delete_downtime_by_host_name(cmd, args);
1086
case CMD_DEL_DOWNTIME_BY_HOSTGROUP_NAME:
1087
cmd_delete_downtime_by_hostgroup_name(cmd, args);
1090
case CMD_DEL_DOWNTIME_BY_START_TIME_COMMENT:
1091
cmd_delete_downtime_by_start_time_comment(cmd, args);
1094
case CMD_CANCEL_ACTIVE_HOST_SVC_DOWNTIME:
1095
case CMD_CANCEL_PENDING_HOST_SVC_DOWNTIME:
1098
case CMD_SCHEDULE_HOST_CHECK:
1099
case CMD_SCHEDULE_FORCED_HOST_CHECK:
1100
cmd_schedule_check(cmd, args);
1103
case CMD_CHANGE_GLOBAL_HOST_EVENT_HANDLER:
1104
case CMD_CHANGE_GLOBAL_SVC_EVENT_HANDLER:
1105
case CMD_CHANGE_HOST_EVENT_HANDLER:
1106
case CMD_CHANGE_SVC_EVENT_HANDLER:
1107
case CMD_CHANGE_HOST_CHECK_COMMAND:
1108
case CMD_CHANGE_SVC_CHECK_COMMAND:
1109
case CMD_CHANGE_HOST_CHECK_TIMEPERIOD:
1110
case CMD_CHANGE_SVC_CHECK_TIMEPERIOD:
1111
case CMD_CHANGE_HOST_NOTIFICATION_TIMEPERIOD:
1112
case CMD_CHANGE_SVC_NOTIFICATION_TIMEPERIOD:
1113
case CMD_CHANGE_CONTACT_HOST_NOTIFICATION_TIMEPERIOD:
1114
case CMD_CHANGE_CONTACT_SVC_NOTIFICATION_TIMEPERIOD:
1115
cmd_change_object_char_var(cmd, args);
1118
case CMD_CHANGE_NORMAL_HOST_CHECK_INTERVAL:
1119
case CMD_CHANGE_RETRY_HOST_CHECK_INTERVAL:
1120
case CMD_CHANGE_NORMAL_SVC_CHECK_INTERVAL:
1121
case CMD_CHANGE_RETRY_SVC_CHECK_INTERVAL:
1122
case CMD_CHANGE_MAX_HOST_CHECK_ATTEMPTS:
1123
case CMD_CHANGE_MAX_SVC_CHECK_ATTEMPTS:
1124
case CMD_CHANGE_HOST_MODATTR:
1125
case CMD_CHANGE_SVC_MODATTR:
1126
case CMD_CHANGE_CONTACT_MODATTR:
1127
case CMD_CHANGE_CONTACT_MODHATTR:
1128
case CMD_CHANGE_CONTACT_MODSATTR:
1129
cmd_change_object_int_var(cmd, args);
1132
case CMD_CHANGE_CUSTOM_HOST_VAR:
1133
case CMD_CHANGE_CUSTOM_SVC_VAR:
1134
case CMD_CHANGE_CUSTOM_CONTACT_VAR:
1135
cmd_change_object_custom_var(cmd, args);
1139
/***********************/
1140
/**** MISC COMMANDS ****/
1141
/***********************/
1144
case CMD_PROCESS_FILE:
1145
cmd_process_external_commands_from_file(cmd, args);
1149
/*************************/
1150
/**** CUSTOM COMMANDS ****/
1151
/*************************/
1154
case CMD_CUSTOM_COMMAND:
1155
/* custom commands aren't handled internally by Nagios, but may be by NEB modules */
1338
/* loop through all services on the host */
1339
for(temp_servicesmember=temp_host->services;temp_servicesmember!=NULL;temp_servicesmember=temp_servicesmember->next){
1340
if((temp_service=temp_servicesmember->service_ptr)==NULL)
1167
/* processes an external host command */
1168
int process_host_command(int cmd, time_t entry_time, char *args) {
1169
char *host_name = NULL;
1170
host *temp_host = NULL;
1171
service *temp_service = NULL;
1172
servicesmember *temp_servicesmember = NULL;
1174
char *buf[2] = {NULL, NULL};
1177
printf("ARGS: %s\n", args);
1179
/* get the host name */
1180
if((host_name = my_strtok(args, ";")) == NULL)
1184
if((temp_host = find_host(host_name)) == NULL)
1189
case CMD_ENABLE_HOST_NOTIFICATIONS:
1190
enable_host_notifications(temp_host);
1193
case CMD_DISABLE_HOST_NOTIFICATIONS:
1194
disable_host_notifications(temp_host);
1197
case CMD_ENABLE_HOST_AND_CHILD_NOTIFICATIONS:
1198
enable_and_propagate_notifications(temp_host, 0, TRUE, TRUE, FALSE);
1201
case CMD_DISABLE_HOST_AND_CHILD_NOTIFICATIONS:
1202
disable_and_propagate_notifications(temp_host, 0, TRUE, TRUE, FALSE);
1205
case CMD_ENABLE_ALL_NOTIFICATIONS_BEYOND_HOST:
1206
enable_and_propagate_notifications(temp_host, 0, FALSE, TRUE, TRUE);
1209
case CMD_DISABLE_ALL_NOTIFICATIONS_BEYOND_HOST:
1210
disable_and_propagate_notifications(temp_host, 0, FALSE, TRUE, TRUE);
1213
case CMD_ENABLE_HOST_SVC_NOTIFICATIONS:
1214
case CMD_DISABLE_HOST_SVC_NOTIFICATIONS:
1215
for(temp_servicesmember = temp_host->services; temp_servicesmember != NULL; temp_servicesmember = temp_servicesmember->next) {
1216
if((temp_service = temp_servicesmember->service_ptr) == NULL)
1345
case CMD_ENABLE_HOSTGROUP_SVC_NOTIFICATIONS:
1218
if(cmd == CMD_ENABLE_HOST_SVC_NOTIFICATIONS)
1346
1219
enable_service_notifications(temp_service);
1349
case CMD_DISABLE_HOSTGROUP_SVC_NOTIFICATIONS:
1350
1221
disable_service_notifications(temp_service);
1353
case CMD_ENABLE_HOSTGROUP_SVC_CHECKS:
1225
case CMD_ENABLE_HOST_SVC_CHECKS:
1226
case CMD_DISABLE_HOST_SVC_CHECKS:
1227
for(temp_servicesmember = temp_host->services; temp_servicesmember != NULL; temp_servicesmember = temp_servicesmember->next) {
1228
if((temp_service = temp_servicesmember->service_ptr) == NULL)
1230
if(cmd == CMD_ENABLE_HOST_SVC_CHECKS)
1354
1231
enable_service_checks(temp_service);
1357
case CMD_DISABLE_HOSTGROUP_SVC_CHECKS:
1358
1233
disable_service_checks(temp_service);
1361
case CMD_ENABLE_HOSTGROUP_PASSIVE_SVC_CHECKS:
1362
enable_passive_service_checks(temp_service);
1365
case CMD_DISABLE_HOSTGROUP_PASSIVE_SVC_CHECKS:
1366
disable_passive_service_checks(temp_service);
1384
/* processes an external service command */
1385
int process_service_command(int cmd, time_t entry_time, char *args){
1386
char *host_name=NULL;
1387
char *svc_description=NULL;
1388
service *temp_service=NULL;
1390
char *buf[2]={NULL,NULL};
1393
/* get the host name */
1394
if((host_name=my_strtok(args,";"))==NULL)
1397
/* get the service description */
1398
if((svc_description=my_strtok(NULL,";"))==NULL)
1401
/* find the service */
1402
if((temp_service=find_service(host_name,svc_description))==NULL)
1407
case CMD_ENABLE_SVC_NOTIFICATIONS:
1408
enable_service_notifications(temp_service);
1411
case CMD_DISABLE_SVC_NOTIFICATIONS:
1412
disable_service_notifications(temp_service);
1415
case CMD_ENABLE_SVC_CHECK:
1416
enable_service_checks(temp_service);
1419
case CMD_DISABLE_SVC_CHECK:
1420
disable_service_checks(temp_service);
1423
case CMD_ENABLE_SVC_EVENT_HANDLER:
1424
enable_service_event_handler(temp_service);
1427
case CMD_DISABLE_SVC_EVENT_HANDLER:
1428
disable_service_event_handler(temp_service);
1431
case CMD_ENABLE_SVC_FLAP_DETECTION:
1432
enable_service_flap_detection(temp_service);
1435
case CMD_DISABLE_SVC_FLAP_DETECTION:
1436
disable_service_flap_detection(temp_service);
1439
case CMD_ENABLE_PASSIVE_SVC_CHECKS:
1440
enable_passive_service_checks(temp_service);
1443
case CMD_DISABLE_PASSIVE_SVC_CHECKS:
1444
disable_passive_service_checks(temp_service);
1447
case CMD_START_OBSESSING_OVER_SVC:
1448
start_obsessing_over_service(temp_service);
1451
case CMD_STOP_OBSESSING_OVER_SVC:
1452
stop_obsessing_over_service(temp_service);
1455
case CMD_SET_SVC_NOTIFICATION_NUMBER:
1456
if((str=my_strtok(NULL,";"))){
1458
set_service_notification_number(temp_service,intval);
1462
case CMD_SEND_CUSTOM_SVC_NOTIFICATION:
1463
if((str=my_strtok(NULL,";")))
1465
str=my_strtok(NULL,";");
1468
str=my_strtok(NULL,";");
1471
if(buf[0] && buf[1])
1472
service_notification(temp_service,NOTIFICATION_CUSTOM,buf[0],buf[1],intval);
1483
/* processes an external servicegroup command */
1484
int process_servicegroup_command(int cmd, time_t entry_time, char *args){
1485
char *servicegroup_name=NULL;
1486
servicegroup *temp_servicegroup=NULL;
1487
servicesmember *temp_member=NULL;
1488
host *temp_host=NULL;
1489
host *last_host=NULL;
1490
service *temp_service=NULL;
1492
/* get the servicegroup name */
1493
if((servicegroup_name=my_strtok(args,";"))==NULL)
1496
/* find the servicegroup */
1497
if((temp_servicegroup=find_servicegroup(servicegroup_name))==NULL)
1502
case CMD_ENABLE_SERVICEGROUP_SVC_NOTIFICATIONS:
1503
case CMD_DISABLE_SERVICEGROUP_SVC_NOTIFICATIONS:
1504
case CMD_ENABLE_SERVICEGROUP_SVC_CHECKS:
1505
case CMD_DISABLE_SERVICEGROUP_SVC_CHECKS:
1506
case CMD_ENABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS:
1507
case CMD_DISABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS:
1509
/* loop through all servicegroup members */
1510
for(temp_member=temp_servicegroup->members;temp_member!=NULL;temp_member=temp_member->next){
1512
temp_service=find_service(temp_member->host_name,temp_member->service_description);
1513
if(temp_service==NULL)
1518
case CMD_ENABLE_SERVICEGROUP_SVC_NOTIFICATIONS:
1519
enable_service_notifications(temp_service);
1522
case CMD_DISABLE_SERVICEGROUP_SVC_NOTIFICATIONS:
1523
disable_service_notifications(temp_service);
1526
case CMD_ENABLE_SERVICEGROUP_SVC_CHECKS:
1527
enable_service_checks(temp_service);
1530
case CMD_DISABLE_SERVICEGROUP_SVC_CHECKS:
1531
disable_service_checks(temp_service);
1534
case CMD_ENABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS:
1535
enable_passive_service_checks(temp_service);
1538
case CMD_DISABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS:
1539
disable_passive_service_checks(temp_service);
1549
case CMD_ENABLE_SERVICEGROUP_HOST_NOTIFICATIONS:
1550
case CMD_DISABLE_SERVICEGROUP_HOST_NOTIFICATIONS:
1551
case CMD_ENABLE_SERVICEGROUP_HOST_CHECKS:
1552
case CMD_DISABLE_SERVICEGROUP_HOST_CHECKS:
1553
case CMD_ENABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS:
1554
case CMD_DISABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS:
1556
/* loop through all hosts that have services belonging to the servicegroup */
1558
for(temp_member=temp_servicegroup->members;temp_member!=NULL;temp_member=temp_member->next){
1560
if((temp_host=find_host(temp_member->host_name))==NULL)
1563
if(temp_host==last_host)
1568
case CMD_ENABLE_SERVICEGROUP_HOST_NOTIFICATIONS:
1237
case CMD_ENABLE_HOST_CHECK:
1238
enable_host_checks(temp_host);
1241
case CMD_DISABLE_HOST_CHECK:
1242
disable_host_checks(temp_host);
1245
case CMD_ENABLE_HOST_EVENT_HANDLER:
1246
enable_host_event_handler(temp_host);
1249
case CMD_DISABLE_HOST_EVENT_HANDLER:
1250
disable_host_event_handler(temp_host);
1253
case CMD_ENABLE_HOST_FLAP_DETECTION:
1254
enable_host_flap_detection(temp_host);
1257
case CMD_DISABLE_HOST_FLAP_DETECTION:
1258
disable_host_flap_detection(temp_host);
1261
case CMD_ENABLE_PASSIVE_HOST_CHECKS:
1262
enable_passive_host_checks(temp_host);
1265
case CMD_DISABLE_PASSIVE_HOST_CHECKS:
1266
disable_passive_host_checks(temp_host);
1269
case CMD_START_OBSESSING_OVER_HOST:
1270
start_obsessing_over_host(temp_host);
1273
case CMD_STOP_OBSESSING_OVER_HOST:
1274
stop_obsessing_over_host(temp_host);
1277
case CMD_SET_HOST_NOTIFICATION_NUMBER:
1278
if((str = my_strtok(NULL, ";"))) {
1280
set_host_notification_number(temp_host, intval);
1284
case CMD_SEND_CUSTOM_HOST_NOTIFICATION:
1285
if((str = my_strtok(NULL, ";")))
1287
str = my_strtok(NULL, ";");
1289
buf[0] = strdup(str);
1290
str = my_strtok(NULL, ";");
1292
buf[1] = strdup(str);
1293
if(buf[0] && buf[1])
1294
host_notification(temp_host, NOTIFICATION_CUSTOM, buf[0], buf[1], intval);
1305
/* processes an external hostgroup command */
1306
int process_hostgroup_command(int cmd, time_t entry_time, char *args) {
1307
char *hostgroup_name = NULL;
1308
hostgroup *temp_hostgroup = NULL;
1309
hostsmember *temp_member = NULL;
1310
host *temp_host = NULL;
1311
service *temp_service = NULL;
1312
servicesmember *temp_servicesmember = NULL;
1314
/* get the hostgroup name */
1315
if((hostgroup_name = my_strtok(args, ";")) == NULL)
1318
/* find the hostgroup */
1319
if((temp_hostgroup = find_hostgroup(hostgroup_name)) == NULL)
1322
/* loop through all hosts in the hostgroup */
1323
for(temp_member = temp_hostgroup->members; temp_member != NULL; temp_member = temp_member->next) {
1325
if((temp_host = (host *)temp_member->host_ptr) == NULL)
1330
case CMD_ENABLE_HOSTGROUP_HOST_NOTIFICATIONS:
1569
1331
enable_host_notifications(temp_host);
1572
case CMD_DISABLE_SERVICEGROUP_HOST_NOTIFICATIONS:
1334
case CMD_DISABLE_HOSTGROUP_HOST_NOTIFICATIONS:
1573
1335
disable_host_notifications(temp_host);
1576
case CMD_ENABLE_SERVICEGROUP_HOST_CHECKS:
1338
case CMD_ENABLE_HOSTGROUP_HOST_CHECKS:
1577
1339
enable_host_checks(temp_host);
1580
case CMD_DISABLE_SERVICEGROUP_HOST_CHECKS:
1342
case CMD_DISABLE_HOSTGROUP_HOST_CHECKS:
1581
1343
disable_host_checks(temp_host);
1584
case CMD_ENABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS:
1346
case CMD_ENABLE_HOSTGROUP_PASSIVE_HOST_CHECKS:
1585
1347
enable_passive_host_checks(temp_host);
1588
case CMD_DISABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS:
1350
case CMD_DISABLE_HOSTGROUP_PASSIVE_HOST_CHECKS:
1589
1351
disable_passive_host_checks(temp_host);
1356
/* loop through all services on the host */
1357
for(temp_servicesmember = temp_host->services; temp_servicesmember != NULL; temp_servicesmember = temp_servicesmember->next) {
1358
if((temp_service = temp_servicesmember->service_ptr) == NULL)
1363
case CMD_ENABLE_HOSTGROUP_SVC_NOTIFICATIONS:
1364
enable_service_notifications(temp_service);
1367
case CMD_DISABLE_HOSTGROUP_SVC_NOTIFICATIONS:
1368
disable_service_notifications(temp_service);
1371
case CMD_ENABLE_HOSTGROUP_SVC_CHECKS:
1372
enable_service_checks(temp_service);
1375
case CMD_DISABLE_HOSTGROUP_SVC_CHECKS:
1376
disable_service_checks(temp_service);
1379
case CMD_ENABLE_HOSTGROUP_PASSIVE_SVC_CHECKS:
1380
enable_passive_service_checks(temp_service);
1383
case CMD_DISABLE_HOSTGROUP_PASSIVE_SVC_CHECKS:
1384
disable_passive_service_checks(temp_service);
1596
last_host=temp_host;
1402
/* processes an external service command */
1403
int process_service_command(int cmd, time_t entry_time, char *args) {
1404
char *host_name = NULL;
1405
char *svc_description = NULL;
1406
service *temp_service = NULL;
1408
char *buf[2] = {NULL, NULL};
1411
/* get the host name */
1412
if((host_name = my_strtok(args, ";")) == NULL)
1415
/* get the service description */
1416
if((svc_description = my_strtok(NULL, ";")) == NULL)
1419
/* find the service */
1420
if((temp_service = find_service(host_name, svc_description)) == NULL)
1425
case CMD_ENABLE_SVC_NOTIFICATIONS:
1426
enable_service_notifications(temp_service);
1429
case CMD_DISABLE_SVC_NOTIFICATIONS:
1430
disable_service_notifications(temp_service);
1433
case CMD_ENABLE_SVC_CHECK:
1434
enable_service_checks(temp_service);
1437
case CMD_DISABLE_SVC_CHECK:
1438
disable_service_checks(temp_service);
1441
case CMD_ENABLE_SVC_EVENT_HANDLER:
1442
enable_service_event_handler(temp_service);
1445
case CMD_DISABLE_SVC_EVENT_HANDLER:
1446
disable_service_event_handler(temp_service);
1449
case CMD_ENABLE_SVC_FLAP_DETECTION:
1450
enable_service_flap_detection(temp_service);
1453
case CMD_DISABLE_SVC_FLAP_DETECTION:
1454
disable_service_flap_detection(temp_service);
1457
case CMD_ENABLE_PASSIVE_SVC_CHECKS:
1458
enable_passive_service_checks(temp_service);
1461
case CMD_DISABLE_PASSIVE_SVC_CHECKS:
1462
disable_passive_service_checks(temp_service);
1465
case CMD_START_OBSESSING_OVER_SVC:
1466
start_obsessing_over_service(temp_service);
1469
case CMD_STOP_OBSESSING_OVER_SVC:
1470
stop_obsessing_over_service(temp_service);
1473
case CMD_SET_SVC_NOTIFICATION_NUMBER:
1474
if((str = my_strtok(NULL, ";"))) {
1476
set_service_notification_number(temp_service, intval);
1480
case CMD_SEND_CUSTOM_SVC_NOTIFICATION:
1481
if((str = my_strtok(NULL, ";")))
1483
str = my_strtok(NULL, ";");
1485
buf[0] = strdup(str);
1486
str = my_strtok(NULL, ";");
1488
buf[1] = strdup(str);
1489
if(buf[0] && buf[1])
1490
service_notification(temp_service, NOTIFICATION_CUSTOM, buf[0], buf[1], intval);
1501
/* processes an external servicegroup command */
1502
int process_servicegroup_command(int cmd, time_t entry_time, char *args) {
1503
char *servicegroup_name = NULL;
1504
servicegroup *temp_servicegroup = NULL;
1505
servicesmember *temp_member = NULL;
1506
host *temp_host = NULL;
1507
host *last_host = NULL;
1508
service *temp_service = NULL;
1510
/* get the servicegroup name */
1511
if((servicegroup_name = my_strtok(args, ";")) == NULL)
1514
/* find the servicegroup */
1515
if((temp_servicegroup = find_servicegroup(servicegroup_name)) == NULL)
1520
case CMD_ENABLE_SERVICEGROUP_SVC_NOTIFICATIONS:
1521
case CMD_DISABLE_SERVICEGROUP_SVC_NOTIFICATIONS:
1522
case CMD_ENABLE_SERVICEGROUP_SVC_CHECKS:
1523
case CMD_DISABLE_SERVICEGROUP_SVC_CHECKS:
1524
case CMD_ENABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS:
1525
case CMD_DISABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS:
1527
/* loop through all servicegroup members */
1528
for(temp_member = temp_servicegroup->members; temp_member != NULL; temp_member = temp_member->next) {
1530
temp_service = find_service(temp_member->host_name, temp_member->service_description);
1531
if(temp_service == NULL)
1536
case CMD_ENABLE_SERVICEGROUP_SVC_NOTIFICATIONS:
1537
enable_service_notifications(temp_service);
1540
case CMD_DISABLE_SERVICEGROUP_SVC_NOTIFICATIONS:
1541
disable_service_notifications(temp_service);
1544
case CMD_ENABLE_SERVICEGROUP_SVC_CHECKS:
1545
enable_service_checks(temp_service);
1548
case CMD_DISABLE_SERVICEGROUP_SVC_CHECKS:
1549
disable_service_checks(temp_service);
1552
case CMD_ENABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS:
1553
enable_passive_service_checks(temp_service);
1556
case CMD_DISABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS:
1557
disable_passive_service_checks(temp_service);
1567
case CMD_ENABLE_SERVICEGROUP_HOST_NOTIFICATIONS:
1568
case CMD_DISABLE_SERVICEGROUP_HOST_NOTIFICATIONS:
1569
case CMD_ENABLE_SERVICEGROUP_HOST_CHECKS:
1570
case CMD_DISABLE_SERVICEGROUP_HOST_CHECKS:
1571
case CMD_ENABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS:
1572
case CMD_DISABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS:
1574
/* loop through all hosts that have services belonging to the servicegroup */
1576
for(temp_member = temp_servicegroup->members; temp_member != NULL; temp_member = temp_member->next) {
1578
if((temp_host = find_host(temp_member->host_name)) == NULL)
1581
if(temp_host == last_host)
1586
case CMD_ENABLE_SERVICEGROUP_HOST_NOTIFICATIONS:
1587
enable_host_notifications(temp_host);
1590
case CMD_DISABLE_SERVICEGROUP_HOST_NOTIFICATIONS:
1591
disable_host_notifications(temp_host);
1594
case CMD_ENABLE_SERVICEGROUP_HOST_CHECKS:
1595
enable_host_checks(temp_host);
1598
case CMD_DISABLE_SERVICEGROUP_HOST_CHECKS:
1599
disable_host_checks(temp_host);
1602
case CMD_ENABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS:
1603
enable_passive_host_checks(temp_host);
1606
case CMD_DISABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS:
1607
disable_passive_host_checks(temp_host);
1614
last_host = temp_host;
1610
1628
/* processes an external contact command */
1611
int process_contact_command(int cmd, time_t entry_time, char *args){
1612
char *contact_name=NULL;
1613
contact *temp_contact=NULL;
1629
int process_contact_command(int cmd, time_t entry_time, char *args) {
1630
char *contact_name = NULL;
1631
contact *temp_contact = NULL;
1615
1633
/* get the contact name */
1616
if((contact_name=my_strtok(args,";"))==NULL)
1634
if((contact_name = my_strtok(args, ";")) == NULL)
1619
1637
/* find the contact */
1620
if((temp_contact=find_contact(contact_name))==NULL)
1638
if((temp_contact = find_contact(contact_name)) == NULL)
1625
case CMD_ENABLE_CONTACT_HOST_NOTIFICATIONS:
1626
enable_contact_host_notifications(temp_contact);
1629
case CMD_DISABLE_CONTACT_HOST_NOTIFICATIONS:
1630
disable_contact_host_notifications(temp_contact);
1633
case CMD_ENABLE_CONTACT_SVC_NOTIFICATIONS:
1634
enable_contact_service_notifications(temp_contact);
1637
case CMD_DISABLE_CONTACT_SVC_NOTIFICATIONS:
1638
disable_contact_service_notifications(temp_contact);
1643
case CMD_ENABLE_CONTACT_HOST_NOTIFICATIONS:
1644
enable_contact_host_notifications(temp_contact);
1647
case CMD_DISABLE_CONTACT_HOST_NOTIFICATIONS:
1648
disable_contact_host_notifications(temp_contact);
1651
case CMD_ENABLE_CONTACT_SVC_NOTIFICATIONS:
1652
enable_contact_service_notifications(temp_contact);
1655
case CMD_DISABLE_CONTACT_SVC_NOTIFICATIONS:
1656
disable_contact_service_notifications(temp_contact);
1649
1667
/* processes an external contactgroup command */
1650
int process_contactgroup_command(int cmd, time_t entry_time, char *args){
1651
char *contactgroup_name=NULL;
1652
contactgroup *temp_contactgroup=NULL;
1653
contactsmember *temp_member=NULL;
1654
contact *temp_contact=NULL;
1668
int process_contactgroup_command(int cmd, time_t entry_time, char *args) {
1669
char *contactgroup_name = NULL;
1670
contactgroup *temp_contactgroup = NULL;
1671
contactsmember *temp_member = NULL;
1672
contact *temp_contact = NULL;
1656
1674
/* get the contactgroup name */
1657
if((contactgroup_name=my_strtok(args,";"))==NULL)
1675
if((contactgroup_name = my_strtok(args, ";")) == NULL)
1660
1678
/* find the contactgroup */
1661
if((temp_contactgroup=find_contactgroup(contactgroup_name))==NULL)
1679
if((temp_contactgroup = find_contactgroup(contactgroup_name)) == NULL)
1666
case CMD_ENABLE_CONTACTGROUP_HOST_NOTIFICATIONS:
1667
case CMD_DISABLE_CONTACTGROUP_HOST_NOTIFICATIONS:
1668
case CMD_ENABLE_CONTACTGROUP_SVC_NOTIFICATIONS:
1669
case CMD_DISABLE_CONTACTGROUP_SVC_NOTIFICATIONS:
1671
/* loop through all contactgroup members */
1672
for(temp_member=temp_contactgroup->members;temp_member!=NULL;temp_member=temp_member->next){
1674
if((temp_contact=temp_member->contact_ptr)==NULL)
1679
case CMD_ENABLE_CONTACTGROUP_HOST_NOTIFICATIONS:
1680
enable_contact_host_notifications(temp_contact);
1683
case CMD_DISABLE_CONTACTGROUP_HOST_NOTIFICATIONS:
1684
disable_contact_host_notifications(temp_contact);
1687
case CMD_ENABLE_CONTACTGROUP_SVC_NOTIFICATIONS:
1688
enable_contact_service_notifications(temp_contact);
1691
case CMD_DISABLE_CONTACTGROUP_SVC_NOTIFICATIONS:
1692
disable_contact_service_notifications(temp_contact);
1684
case CMD_ENABLE_CONTACTGROUP_HOST_NOTIFICATIONS:
1685
case CMD_DISABLE_CONTACTGROUP_HOST_NOTIFICATIONS:
1686
case CMD_ENABLE_CONTACTGROUP_SVC_NOTIFICATIONS:
1687
case CMD_DISABLE_CONTACTGROUP_SVC_NOTIFICATIONS:
1689
/* loop through all contactgroup members */
1690
for(temp_member = temp_contactgroup->members; temp_member != NULL; temp_member = temp_member->next) {
1692
if((temp_contact = temp_member->contact_ptr) == NULL)
1697
case CMD_ENABLE_CONTACTGROUP_HOST_NOTIFICATIONS:
1698
enable_contact_host_notifications(temp_contact);
1701
case CMD_DISABLE_CONTACTGROUP_HOST_NOTIFICATIONS:
1702
disable_contact_host_notifications(temp_contact);
1705
case CMD_ENABLE_CONTACTGROUP_SVC_NOTIFICATIONS:
1706
enable_contact_service_notifications(temp_contact);
1709
case CMD_DISABLE_CONTACTGROUP_SVC_NOTIFICATIONS:
1710
disable_contact_service_notifications(temp_contact);
2381
2399
remove_service_acknowledgement(temp_service);
2388
2406
/* schedules downtime for a specific host or service */
2389
int cmd_schedule_downtime(int cmd, time_t entry_time, char *args){
2390
servicesmember *temp_servicesmember=NULL;
2391
service *temp_service=NULL;
2392
host *temp_host=NULL;
2393
host *last_host=NULL;
2394
hostgroup *temp_hostgroup=NULL;
2395
hostsmember *temp_hgmember=NULL;
2396
servicegroup *temp_servicegroup=NULL;
2397
servicesmember *temp_sgmember=NULL;
2398
char *host_name=NULL;
2399
char *hostgroup_name=NULL;
2400
char *servicegroup_name=NULL;
2401
char *svc_description=NULL;
2402
char *temp_ptr=NULL;
2403
time_t start_time=0L;
2406
unsigned long triggered_by=0L;
2407
unsigned long duration=0L;
2409
char *comment_data=NULL;
2410
unsigned long downtime_id=0L;
2412
if(cmd==CMD_SCHEDULE_HOSTGROUP_HOST_DOWNTIME || cmd==CMD_SCHEDULE_HOSTGROUP_SVC_DOWNTIME){
2407
int cmd_schedule_downtime(int cmd, time_t entry_time, char *args) {
2408
servicesmember *temp_servicesmember = NULL;
2409
service *temp_service = NULL;
2410
host *temp_host = NULL;
2411
host *last_host = NULL;
2412
hostgroup *temp_hostgroup = NULL;
2413
hostsmember *temp_hgmember = NULL;
2414
servicegroup *temp_servicegroup = NULL;
2415
servicesmember *temp_sgmember = NULL;
2416
char *host_name = NULL;
2417
char *hostgroup_name = NULL;
2418
char *servicegroup_name = NULL;
2419
char *svc_description = NULL;
2420
char *temp_ptr = NULL;
2421
time_t start_time = 0L;
2422
time_t end_time = 0L;
2424
unsigned long triggered_by = 0L;
2425
unsigned long duration = 0L;
2426
char *author = NULL;
2427
char *comment_data = NULL;
2428
unsigned long downtime_id = 0L;
2430
if(cmd == CMD_SCHEDULE_HOSTGROUP_HOST_DOWNTIME || cmd == CMD_SCHEDULE_HOSTGROUP_SVC_DOWNTIME) {
2414
2432
/* get the hostgroup name */
2415
if((hostgroup_name=my_strtok(args,";"))==NULL)
2433
if((hostgroup_name = my_strtok(args, ";")) == NULL)
2418
2436
/* verify that the hostgroup is valid */
2419
if((temp_hostgroup=find_hostgroup(hostgroup_name))==NULL)
2437
if((temp_hostgroup = find_hostgroup(hostgroup_name)) == NULL)
2423
else if(cmd==CMD_SCHEDULE_SERVICEGROUP_HOST_DOWNTIME || cmd==CMD_SCHEDULE_SERVICEGROUP_SVC_DOWNTIME){
2441
else if(cmd == CMD_SCHEDULE_SERVICEGROUP_HOST_DOWNTIME || cmd == CMD_SCHEDULE_SERVICEGROUP_SVC_DOWNTIME) {
2425
2443
/* get the servicegroup name */
2426
if((servicegroup_name=my_strtok(args,";"))==NULL)
2444
if((servicegroup_name = my_strtok(args, ";")) == NULL)
2429
2447
/* verify that the servicegroup is valid */
2430
if((temp_servicegroup=find_servicegroup(servicegroup_name))==NULL)
2448
if((temp_servicegroup = find_servicegroup(servicegroup_name)) == NULL)
2436
2454
/* get the host name */
2437
if((host_name=my_strtok(args,";"))==NULL)
2455
if((host_name = my_strtok(args, ";")) == NULL)
2440
2458
/* verify that the host is valid */
2441
if((temp_host=find_host(host_name))==NULL)
2459
if((temp_host = find_host(host_name)) == NULL)
2444
2462
/* this is a service downtime */
2445
if(cmd==CMD_SCHEDULE_SVC_DOWNTIME){
2463
if(cmd == CMD_SCHEDULE_SVC_DOWNTIME) {
2447
2465
/* get the service name */
2448
if((svc_description=my_strtok(NULL,";"))==NULL)
2466
if((svc_description = my_strtok(NULL, ";")) == NULL)
2451
2469
/* verify that the service is valid */
2452
if((temp_service=find_service(temp_host->name,svc_description))==NULL)
2470
if((temp_service = find_service(temp_host->name, svc_description)) == NULL)
2457
2475
/* get the start time */
2458
if((temp_ptr=my_strtok(NULL,";"))==NULL)
2476
if((temp_ptr = my_strtok(NULL, ";")) == NULL)
2460
start_time=(time_t)strtoul(temp_ptr,NULL,10);
2478
start_time = (time_t)strtoul(temp_ptr, NULL, 10);
2462
2480
/* get the end time */
2463
if((temp_ptr=my_strtok(NULL,";"))==NULL)
2481
if((temp_ptr = my_strtok(NULL, ";")) == NULL)
2465
end_time=(time_t)strtoul(temp_ptr,NULL,10);
2483
end_time = (time_t)strtoul(temp_ptr, NULL, 10);
2467
2485
/* get the fixed flag */
2468
if((temp_ptr=my_strtok(NULL,";"))==NULL)
2486
if((temp_ptr = my_strtok(NULL, ";")) == NULL)
2470
fixed=atoi(temp_ptr);
2488
fixed = atoi(temp_ptr);
2472
2490
/* get the trigger id */
2473
if((temp_ptr=my_strtok(NULL,";"))==NULL)
2491
if((temp_ptr = my_strtok(NULL, ";")) == NULL)
2475
triggered_by=strtoul(temp_ptr,NULL,10);
2493
triggered_by = strtoul(temp_ptr, NULL, 10);
2477
2495
/* get the duration */
2478
if((temp_ptr=my_strtok(NULL,";"))==NULL)
2496
if((temp_ptr = my_strtok(NULL, ";")) == NULL)
2480
duration=strtoul(temp_ptr,NULL,10);
2498
duration = strtoul(temp_ptr, NULL, 10);
2482
2500
/* get the author */
2483
if((author=my_strtok(NULL,";"))==NULL)
2501
if((author = my_strtok(NULL, ";")) == NULL)
2486
2504
/* get the comment */
2487
if((comment_data=my_strtok(NULL,";"))==NULL)
2505
if((comment_data = my_strtok(NULL, ";")) == NULL)
2508
/* check if flexible downtime demanded and duration set
2510
according to the documentation, a flexible downtime is
2511
started between start and end time and will last for
2512
"duration" seconds. strtoul converts a NULL value to 0
2513
so if set to 0, bail out as a duration>0 is needed. */
2515
if(fixed == 0 && duration == 0)
2490
2519
/* duration should be auto-calculated, not user-specified */
2492
duration=(unsigned long)(end_time-start_time);
2521
duration = (unsigned long)(end_time - start_time);
2494
2523
/* schedule downtime */
2497
case CMD_SCHEDULE_HOST_DOWNTIME:
2498
schedule_downtime(HOST_DOWNTIME,host_name,NULL,entry_time,author,comment_data,start_time,end_time,fixed,triggered_by,duration,&downtime_id);
2501
case CMD_SCHEDULE_SVC_DOWNTIME:
2502
schedule_downtime(SERVICE_DOWNTIME,host_name,svc_description,entry_time,author,comment_data,start_time,end_time,fixed,triggered_by,duration,&downtime_id);
2505
case CMD_SCHEDULE_HOST_SVC_DOWNTIME:
2506
for(temp_servicesmember=temp_host->services;temp_servicesmember!=NULL;temp_servicesmember=temp_servicesmember->next){
2507
if((temp_service=temp_servicesmember->service_ptr)==NULL)
2509
schedule_downtime(SERVICE_DOWNTIME,host_name,temp_service->description,entry_time,author,comment_data,start_time,end_time,fixed,triggered_by,duration,&downtime_id);
2513
case CMD_SCHEDULE_HOSTGROUP_HOST_DOWNTIME:
2514
for(temp_hgmember=temp_hostgroup->members;temp_hgmember!=NULL;temp_hgmember=temp_hgmember->next)
2515
schedule_downtime(HOST_DOWNTIME,temp_hgmember->host_name,NULL,entry_time,author,comment_data,start_time,end_time,fixed,triggered_by,duration,&downtime_id);
2518
case CMD_SCHEDULE_HOSTGROUP_SVC_DOWNTIME:
2519
for(temp_hgmember=temp_hostgroup->members;temp_hgmember!=NULL;temp_hgmember=temp_hgmember->next){
2520
if((temp_host=temp_hgmember->host_ptr)==NULL)
2522
for(temp_servicesmember=temp_host->services;temp_servicesmember!=NULL;temp_servicesmember=temp_servicesmember->next){
2523
if((temp_service=temp_servicesmember->service_ptr)==NULL)
2525
schedule_downtime(SERVICE_DOWNTIME,temp_service->host_name,temp_service->description,entry_time,author,comment_data,start_time,end_time,fixed,triggered_by,duration,&downtime_id);
2530
case CMD_SCHEDULE_SERVICEGROUP_HOST_DOWNTIME:
2532
for(temp_sgmember=temp_servicegroup->members;temp_sgmember!=NULL;temp_sgmember=temp_sgmember->next){
2533
temp_host=find_host(temp_sgmember->host_name);
2536
if(last_host==temp_host)
2538
schedule_downtime(HOST_DOWNTIME,temp_sgmember->host_name,NULL,entry_time,author,comment_data,start_time,end_time,fixed,triggered_by,duration,&downtime_id);
2539
last_host=temp_host;
2543
case CMD_SCHEDULE_SERVICEGROUP_SVC_DOWNTIME:
2544
for(temp_sgmember=temp_servicegroup->members;temp_sgmember!=NULL;temp_sgmember=temp_sgmember->next)
2545
schedule_downtime(SERVICE_DOWNTIME,temp_sgmember->host_name,temp_sgmember->service_description,entry_time,author,comment_data,start_time,end_time,fixed,triggered_by,duration,&downtime_id);
2548
case CMD_SCHEDULE_AND_PROPAGATE_HOST_DOWNTIME:
2550
/* schedule downtime for "parent" host */
2551
schedule_downtime(HOST_DOWNTIME,host_name,NULL,entry_time,author,comment_data,start_time,end_time,fixed,triggered_by,duration,&downtime_id);
2553
/* schedule (non-triggered) downtime for all child hosts */
2554
schedule_and_propagate_downtime(temp_host,entry_time,author,comment_data,start_time,end_time,fixed,0,duration);
2557
case CMD_SCHEDULE_AND_PROPAGATE_TRIGGERED_HOST_DOWNTIME:
2559
/* schedule downtime for "parent" host */
2560
schedule_downtime(HOST_DOWNTIME,host_name,NULL,entry_time,author,comment_data,start_time,end_time,fixed,triggered_by,duration,&downtime_id);
2562
/* schedule triggered downtime for all child hosts */
2563
schedule_and_propagate_downtime(temp_host,entry_time,author,comment_data,start_time,end_time,fixed,downtime_id,duration);
2526
case CMD_SCHEDULE_HOST_DOWNTIME:
2527
schedule_downtime(HOST_DOWNTIME, host_name, NULL, entry_time, author, comment_data, start_time, end_time, fixed, triggered_by, duration, &downtime_id);
2530
case CMD_SCHEDULE_SVC_DOWNTIME:
2531
schedule_downtime(SERVICE_DOWNTIME, host_name, svc_description, entry_time, author, comment_data, start_time, end_time, fixed, triggered_by, duration, &downtime_id);
2534
case CMD_SCHEDULE_HOST_SVC_DOWNTIME:
2535
for(temp_servicesmember = temp_host->services; temp_servicesmember != NULL; temp_servicesmember = temp_servicesmember->next) {
2536
if((temp_service = temp_servicesmember->service_ptr) == NULL)
2538
schedule_downtime(SERVICE_DOWNTIME, host_name, temp_service->description, entry_time, author, comment_data, start_time, end_time, fixed, triggered_by, duration, &downtime_id);
2542
case CMD_SCHEDULE_HOSTGROUP_HOST_DOWNTIME:
2543
for(temp_hgmember = temp_hostgroup->members; temp_hgmember != NULL; temp_hgmember = temp_hgmember->next)
2544
schedule_downtime(HOST_DOWNTIME, temp_hgmember->host_name, NULL, entry_time, author, comment_data, start_time, end_time, fixed, triggered_by, duration, &downtime_id);
2547
case CMD_SCHEDULE_HOSTGROUP_SVC_DOWNTIME:
2548
for(temp_hgmember = temp_hostgroup->members; temp_hgmember != NULL; temp_hgmember = temp_hgmember->next) {
2549
if((temp_host = temp_hgmember->host_ptr) == NULL)
2551
for(temp_servicesmember = temp_host->services; temp_servicesmember != NULL; temp_servicesmember = temp_servicesmember->next) {
2552
if((temp_service = temp_servicesmember->service_ptr) == NULL)
2554
schedule_downtime(SERVICE_DOWNTIME, temp_service->host_name, temp_service->description, entry_time, author, comment_data, start_time, end_time, fixed, triggered_by, duration, &downtime_id);
2559
case CMD_SCHEDULE_SERVICEGROUP_HOST_DOWNTIME:
2561
for(temp_sgmember = temp_servicegroup->members; temp_sgmember != NULL; temp_sgmember = temp_sgmember->next) {
2562
temp_host = find_host(temp_sgmember->host_name);
2563
if(temp_host == NULL)
2565
if(last_host == temp_host)
2567
schedule_downtime(HOST_DOWNTIME, temp_sgmember->host_name, NULL, entry_time, author, comment_data, start_time, end_time, fixed, triggered_by, duration, &downtime_id);
2568
last_host = temp_host;
2572
case CMD_SCHEDULE_SERVICEGROUP_SVC_DOWNTIME:
2573
for(temp_sgmember = temp_servicegroup->members; temp_sgmember != NULL; temp_sgmember = temp_sgmember->next)
2574
schedule_downtime(SERVICE_DOWNTIME, temp_sgmember->host_name, temp_sgmember->service_description, entry_time, author, comment_data, start_time, end_time, fixed, triggered_by, duration, &downtime_id);
2577
case CMD_SCHEDULE_AND_PROPAGATE_HOST_DOWNTIME:
2579
/* schedule downtime for "parent" host */
2580
schedule_downtime(HOST_DOWNTIME, host_name, NULL, entry_time, author, comment_data, start_time, end_time, fixed, triggered_by, duration, &downtime_id);
2582
/* schedule (non-triggered) downtime for all child hosts */
2583
schedule_and_propagate_downtime(temp_host, entry_time, author, comment_data, start_time, end_time, fixed, 0, duration);
2586
case CMD_SCHEDULE_AND_PROPAGATE_TRIGGERED_HOST_DOWNTIME:
2588
/* schedule downtime for "parent" host */
2589
schedule_downtime(HOST_DOWNTIME, host_name, NULL, entry_time, author, comment_data, start_time, end_time, fixed, triggered_by, duration, &downtime_id);
2591
/* schedule triggered downtime for all child hosts */
2592
schedule_and_propagate_downtime(temp_host, entry_time, author, comment_data, start_time, end_time, fixed, downtime_id, duration);
2575
2604
/* deletes scheduled host or service downtime */
2576
int cmd_delete_downtime(int cmd, char *args){
2577
unsigned long downtime_id=0L;
2578
char *temp_ptr=NULL;
2605
int cmd_delete_downtime(int cmd, char *args) {
2606
unsigned long downtime_id = 0L;
2607
char *temp_ptr = NULL;
2580
2609
/* get the id of the downtime to delete */
2581
if((temp_ptr=my_strtok(args,"\n"))==NULL)
2610
if((temp_ptr = my_strtok(args, "\n")) == NULL)
2583
downtime_id=strtoul(temp_ptr,NULL,10);
2612
downtime_id = strtoul(temp_ptr, NULL, 10);
2585
if(cmd==CMD_DEL_HOST_DOWNTIME)
2586
unschedule_downtime(HOST_DOWNTIME,downtime_id);
2614
if(cmd == CMD_DEL_HOST_DOWNTIME)
2615
unschedule_downtime(HOST_DOWNTIME, downtime_id);
2588
unschedule_downtime(SERVICE_DOWNTIME,downtime_id);
2617
unschedule_downtime(SERVICE_DOWNTIME, downtime_id);
2623
/* Opsview enhancements: some of these commands are now "distributable" as no downtime ids are used */
2624
/* Deletes scheduled host and service downtime based on hostname and optionally other filter arguments */
2625
int cmd_delete_downtime_by_host_name(int cmd, char *args) {
2626
char *temp_ptr = NULL;
2627
char *end_ptr = NULL;
2628
char *hostname = NULL;
2629
char *service_description = NULL;
2630
char *downtime_comment = NULL;
2631
time_t downtime_start_time = 0L;
2634
/* get the host name of the downtime to delete */
2635
temp_ptr = my_strtok(args, ";");
2636
if(temp_ptr == NULL)
2638
hostname = temp_ptr;
2640
/* get the optional service name */
2641
temp_ptr = my_strtok(NULL, ";");
2642
if(temp_ptr != NULL) {
2643
if(*temp_ptr != '\0')
2644
service_description = temp_ptr;
2646
/* get the optional start time */
2647
temp_ptr = my_strtok(NULL, ";");
2648
if(temp_ptr != NULL) {
2649
downtime_start_time = strtoul(temp_ptr, &end_ptr, 10);
2651
/* get the optional comment */
2652
temp_ptr = my_strtok(NULL, ";");
2653
if(temp_ptr != NULL) {
2654
if(*temp_ptr != '\0')
2655
downtime_comment = temp_ptr;
2661
deleted = delete_downtime_by_hostname_service_description_start_time_comment(hostname, service_description, downtime_start_time, downtime_comment);
2669
/* Opsview enhancement: Deletes scheduled host and service downtime based on hostgroup and optionally other filter arguments */
2670
int cmd_delete_downtime_by_hostgroup_name(int cmd, char *args) {
2671
char *temp_ptr = NULL;
2672
char *end_ptr = NULL;
2673
host *temp_host = NULL;
2674
hostgroup *temp_hostgroup = NULL;
2675
hostsmember *temp_member = NULL;
2676
char *service_description = NULL;
2677
char *downtime_comment = NULL;
2678
char *host_name = NULL;
2679
time_t downtime_start_time = 0L;
2682
/* get the host group name of the downtime to delete */
2683
temp_ptr = my_strtok(args, ";");
2684
if(temp_ptr == NULL)
2687
temp_hostgroup = find_hostgroup(temp_ptr);
2688
if(temp_hostgroup == NULL)
2691
/* get the optional host name */
2692
temp_ptr = my_strtok(NULL, ";");
2693
if(temp_ptr != NULL) {
2694
if(*temp_ptr != '\0')
2695
host_name = temp_ptr;
2697
/* get the optional service name */
2698
temp_ptr = my_strtok(NULL, ";");
2699
if(temp_ptr != NULL) {
2700
if(*temp_ptr != '\0')
2701
service_description = temp_ptr;
2703
/* get the optional start time */
2704
temp_ptr = my_strtok(NULL, ";");
2705
if(temp_ptr != NULL) {
2706
downtime_start_time = strtoul(temp_ptr, &end_ptr, 10);
2708
/* get the optional comment */
2709
temp_ptr = my_strtok(NULL, ";");
2710
if(temp_ptr != NULL) {
2711
if(*temp_ptr != '\0')
2712
downtime_comment = temp_ptr;
2718
/* get the optional service name */
2719
temp_ptr = my_strtok(NULL, ";");
2720
if(temp_ptr != NULL) {
2721
if(*temp_ptr != '\0')
2722
service_description = temp_ptr;
2724
/* get the optional start time */
2725
temp_ptr = my_strtok(NULL, ";");
2726
if(temp_ptr != NULL) {
2727
downtime_start_time = strtoul(temp_ptr, &end_ptr, 10);
2729
/* get the optional comment */
2730
temp_ptr = my_strtok(NULL, ";");
2731
if(temp_ptr != NULL) {
2732
if(*temp_ptr != '\0')
2733
downtime_comment = temp_ptr;
2739
for(temp_member = temp_hostgroup->members; temp_member != NULL; temp_member = temp_member->next) {
2740
if((temp_host = (host *)temp_member->host_ptr) == NULL)
2742
if(host_name != NULL && strcmp(temp_host->name, host_name) != 0)
2744
deleted = +delete_downtime_by_hostname_service_description_start_time_comment(temp_host->name, service_description, downtime_start_time, downtime_comment);
2753
/* Opsview enhancement: Delete downtimes based on start time and/or comment */
2754
int cmd_delete_downtime_by_start_time_comment(int cmd, char *args) {
2755
time_t downtime_start_time = 0L;
2756
char *downtime_comment = NULL;
2757
char *temp_ptr = NULL;
2758
char *end_ptr = NULL;
2761
/* Get start time if set */
2762
temp_ptr = my_strtok(args, ";");
2763
if(temp_ptr != NULL) {
2764
/* This will be set to 0 if no start_time is entered or data is bad */
2765
downtime_start_time = strtoul(temp_ptr, &end_ptr, 10);
2768
/* Get comment - not sure if this should be also tokenised by ; */
2769
temp_ptr = my_strtok(NULL, "\n");
2770
if(temp_ptr != NULL && *temp_ptr != '\0') {
2771
downtime_comment = temp_ptr;
2774
/* No args should give an error */
2775
if(downtime_start_time == 0 && downtime_comment == NULL)
2778
deleted = delete_downtime_by_hostname_service_description_start_time_comment(NULL, NULL, downtime_start_time, downtime_comment);
2595
2787
/* changes a host or service (integer) variable */
2596
int cmd_change_object_int_var(int cmd,char *args){
2597
service *temp_service=NULL;
2598
host *temp_host=NULL;
2599
contact *temp_contact=NULL;
2600
char *host_name=NULL;
2601
char *svc_description=NULL;
2602
char *contact_name=NULL;
2603
char *temp_ptr=NULL;
2606
double old_dval=0.0;
2607
time_t preferred_time=0L;
2608
time_t next_valid_time=0L;
2609
unsigned long attr=MODATTR_NONE;
2610
unsigned long hattr=MODATTR_NONE;
2611
unsigned long sattr=MODATTR_NONE;
2615
case CMD_CHANGE_NORMAL_SVC_CHECK_INTERVAL:
2616
case CMD_CHANGE_RETRY_SVC_CHECK_INTERVAL:
2617
case CMD_CHANGE_MAX_SVC_CHECK_ATTEMPTS:
2618
case CMD_CHANGE_SVC_MODATTR:
2620
/* get the host name */
2621
if((host_name=my_strtok(args,";"))==NULL)
2624
/* get the service name */
2625
if((svc_description=my_strtok(NULL,";"))==NULL)
2628
/* verify that the service is valid */
2629
if((temp_service=find_service(host_name,svc_description))==NULL)
2634
case CMD_CHANGE_NORMAL_HOST_CHECK_INTERVAL:
2635
case CMD_CHANGE_RETRY_HOST_CHECK_INTERVAL:
2636
case CMD_CHANGE_MAX_HOST_CHECK_ATTEMPTS:
2637
case CMD_CHANGE_HOST_MODATTR:
2639
/* get the host name */
2640
if((host_name=my_strtok(args,";"))==NULL)
2643
/* verify that the host is valid */
2644
if((temp_host=find_host(host_name))==NULL)
2648
case CMD_CHANGE_CONTACT_MODATTR:
2649
case CMD_CHANGE_CONTACT_MODHATTR:
2650
case CMD_CHANGE_CONTACT_MODSATTR:
2652
/* get the contact name */
2653
if((contact_name=my_strtok(args,";"))==NULL)
2656
/* verify that the contact is valid */
2657
if((temp_contact=find_contact(contact_name))==NULL)
2662
/* unknown command */
2788
int cmd_change_object_int_var(int cmd, char *args) {
2789
service *temp_service = NULL;
2790
host *temp_host = NULL;
2791
contact *temp_contact = NULL;
2792
char *host_name = NULL;
2793
char *svc_description = NULL;
2794
char *contact_name = NULL;
2795
char *temp_ptr = NULL;
2798
double old_dval = 0.0;
2799
time_t preferred_time = 0L;
2800
time_t next_valid_time = 0L;
2801
unsigned long attr = MODATTR_NONE;
2802
unsigned long hattr = MODATTR_NONE;
2803
unsigned long sattr = MODATTR_NONE;
2807
case CMD_CHANGE_NORMAL_SVC_CHECK_INTERVAL:
2808
case CMD_CHANGE_RETRY_SVC_CHECK_INTERVAL:
2809
case CMD_CHANGE_MAX_SVC_CHECK_ATTEMPTS:
2810
case CMD_CHANGE_SVC_MODATTR:
2812
/* get the host name */
2813
if((host_name = my_strtok(args, ";")) == NULL)
2816
/* get the service name */
2817
if((svc_description = my_strtok(NULL, ";")) == NULL)
2820
/* verify that the service is valid */
2821
if((temp_service = find_service(host_name, svc_description)) == NULL)
2826
case CMD_CHANGE_NORMAL_HOST_CHECK_INTERVAL:
2827
case CMD_CHANGE_RETRY_HOST_CHECK_INTERVAL:
2828
case CMD_CHANGE_MAX_HOST_CHECK_ATTEMPTS:
2829
case CMD_CHANGE_HOST_MODATTR:
2831
/* get the host name */
2832
if((host_name = my_strtok(args, ";")) == NULL)
2835
/* verify that the host is valid */
2836
if((temp_host = find_host(host_name)) == NULL)
2840
case CMD_CHANGE_CONTACT_MODATTR:
2841
case CMD_CHANGE_CONTACT_MODHATTR:
2842
case CMD_CHANGE_CONTACT_MODSATTR:
2844
/* get the contact name */
2845
if((contact_name = my_strtok(args, ";")) == NULL)
2848
/* verify that the contact is valid */
2849
if((temp_contact = find_contact(contact_name)) == NULL)
2854
/* unknown command */
2667
2859
/* get the value */
2668
if((temp_ptr=my_strtok(NULL,";"))==NULL)
2670
intval=(int)strtol(temp_ptr,NULL,0);
2671
if(intval<0 || (intval==0 && errno==EINVAL))
2673
dval=(int)strtod(temp_ptr,NULL);
2677
case CMD_CHANGE_NORMAL_HOST_CHECK_INTERVAL:
2679
/* save the old check interval */
2680
old_dval=temp_host->check_interval;
2682
/* modify the check interval */
2683
temp_host->check_interval=dval;
2684
attr=MODATTR_NORMAL_CHECK_INTERVAL;
2686
/* schedule a host check if previous interval was 0 (checks were not regularly scheduled) */
2687
if(old_dval==0 && temp_host->checks_enabled==TRUE){
2689
/* set the host check flag */
2690
temp_host->should_be_scheduled=TRUE;
2692
/* schedule a check for right now (or as soon as possible) */
2693
time(&preferred_time);
2694
if(check_time_against_period(preferred_time,temp_host->check_period_ptr)==ERROR){
2695
get_next_valid_time(preferred_time,&next_valid_time,temp_host->check_period_ptr);
2696
temp_host->next_check=next_valid_time;
2699
temp_host->next_check=preferred_time;
2701
/* schedule a check if we should */
2702
if(temp_host->should_be_scheduled==TRUE)
2703
schedule_host_check(temp_host,temp_host->next_check,CHECK_OPTION_NONE);
2708
case CMD_CHANGE_RETRY_HOST_CHECK_INTERVAL:
2710
temp_host->retry_interval=dval;
2711
attr=MODATTR_RETRY_CHECK_INTERVAL;
2715
case CMD_CHANGE_MAX_HOST_CHECK_ATTEMPTS:
2717
temp_host->max_attempts=intval;
2718
attr=MODATTR_MAX_CHECK_ATTEMPTS;
2720
/* adjust current attempt number if in a hard state */
2721
if(temp_host->state_type==HARD_STATE && temp_host->current_state!=HOST_UP && temp_host->current_attempt>1)
2722
temp_host->current_attempt=temp_host->max_attempts;
2726
case CMD_CHANGE_NORMAL_SVC_CHECK_INTERVAL:
2728
/* save the old check interval */
2729
old_dval=temp_service->check_interval;
2731
/* modify the check interval */
2732
temp_service->check_interval=dval;
2733
attr=MODATTR_NORMAL_CHECK_INTERVAL;
2735
/* schedule a service check if previous interval was 0 (checks were not regularly scheduled) */
2736
if(old_dval==0 && temp_service->checks_enabled==TRUE && temp_service->check_interval!=0){
2738
/* set the service check flag */
2739
temp_service->should_be_scheduled=TRUE;
2741
/* schedule a check for right now (or as soon as possible) */
2742
time(&preferred_time);
2743
if(check_time_against_period(preferred_time,temp_service->check_period_ptr)==ERROR){
2744
get_next_valid_time(preferred_time,&next_valid_time,temp_service->check_period_ptr);
2745
temp_service->next_check=next_valid_time;
2748
temp_service->next_check=preferred_time;
2750
/* schedule a check if we should */
2751
if(temp_service->should_be_scheduled==TRUE)
2752
schedule_service_check(temp_service,temp_service->next_check,CHECK_OPTION_NONE);
2757
case CMD_CHANGE_RETRY_SVC_CHECK_INTERVAL:
2759
temp_service->retry_interval=dval;
2760
attr=MODATTR_RETRY_CHECK_INTERVAL;
2764
case CMD_CHANGE_MAX_SVC_CHECK_ATTEMPTS:
2766
temp_service->max_attempts=intval;
2767
attr=MODATTR_MAX_CHECK_ATTEMPTS;
2769
/* adjust current attempt number if in a hard state */
2770
if(temp_service->state_type==HARD_STATE && temp_service->current_state!=STATE_OK && temp_service->current_attempt>1)
2771
temp_service->current_attempt=temp_service->max_attempts;
2775
case CMD_CHANGE_HOST_MODATTR:
2776
case CMD_CHANGE_SVC_MODATTR:
2777
case CMD_CHANGE_CONTACT_MODATTR:
2782
case CMD_CHANGE_CONTACT_MODHATTR:
2787
case CMD_CHANGE_CONTACT_MODSATTR:
2860
if((temp_ptr = my_strtok(NULL, ";")) == NULL)
2862
intval = (int)strtol(temp_ptr, NULL, 0);
2863
if(intval < 0 || (intval == 0 && errno == EINVAL))
2865
dval = (int)strtod(temp_ptr, NULL);
2869
case CMD_CHANGE_NORMAL_HOST_CHECK_INTERVAL:
2871
/* save the old check interval */
2872
old_dval = temp_host->check_interval;
2874
/* modify the check interval */
2875
temp_host->check_interval = dval;
2876
attr = MODATTR_NORMAL_CHECK_INTERVAL;
2878
/* schedule a host check if previous interval was 0 (checks were not regularly scheduled) */
2879
if(old_dval == 0 && temp_host->checks_enabled == TRUE) {
2881
/* set the host check flag */
2882
temp_host->should_be_scheduled = TRUE;
2884
/* schedule a check for right now (or as soon as possible) */
2885
time(&preferred_time);
2886
if(check_time_against_period(preferred_time, temp_host->check_period_ptr) == ERROR) {
2887
get_next_valid_time(preferred_time, &next_valid_time, temp_host->check_period_ptr);
2888
temp_host->next_check = next_valid_time;
2891
temp_host->next_check = preferred_time;
2893
/* schedule a check if we should */
2894
if(temp_host->should_be_scheduled == TRUE)
2895
schedule_host_check(temp_host, temp_host->next_check, CHECK_OPTION_NONE);
2900
case CMD_CHANGE_RETRY_HOST_CHECK_INTERVAL:
2902
temp_host->retry_interval = dval;
2903
attr = MODATTR_RETRY_CHECK_INTERVAL;
2907
case CMD_CHANGE_MAX_HOST_CHECK_ATTEMPTS:
2909
temp_host->max_attempts = intval;
2910
attr = MODATTR_MAX_CHECK_ATTEMPTS;
2912
/* adjust current attempt number if in a hard state */
2913
if(temp_host->state_type == HARD_STATE && temp_host->current_state != HOST_UP && temp_host->current_attempt > 1)
2914
temp_host->current_attempt = temp_host->max_attempts;
2918
case CMD_CHANGE_NORMAL_SVC_CHECK_INTERVAL:
2920
/* save the old check interval */
2921
old_dval = temp_service->check_interval;
2923
/* modify the check interval */
2924
temp_service->check_interval = dval;
2925
attr = MODATTR_NORMAL_CHECK_INTERVAL;
2927
/* schedule a service check if previous interval was 0 (checks were not regularly scheduled) */
2928
if(old_dval == 0 && temp_service->checks_enabled == TRUE && temp_service->check_interval != 0) {
2930
/* set the service check flag */
2931
temp_service->should_be_scheduled = TRUE;
2933
/* schedule a check for right now (or as soon as possible) */
2934
time(&preferred_time);
2935
if(check_time_against_period(preferred_time, temp_service->check_period_ptr) == ERROR) {
2936
get_next_valid_time(preferred_time, &next_valid_time, temp_service->check_period_ptr);
2937
temp_service->next_check = next_valid_time;
2940
temp_service->next_check = preferred_time;
2942
/* schedule a check if we should */
2943
if(temp_service->should_be_scheduled == TRUE)
2944
schedule_service_check(temp_service, temp_service->next_check, CHECK_OPTION_NONE);
2949
case CMD_CHANGE_RETRY_SVC_CHECK_INTERVAL:
2951
temp_service->retry_interval = dval;
2952
attr = MODATTR_RETRY_CHECK_INTERVAL;
2956
case CMD_CHANGE_MAX_SVC_CHECK_ATTEMPTS:
2958
temp_service->max_attempts = intval;
2959
attr = MODATTR_MAX_CHECK_ATTEMPTS;
2961
/* adjust current attempt number if in a hard state */
2962
if(temp_service->state_type == HARD_STATE && temp_service->current_state != STATE_OK && temp_service->current_attempt > 1)
2963
temp_service->current_attempt = temp_service->max_attempts;
2967
case CMD_CHANGE_HOST_MODATTR:
2968
case CMD_CHANGE_SVC_MODATTR:
2969
case CMD_CHANGE_CONTACT_MODATTR:
2974
case CMD_CHANGE_CONTACT_MODHATTR:
2979
case CMD_CHANGE_CONTACT_MODSATTR:
2798
2990
/* send data to event broker and update status file */
2801
case CMD_CHANGE_RETRY_SVC_CHECK_INTERVAL:
2802
case CMD_CHANGE_NORMAL_SVC_CHECK_INTERVAL:
2803
case CMD_CHANGE_MAX_SVC_CHECK_ATTEMPTS:
2804
case CMD_CHANGE_SVC_MODATTR:
2806
/* set the modified service attribute */
2807
if(cmd==CMD_CHANGE_SVC_MODATTR)
2808
temp_service->modified_attributes=attr;
2810
temp_service->modified_attributes|=attr;
2812
#ifdef USE_EVENT_BROKER
2813
/* send data to event broker */
2814
broker_adaptive_service_data(NEBTYPE_ADAPTIVESERVICE_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,temp_service,cmd,attr,temp_service->modified_attributes,NULL);
2817
/* update the status log with the service info */
2818
update_service_status(temp_service,FALSE);
2822
case CMD_CHANGE_NORMAL_HOST_CHECK_INTERVAL:
2823
case CMD_CHANGE_RETRY_HOST_CHECK_INTERVAL:
2824
case CMD_CHANGE_MAX_HOST_CHECK_ATTEMPTS:
2825
case CMD_CHANGE_HOST_MODATTR:
2827
/* set the modified host attribute */
2828
if(cmd==CMD_CHANGE_HOST_MODATTR)
2829
temp_host->modified_attributes=attr;
2831
temp_host->modified_attributes|=attr;
2833
#ifdef USE_EVENT_BROKER
2834
/* send data to event broker */
2835
broker_adaptive_host_data(NEBTYPE_ADAPTIVEHOST_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,temp_host,cmd,attr,temp_host->modified_attributes,NULL);
2838
/* update the status log with the host info */
2839
update_host_status(temp_host,FALSE);
2842
case CMD_CHANGE_CONTACT_MODATTR:
2843
case CMD_CHANGE_CONTACT_MODHATTR:
2844
case CMD_CHANGE_CONTACT_MODSATTR:
2846
/* set the modified attribute */
2993
case CMD_CHANGE_RETRY_SVC_CHECK_INTERVAL:
2994
case CMD_CHANGE_NORMAL_SVC_CHECK_INTERVAL:
2995
case CMD_CHANGE_MAX_SVC_CHECK_ATTEMPTS:
2996
case CMD_CHANGE_SVC_MODATTR:
2998
/* set the modified service attribute */
2999
if(cmd == CMD_CHANGE_SVC_MODATTR)
3000
temp_service->modified_attributes = attr;
3002
temp_service->modified_attributes |= attr;
3004
#ifdef USE_EVENT_BROKER
3005
/* send data to event broker */
3006
broker_adaptive_service_data(NEBTYPE_ADAPTIVESERVICE_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, temp_service, cmd, attr, temp_service->modified_attributes, NULL);
3009
/* update the status log with the service info */
3010
update_service_status(temp_service, FALSE);
3014
case CMD_CHANGE_NORMAL_HOST_CHECK_INTERVAL:
3015
case CMD_CHANGE_RETRY_HOST_CHECK_INTERVAL:
3016
case CMD_CHANGE_MAX_HOST_CHECK_ATTEMPTS:
3017
case CMD_CHANGE_HOST_MODATTR:
3019
/* set the modified host attribute */
3020
if(cmd == CMD_CHANGE_HOST_MODATTR)
3021
temp_host->modified_attributes = attr;
3023
temp_host->modified_attributes |= attr;
3025
#ifdef USE_EVENT_BROKER
3026
/* send data to event broker */
3027
broker_adaptive_host_data(NEBTYPE_ADAPTIVEHOST_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, temp_host, cmd, attr, temp_host->modified_attributes, NULL);
3030
/* update the status log with the host info */
3031
update_host_status(temp_host, FALSE);
2848
3034
case CMD_CHANGE_CONTACT_MODATTR:
2849
temp_contact->modified_attributes=attr;
2851
3035
case CMD_CHANGE_CONTACT_MODHATTR:
2852
temp_contact->modified_host_attributes=hattr;
2854
3036
case CMD_CHANGE_CONTACT_MODSATTR:
2855
temp_contact->modified_service_attributes=sattr;
3038
/* set the modified attribute */
3040
case CMD_CHANGE_CONTACT_MODATTR:
3041
temp_contact->modified_attributes = attr;
3043
case CMD_CHANGE_CONTACT_MODHATTR:
3044
temp_contact->modified_host_attributes = hattr;
3046
case CMD_CHANGE_CONTACT_MODSATTR:
3047
temp_contact->modified_service_attributes = sattr;
3053
#ifdef USE_EVENT_BROKER
3054
/* send data to event broker */
3055
broker_adaptive_contact_data(NEBTYPE_ADAPTIVECONTACT_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, temp_contact, cmd, attr, temp_contact->modified_attributes, hattr, temp_contact->modified_host_attributes, sattr, temp_contact->modified_service_attributes, NULL);
3058
/* update the status log with the contact info */
3059
update_contact_status(temp_contact, FALSE);
2861
#ifdef USE_EVENT_BROKER
2862
/* send data to event broker */
2863
broker_adaptive_contact_data(NEBTYPE_ADAPTIVECONTACT_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,temp_contact,cmd,attr,temp_contact->modified_attributes,hattr,temp_contact->modified_host_attributes,sattr,temp_contact->modified_service_attributes,NULL);
2866
/* update the status log with the contact info */
2867
update_contact_status(temp_contact,FALSE);
2879
3071
/* changes a host or service (char) variable */
2880
int cmd_change_object_char_var(int cmd,char *args){
2881
service *temp_service=NULL;
2882
host *temp_host=NULL;
2883
contact *temp_contact=NULL;
2884
timeperiod *temp_timeperiod=NULL;
2885
command *temp_command=NULL;
2886
char *host_name=NULL;
2887
char *svc_description=NULL;
2888
char *contact_name=NULL;
2890
char *temp_ptr=NULL;
2891
char *temp_ptr2=NULL;
2892
unsigned long attr=MODATTR_NONE;
2893
unsigned long hattr=MODATTR_NONE;
2894
unsigned long sattr=MODATTR_NONE;
3072
int cmd_change_object_char_var(int cmd, char *args) {
3073
service *temp_service = NULL;
3074
host *temp_host = NULL;
3075
contact *temp_contact = NULL;
3076
timeperiod *temp_timeperiod = NULL;
3077
command *temp_command = NULL;
3078
char *host_name = NULL;
3079
char *svc_description = NULL;
3080
char *contact_name = NULL;
3081
char *charval = NULL;
3082
char *temp_ptr = NULL;
3083
char *temp_ptr2 = NULL;
3084
unsigned long attr = MODATTR_NONE;
3085
unsigned long hattr = MODATTR_NONE;
3086
unsigned long sattr = MODATTR_NONE;
2897
3089
/* SECURITY PATCH - disable these for the time being */
2899
case CMD_CHANGE_GLOBAL_HOST_EVENT_HANDLER:
2900
case CMD_CHANGE_GLOBAL_SVC_EVENT_HANDLER:
2901
case CMD_CHANGE_HOST_EVENT_HANDLER:
2902
case CMD_CHANGE_SVC_EVENT_HANDLER:
2903
case CMD_CHANGE_HOST_CHECK_COMMAND:
2904
case CMD_CHANGE_SVC_CHECK_COMMAND:
3091
case CMD_CHANGE_GLOBAL_HOST_EVENT_HANDLER:
3092
case CMD_CHANGE_GLOBAL_SVC_EVENT_HANDLER:
3093
case CMD_CHANGE_HOST_EVENT_HANDLER:
3094
case CMD_CHANGE_SVC_EVENT_HANDLER:
3095
case CMD_CHANGE_HOST_CHECK_COMMAND:
3096
case CMD_CHANGE_SVC_CHECK_COMMAND:
2909
3101
/* get the command arguments */
2912
case CMD_CHANGE_GLOBAL_HOST_EVENT_HANDLER:
2913
case CMD_CHANGE_GLOBAL_SVC_EVENT_HANDLER:
2915
if((charval=my_strtok(args,"\n"))==NULL)
2920
case CMD_CHANGE_HOST_EVENT_HANDLER:
2921
case CMD_CHANGE_HOST_CHECK_COMMAND:
2922
case CMD_CHANGE_HOST_CHECK_TIMEPERIOD:
2923
case CMD_CHANGE_HOST_NOTIFICATION_TIMEPERIOD:
2925
/* get the host name */
2926
if((host_name=my_strtok(args,";"))==NULL)
2929
/* verify that the host is valid */
2930
if((temp_host=find_host(host_name))==NULL)
2933
if((charval=my_strtok(NULL,"\n"))==NULL)
2938
case CMD_CHANGE_SVC_EVENT_HANDLER:
2939
case CMD_CHANGE_SVC_CHECK_COMMAND:
2940
case CMD_CHANGE_SVC_CHECK_TIMEPERIOD:
2941
case CMD_CHANGE_SVC_NOTIFICATION_TIMEPERIOD:
2943
/* get the host name */
2944
if((host_name=my_strtok(args,";"))==NULL)
2947
/* get the service name */
2948
if((svc_description=my_strtok(NULL,";"))==NULL)
2951
/* verify that the service is valid */
2952
if((temp_service=find_service(host_name,svc_description))==NULL)
2955
if((charval=my_strtok(NULL,"\n"))==NULL)
2961
case CMD_CHANGE_CONTACT_HOST_NOTIFICATION_TIMEPERIOD:
2962
case CMD_CHANGE_CONTACT_SVC_NOTIFICATION_TIMEPERIOD:
2964
/* get the contact name */
2965
if((contact_name=my_strtok(args,";"))==NULL)
2968
/* verify that the contact is valid */
2969
if((temp_contact=find_contact(contact_name))==NULL)
2972
if((charval=my_strtok(NULL,"\n"))==NULL)
2978
/* invalid command */
2984
if((temp_ptr=(char *)strdup(charval))==NULL)
3104
case CMD_CHANGE_GLOBAL_HOST_EVENT_HANDLER:
3105
case CMD_CHANGE_GLOBAL_SVC_EVENT_HANDLER:
3107
if((charval = my_strtok(args, "\n")) == NULL)
3112
case CMD_CHANGE_HOST_EVENT_HANDLER:
3113
case CMD_CHANGE_HOST_CHECK_COMMAND:
3114
case CMD_CHANGE_HOST_CHECK_TIMEPERIOD:
3115
case CMD_CHANGE_HOST_NOTIFICATION_TIMEPERIOD:
3117
/* get the host name */
3118
if((host_name = my_strtok(args, ";")) == NULL)
3121
/* verify that the host is valid */
3122
if((temp_host = find_host(host_name)) == NULL)
3125
if((charval = my_strtok(NULL, "\n")) == NULL)
3130
case CMD_CHANGE_SVC_EVENT_HANDLER:
3131
case CMD_CHANGE_SVC_CHECK_COMMAND:
3132
case CMD_CHANGE_SVC_CHECK_TIMEPERIOD:
3133
case CMD_CHANGE_SVC_NOTIFICATION_TIMEPERIOD:
3135
/* get the host name */
3136
if((host_name = my_strtok(args, ";")) == NULL)
3139
/* get the service name */
3140
if((svc_description = my_strtok(NULL, ";")) == NULL)
3143
/* verify that the service is valid */
3144
if((temp_service = find_service(host_name, svc_description)) == NULL)
3147
if((charval = my_strtok(NULL, "\n")) == NULL)
3153
case CMD_CHANGE_CONTACT_HOST_NOTIFICATION_TIMEPERIOD:
3154
case CMD_CHANGE_CONTACT_SVC_NOTIFICATION_TIMEPERIOD:
3156
/* get the contact name */
3157
if((contact_name = my_strtok(args, ";")) == NULL)
3160
/* verify that the contact is valid */
3161
if((temp_contact = find_contact(contact_name)) == NULL)
3164
if((charval = my_strtok(NULL, "\n")) == NULL)
3170
/* invalid command */
3176
if((temp_ptr = (char *)strdup(charval)) == NULL)
2988
3180
/* do some validation */
2991
case CMD_CHANGE_HOST_CHECK_TIMEPERIOD:
2992
case CMD_CHANGE_SVC_CHECK_TIMEPERIOD:
2993
case CMD_CHANGE_HOST_NOTIFICATION_TIMEPERIOD:
2994
case CMD_CHANGE_SVC_NOTIFICATION_TIMEPERIOD:
2995
case CMD_CHANGE_CONTACT_HOST_NOTIFICATION_TIMEPERIOD:
2996
case CMD_CHANGE_CONTACT_SVC_NOTIFICATION_TIMEPERIOD:
2998
/* make sure the timeperiod is valid */
2999
if((temp_timeperiod=find_timeperiod(temp_ptr))==NULL){
3006
case CMD_CHANGE_GLOBAL_HOST_EVENT_HANDLER:
3007
case CMD_CHANGE_GLOBAL_SVC_EVENT_HANDLER:
3008
case CMD_CHANGE_HOST_EVENT_HANDLER:
3009
case CMD_CHANGE_SVC_EVENT_HANDLER:
3010
case CMD_CHANGE_HOST_CHECK_COMMAND:
3011
case CMD_CHANGE_SVC_CHECK_COMMAND:
3013
/* make sure the command exists */
3014
temp_ptr2=my_strtok(temp_ptr,"!");
3015
if((temp_command=find_command(temp_ptr2))==NULL){
3021
if((temp_ptr=(char *)strdup(charval))==NULL)
3183
case CMD_CHANGE_HOST_CHECK_TIMEPERIOD:
3184
case CMD_CHANGE_SVC_CHECK_TIMEPERIOD:
3185
case CMD_CHANGE_HOST_NOTIFICATION_TIMEPERIOD:
3186
case CMD_CHANGE_SVC_NOTIFICATION_TIMEPERIOD:
3187
case CMD_CHANGE_CONTACT_HOST_NOTIFICATION_TIMEPERIOD:
3188
case CMD_CHANGE_CONTACT_SVC_NOTIFICATION_TIMEPERIOD:
3190
/* make sure the timeperiod is valid */
3191
if((temp_timeperiod = find_timeperiod(temp_ptr)) == NULL) {
3198
case CMD_CHANGE_GLOBAL_HOST_EVENT_HANDLER:
3199
case CMD_CHANGE_GLOBAL_SVC_EVENT_HANDLER:
3200
case CMD_CHANGE_HOST_EVENT_HANDLER:
3201
case CMD_CHANGE_SVC_EVENT_HANDLER:
3202
case CMD_CHANGE_HOST_CHECK_COMMAND:
3203
case CMD_CHANGE_SVC_CHECK_COMMAND:
3205
/* make sure the command exists */
3206
temp_ptr2 = my_strtok(temp_ptr, "!");
3207
if((temp_command = find_command(temp_ptr2)) == NULL) {
3213
if((temp_ptr = (char *)strdup(charval)) == NULL)
3031
3223
/* update the variable */
3034
case CMD_CHANGE_GLOBAL_HOST_EVENT_HANDLER:
3036
my_free(global_host_event_handler);
3037
global_host_event_handler=temp_ptr;
3038
global_host_event_handler_ptr=temp_command;
3039
attr=MODATTR_EVENT_HANDLER_COMMAND;
3042
case CMD_CHANGE_GLOBAL_SVC_EVENT_HANDLER:
3044
my_free(global_service_event_handler);
3045
global_service_event_handler=temp_ptr;
3046
global_service_event_handler_ptr=temp_command;
3047
attr=MODATTR_EVENT_HANDLER_COMMAND;
3050
case CMD_CHANGE_HOST_EVENT_HANDLER:
3052
my_free(temp_host->event_handler);
3053
temp_host->event_handler=temp_ptr;
3054
temp_host->event_handler_ptr=temp_command;
3055
attr=MODATTR_EVENT_HANDLER_COMMAND;
3058
case CMD_CHANGE_HOST_CHECK_COMMAND:
3060
my_free(temp_host->host_check_command);
3061
temp_host->host_check_command=temp_ptr;
3062
temp_host->check_command_ptr=temp_command;
3063
attr=MODATTR_CHECK_COMMAND;
3066
case CMD_CHANGE_HOST_CHECK_TIMEPERIOD:
3068
my_free(temp_host->check_period);
3069
temp_host->check_period=temp_ptr;
3070
temp_host->check_period_ptr=temp_timeperiod;
3071
attr=MODATTR_CHECK_TIMEPERIOD;
3074
case CMD_CHANGE_HOST_NOTIFICATION_TIMEPERIOD:
3076
my_free(temp_host->notification_period);
3077
temp_host->notification_period=temp_ptr;
3078
temp_host->notification_period_ptr=temp_timeperiod;
3079
attr=MODATTR_NOTIFICATION_TIMEPERIOD;
3082
case CMD_CHANGE_SVC_EVENT_HANDLER:
3084
my_free(temp_service->event_handler);
3085
temp_service->event_handler=temp_ptr;
3086
temp_service->event_handler_ptr=temp_command;
3087
attr=MODATTR_EVENT_HANDLER_COMMAND;
3090
case CMD_CHANGE_SVC_CHECK_COMMAND:
3092
my_free(temp_service->service_check_command);
3093
temp_service->service_check_command=temp_ptr;
3094
temp_service->check_command_ptr=temp_command;
3095
attr=MODATTR_CHECK_COMMAND;
3098
case CMD_CHANGE_SVC_CHECK_TIMEPERIOD:
3100
my_free(temp_service->check_period);
3101
temp_service->check_period=temp_ptr;
3102
temp_service->check_period_ptr=temp_timeperiod;
3103
attr=MODATTR_CHECK_TIMEPERIOD;
3106
case CMD_CHANGE_SVC_NOTIFICATION_TIMEPERIOD:
3108
my_free(temp_service->notification_period);
3109
temp_service->notification_period=temp_ptr;
3110
temp_service->notification_period_ptr=temp_timeperiod;
3111
attr=MODATTR_NOTIFICATION_TIMEPERIOD;
3114
case CMD_CHANGE_CONTACT_HOST_NOTIFICATION_TIMEPERIOD:
3116
my_free(temp_contact->host_notification_period);
3117
temp_contact->host_notification_period=temp_ptr;
3118
temp_contact->host_notification_period_ptr=temp_timeperiod;
3119
hattr=MODATTR_NOTIFICATION_TIMEPERIOD;
3122
case CMD_CHANGE_CONTACT_SVC_NOTIFICATION_TIMEPERIOD:
3124
my_free(temp_contact->service_notification_period);
3125
temp_contact->service_notification_period=temp_ptr;
3126
temp_contact->service_notification_period_ptr=temp_timeperiod;
3127
sattr=MODATTR_NOTIFICATION_TIMEPERIOD;
3226
case CMD_CHANGE_GLOBAL_HOST_EVENT_HANDLER:
3228
my_free(global_host_event_handler);
3229
global_host_event_handler = temp_ptr;
3230
global_host_event_handler_ptr = temp_command;
3231
attr = MODATTR_EVENT_HANDLER_COMMAND;
3234
case CMD_CHANGE_GLOBAL_SVC_EVENT_HANDLER:
3236
my_free(global_service_event_handler);
3237
global_service_event_handler = temp_ptr;
3238
global_service_event_handler_ptr = temp_command;
3239
attr = MODATTR_EVENT_HANDLER_COMMAND;
3242
case CMD_CHANGE_HOST_EVENT_HANDLER:
3244
my_free(temp_host->event_handler);
3245
temp_host->event_handler = temp_ptr;
3246
temp_host->event_handler_ptr = temp_command;
3247
attr = MODATTR_EVENT_HANDLER_COMMAND;
3250
case CMD_CHANGE_HOST_CHECK_COMMAND:
3252
my_free(temp_host->host_check_command);
3253
temp_host->host_check_command = temp_ptr;
3254
temp_host->check_command_ptr = temp_command;
3255
attr = MODATTR_CHECK_COMMAND;
3258
case CMD_CHANGE_HOST_CHECK_TIMEPERIOD:
3260
my_free(temp_host->check_period);
3261
temp_host->check_period = temp_ptr;
3262
temp_host->check_period_ptr = temp_timeperiod;
3263
attr = MODATTR_CHECK_TIMEPERIOD;
3266
case CMD_CHANGE_HOST_NOTIFICATION_TIMEPERIOD:
3268
my_free(temp_host->notification_period);
3269
temp_host->notification_period = temp_ptr;
3270
temp_host->notification_period_ptr = temp_timeperiod;
3271
attr = MODATTR_NOTIFICATION_TIMEPERIOD;
3274
case CMD_CHANGE_SVC_EVENT_HANDLER:
3276
my_free(temp_service->event_handler);
3277
temp_service->event_handler = temp_ptr;
3278
temp_service->event_handler_ptr = temp_command;
3279
attr = MODATTR_EVENT_HANDLER_COMMAND;
3282
case CMD_CHANGE_SVC_CHECK_COMMAND:
3284
my_free(temp_service->service_check_command);
3285
temp_service->service_check_command = temp_ptr;
3286
temp_service->check_command_ptr = temp_command;
3287
attr = MODATTR_CHECK_COMMAND;
3290
case CMD_CHANGE_SVC_CHECK_TIMEPERIOD:
3292
my_free(temp_service->check_period);
3293
temp_service->check_period = temp_ptr;
3294
temp_service->check_period_ptr = temp_timeperiod;
3295
attr = MODATTR_CHECK_TIMEPERIOD;
3298
case CMD_CHANGE_SVC_NOTIFICATION_TIMEPERIOD:
3300
my_free(temp_service->notification_period);
3301
temp_service->notification_period = temp_ptr;
3302
temp_service->notification_period_ptr = temp_timeperiod;
3303
attr = MODATTR_NOTIFICATION_TIMEPERIOD;
3306
case CMD_CHANGE_CONTACT_HOST_NOTIFICATION_TIMEPERIOD:
3308
my_free(temp_contact->host_notification_period);
3309
temp_contact->host_notification_period = temp_ptr;
3310
temp_contact->host_notification_period_ptr = temp_timeperiod;
3311
hattr = MODATTR_NOTIFICATION_TIMEPERIOD;
3314
case CMD_CHANGE_CONTACT_SVC_NOTIFICATION_TIMEPERIOD:
3316
my_free(temp_contact->service_notification_period);
3317
temp_contact->service_notification_period = temp_ptr;
3318
temp_contact->service_notification_period_ptr = temp_timeperiod;
3319
sattr = MODATTR_NOTIFICATION_TIMEPERIOD;
3135
3327
/* send data to event broker and update status file */
3138
case CMD_CHANGE_GLOBAL_HOST_EVENT_HANDLER:
3140
/* set the modified host attribute */
3141
modified_host_process_attributes|=attr;
3143
#ifdef USE_EVENT_BROKER
3144
/* send data to event broker */
3145
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,cmd,attr,modified_host_process_attributes,MODATTR_NONE,modified_service_process_attributes,NULL);
3148
/* update program status */
3149
update_program_status(FALSE);
3153
case CMD_CHANGE_GLOBAL_SVC_EVENT_HANDLER:
3155
/* set the modified service attribute */
3156
modified_service_process_attributes|=attr;
3158
#ifdef USE_EVENT_BROKER
3159
/* send data to event broker */
3160
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,cmd,MODATTR_NONE,modified_host_process_attributes,attr,modified_service_process_attributes,NULL);
3163
/* update program status */
3164
update_program_status(FALSE);
3168
case CMD_CHANGE_SVC_EVENT_HANDLER:
3169
case CMD_CHANGE_SVC_CHECK_COMMAND:
3170
case CMD_CHANGE_SVC_CHECK_TIMEPERIOD:
3171
case CMD_CHANGE_SVC_NOTIFICATION_TIMEPERIOD:
3173
/* set the modified service attribute */
3174
temp_service->modified_attributes|=attr;
3176
#ifdef USE_EVENT_BROKER
3177
/* send data to event broker */
3178
broker_adaptive_service_data(NEBTYPE_ADAPTIVESERVICE_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,temp_service,cmd,attr,temp_service->modified_attributes,NULL);
3181
/* update the status log with the service info */
3182
update_service_status(temp_service,FALSE);
3186
case CMD_CHANGE_HOST_EVENT_HANDLER:
3187
case CMD_CHANGE_HOST_CHECK_COMMAND:
3188
case CMD_CHANGE_HOST_CHECK_TIMEPERIOD:
3189
case CMD_CHANGE_HOST_NOTIFICATION_TIMEPERIOD:
3191
/* set the modified host attribute */
3192
temp_host->modified_attributes|=attr;
3194
#ifdef USE_EVENT_BROKER
3195
/* send data to event broker */
3196
broker_adaptive_host_data(NEBTYPE_ADAPTIVEHOST_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,temp_host,cmd,attr,temp_host->modified_attributes,NULL);
3199
/* update the status log with the host info */
3200
update_host_status(temp_host,FALSE);
3203
case CMD_CHANGE_CONTACT_HOST_NOTIFICATION_TIMEPERIOD:
3204
case CMD_CHANGE_CONTACT_SVC_NOTIFICATION_TIMEPERIOD:
3206
/* set the modified attributes */
3207
temp_contact->modified_host_attributes|=hattr;
3208
temp_contact->modified_service_attributes|=sattr;
3210
#ifdef USE_EVENT_BROKER
3211
/* send data to event broker */
3212
broker_adaptive_contact_data(NEBTYPE_ADAPTIVECONTACT_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,temp_contact,cmd,attr,temp_contact->modified_attributes,hattr,temp_contact->modified_host_attributes,sattr,temp_contact->modified_service_attributes,NULL);
3215
/* update the status log with the contact info */
3216
update_contact_status(temp_contact,FALSE);
3330
case CMD_CHANGE_GLOBAL_HOST_EVENT_HANDLER:
3332
/* set the modified host attribute */
3333
modified_host_process_attributes |= attr;
3335
#ifdef USE_EVENT_BROKER
3336
/* send data to event broker */
3337
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, cmd, attr, modified_host_process_attributes, MODATTR_NONE, modified_service_process_attributes, NULL);
3340
/* update program status */
3341
update_program_status(FALSE);
3345
case CMD_CHANGE_GLOBAL_SVC_EVENT_HANDLER:
3347
/* set the modified service attribute */
3348
modified_service_process_attributes |= attr;
3350
#ifdef USE_EVENT_BROKER
3351
/* send data to event broker */
3352
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, cmd, MODATTR_NONE, modified_host_process_attributes, attr, modified_service_process_attributes, NULL);
3355
/* update program status */
3356
update_program_status(FALSE);
3360
case CMD_CHANGE_SVC_EVENT_HANDLER:
3361
case CMD_CHANGE_SVC_CHECK_COMMAND:
3362
case CMD_CHANGE_SVC_CHECK_TIMEPERIOD:
3363
case CMD_CHANGE_SVC_NOTIFICATION_TIMEPERIOD:
3365
/* set the modified service attribute */
3366
temp_service->modified_attributes |= attr;
3368
#ifdef USE_EVENT_BROKER
3369
/* send data to event broker */
3370
broker_adaptive_service_data(NEBTYPE_ADAPTIVESERVICE_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, temp_service, cmd, attr, temp_service->modified_attributes, NULL);
3373
/* update the status log with the service info */
3374
update_service_status(temp_service, FALSE);
3378
case CMD_CHANGE_HOST_EVENT_HANDLER:
3379
case CMD_CHANGE_HOST_CHECK_COMMAND:
3380
case CMD_CHANGE_HOST_CHECK_TIMEPERIOD:
3381
case CMD_CHANGE_HOST_NOTIFICATION_TIMEPERIOD:
3383
/* set the modified host attribute */
3384
temp_host->modified_attributes |= attr;
3386
#ifdef USE_EVENT_BROKER
3387
/* send data to event broker */
3388
broker_adaptive_host_data(NEBTYPE_ADAPTIVEHOST_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, temp_host, cmd, attr, temp_host->modified_attributes, NULL);
3391
/* update the status log with the host info */
3392
update_host_status(temp_host, FALSE);
3395
case CMD_CHANGE_CONTACT_HOST_NOTIFICATION_TIMEPERIOD:
3396
case CMD_CHANGE_CONTACT_SVC_NOTIFICATION_TIMEPERIOD:
3398
/* set the modified attributes */
3399
temp_contact->modified_host_attributes |= hattr;
3400
temp_contact->modified_service_attributes |= sattr;
3402
#ifdef USE_EVENT_BROKER
3403
/* send data to event broker */
3404
broker_adaptive_contact_data(NEBTYPE_ADAPTIVECONTACT_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, temp_contact, cmd, attr, temp_contact->modified_attributes, hattr, temp_contact->modified_host_attributes, sattr, temp_contact->modified_service_attributes, NULL);
3407
/* update the status log with the contact info */
3408
update_contact_status(temp_contact, FALSE);
3228
3420
/* changes a custom host or service variable */
3229
int cmd_change_object_custom_var(int cmd, char *args){
3230
host *temp_host=NULL;
3231
service *temp_service=NULL;
3232
contact *temp_contact=NULL;
3233
customvariablesmember *temp_customvariablesmember=NULL;
3234
char *temp_ptr=NULL;
3238
char *varvalue=NULL;
3421
int cmd_change_object_custom_var(int cmd, char *args) {
3422
host *temp_host = NULL;
3423
service *temp_service = NULL;
3424
contact *temp_contact = NULL;
3425
customvariablesmember *temp_customvariablesmember = NULL;
3426
char *temp_ptr = NULL;
3429
char *varname = NULL;
3430
char *varvalue = NULL;
3241
3433
/* get the host or contact name */
3242
if((temp_ptr=my_strtok(args,";"))==NULL)
3434
if((temp_ptr = my_strtok(args, ";")) == NULL)
3244
if((name1=(char *)strdup(temp_ptr))==NULL)
3436
if((name1 = (char *)strdup(temp_ptr)) == NULL)
3247
3439
/* get the service description if necessary */
3248
if(cmd==CMD_CHANGE_CUSTOM_SVC_VAR){
3249
if((temp_ptr=my_strtok(NULL,";"))==NULL){
3253
if((name2=(char *)strdup(temp_ptr))==NULL){
3440
if(cmd == CMD_CHANGE_CUSTOM_SVC_VAR) {
3441
if((temp_ptr = my_strtok(NULL, ";")) == NULL) {
3445
if((name2 = (char *)strdup(temp_ptr)) == NULL) {
3259
3451
/* get the custom variable name */
3260
if((temp_ptr=my_strtok(NULL,";"))==NULL){
3265
if((varname=(char *)strdup(temp_ptr))==NULL){
3452
if((temp_ptr = my_strtok(NULL, ";")) == NULL) {
3457
if((varname = (char *)strdup(temp_ptr)) == NULL) {
3271
3463
/* get the custom variable value */
3272
if((temp_ptr=my_strtok(NULL,";"))==NULL){
3278
if((varvalue=(char *)strdup(temp_ptr))==NULL){
3464
if((temp_ptr = my_strtok(NULL, ";")) == NULL) {
3470
if((varvalue = (char *)strdup(temp_ptr)) == NULL) {
3285
3477
/* find the object */
3287
case CMD_CHANGE_CUSTOM_HOST_VAR:
3288
temp_host=find_host(name1);
3289
temp_customvariablesmember=temp_host->custom_variables;
3291
case CMD_CHANGE_CUSTOM_SVC_VAR:
3292
temp_service=find_service(name1,name2);
3293
temp_customvariablesmember=temp_service->custom_variables;
3295
case CMD_CHANGE_CUSTOM_CONTACT_VAR:
3296
temp_contact=find_contact(name1);
3297
temp_customvariablesmember=temp_contact->custom_variables;
3479
case CMD_CHANGE_CUSTOM_HOST_VAR:
3480
if((temp_host = find_host(name1)) == NULL)
3482
temp_customvariablesmember = temp_host->custom_variables;
3484
case CMD_CHANGE_CUSTOM_SVC_VAR:
3485
if((temp_service = find_service(name1, name2)) == NULL)
3487
temp_customvariablesmember = temp_service->custom_variables;
3489
case CMD_CHANGE_CUSTOM_CONTACT_VAR:
3490
if((temp_contact = find_contact(name1)) == NULL)
3492
temp_customvariablesmember = temp_contact->custom_variables;
3303
3498
/* capitalize the custom variable name */
3304
for(x=0;varname[x]!='\x0';x++)
3305
varname[x]=toupper(varname[x]);
3499
for(x = 0; varname[x] != '\x0'; x++)
3500
varname[x] = toupper(varname[x]);
3307
3502
/* find the proper variable */
3308
for(;temp_customvariablesmember!=NULL;temp_customvariablesmember=temp_customvariablesmember->next){
3503
for(; temp_customvariablesmember != NULL; temp_customvariablesmember = temp_customvariablesmember->next) {
3310
3505
/* we found the variable, so update the value */
3311
if(!strcmp(varname,temp_customvariablesmember->variable_name)){
3506
if(!strcmp(varname, temp_customvariablesmember->variable_name)) {
3313
3508
/* update the value */
3314
3509
if(temp_customvariablesmember->variable_value)
3315
3510
my_free(temp_customvariablesmember->variable_value);
3316
temp_customvariablesmember->variable_value=(char *)strdup(varvalue);
3511
temp_customvariablesmember->variable_value = (char *)strdup(varvalue);
3318
3513
/* mark the variable value as having been changed */
3319
temp_customvariablesmember->has_been_modified=TRUE;
3514
temp_customvariablesmember->has_been_modified = TRUE;
3325
3520
/* free memory */
3326
3521
my_free(name1);
3387
3582
/******************************************************************/
3389
3584
/* temporarily disables a service check */
3390
void disable_service_checks(service *svc){
3391
unsigned long attr=MODATTR_ACTIVE_CHECKS_ENABLED;
3585
void disable_service_checks(service *svc) {
3586
unsigned long attr = MODATTR_ACTIVE_CHECKS_ENABLED;
3393
3588
/* checks are already disabled */
3394
if(svc->checks_enabled==FALSE)
3589
if(svc->checks_enabled == FALSE)
3397
3592
/* set the attribute modified flag */
3398
svc->modified_attributes|=attr;
3593
svc->modified_attributes |= attr;
3400
3595
/* disable the service check... */
3401
svc->checks_enabled=FALSE;
3402
svc->should_be_scheduled=FALSE;
3596
svc->checks_enabled = FALSE;
3597
svc->should_be_scheduled = FALSE;
3404
3599
#ifdef USE_EVENT_BROKER
3405
3600
/* send data to event broker */
3406
broker_adaptive_service_data(NEBTYPE_ADAPTIVESERVICE_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,svc,CMD_NONE,attr,svc->modified_attributes,NULL);
3601
broker_adaptive_service_data(NEBTYPE_ADAPTIVESERVICE_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, svc, CMD_NONE, attr, svc->modified_attributes, NULL);
3409
3604
/* update the status log to reflect the new service state */
3410
update_service_status(svc,FALSE);
3605
update_service_status(svc, FALSE);
3417
3612
/* enables a service check */
3418
void enable_service_checks(service *svc){
3419
time_t preferred_time=0L;
3420
time_t next_valid_time=0L;
3421
unsigned long attr=MODATTR_ACTIVE_CHECKS_ENABLED;
3613
void enable_service_checks(service *svc) {
3614
time_t preferred_time = 0L;
3615
time_t next_valid_time = 0L;
3616
unsigned long attr = MODATTR_ACTIVE_CHECKS_ENABLED;
3423
3618
/* checks are already enabled */
3424
if(svc->checks_enabled==TRUE)
3619
if(svc->checks_enabled == TRUE)
3427
3622
/* set the attribute modified flag */
3428
svc->modified_attributes|=attr;
3623
svc->modified_attributes |= attr;
3430
3625
/* enable the service check... */
3431
svc->checks_enabled=TRUE;
3432
svc->should_be_scheduled=TRUE;
3626
svc->checks_enabled = TRUE;
3627
svc->should_be_scheduled = TRUE;
3434
3629
/* services with no check intervals don't get checked */
3435
if(svc->check_interval==0)
3436
svc->should_be_scheduled=FALSE;
3630
if(svc->check_interval == 0)
3631
svc->should_be_scheduled = FALSE;
3438
3633
/* schedule a check for right now (or as soon as possible) */
3439
3634
time(&preferred_time);
3440
if(check_time_against_period(preferred_time,svc->check_period_ptr)==ERROR){
3441
get_next_valid_time(preferred_time,&next_valid_time,svc->check_period_ptr);
3442
svc->next_check=next_valid_time;
3635
if(check_time_against_period(preferred_time, svc->check_period_ptr) == ERROR) {
3636
get_next_valid_time(preferred_time, &next_valid_time, svc->check_period_ptr);
3637
svc->next_check = next_valid_time;
3445
svc->next_check=preferred_time;
3640
svc->next_check = preferred_time;
3447
3642
/* schedule a check if we should */
3448
if(svc->should_be_scheduled==TRUE)
3449
schedule_service_check(svc,svc->next_check,CHECK_OPTION_NONE);
3643
if(svc->should_be_scheduled == TRUE)
3644
schedule_service_check(svc, svc->next_check, CHECK_OPTION_NONE);
3451
3646
#ifdef USE_EVENT_BROKER
3452
3647
/* send data to event broker */
3453
broker_adaptive_service_data(NEBTYPE_ADAPTIVESERVICE_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,svc,CMD_NONE,attr,svc->modified_attributes,NULL);
3648
broker_adaptive_service_data(NEBTYPE_ADAPTIVESERVICE_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, svc, CMD_NONE, attr, svc->modified_attributes, NULL);
3456
3651
/* update the status log to reflect the new service state */
3457
update_service_status(svc,FALSE);
3652
update_service_status(svc, FALSE);
3464
3659
/* enable notifications on a program-wide basis */
3465
void enable_all_notifications(void){
3466
unsigned long attr=MODATTR_NOTIFICATIONS_ENABLED;
3660
void enable_all_notifications(void) {
3661
unsigned long attr = MODATTR_NOTIFICATIONS_ENABLED;
3468
3663
/* bail out if we're already set... */
3469
if(enable_notifications==TRUE)
3664
if(enable_notifications == TRUE)
3472
3667
/* set the attribute modified flag */
3473
modified_host_process_attributes|=attr;
3474
modified_service_process_attributes|=attr;
3668
modified_host_process_attributes |= attr;
3669
modified_service_process_attributes |= attr;
3476
3671
/* update notification status */
3477
enable_notifications=TRUE;
3672
enable_notifications = TRUE;
3479
3674
#ifdef USE_EVENT_BROKER
3480
3675
/* send data to event broker */
3481
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,CMD_NONE,attr,modified_host_process_attributes,attr,modified_service_process_attributes,NULL);
3676
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, CMD_NONE, attr, modified_host_process_attributes, attr, modified_service_process_attributes, NULL);
3484
3679
/* update the status log */
3485
3680
update_program_status(FALSE);
3491
3686
/* disable notifications on a program-wide basis */
3492
void disable_all_notifications(void){
3493
unsigned long attr=MODATTR_NOTIFICATIONS_ENABLED;
3687
void disable_all_notifications(void) {
3688
unsigned long attr = MODATTR_NOTIFICATIONS_ENABLED;
3495
3690
/* bail out if we're already set... */
3496
if(enable_notifications==FALSE)
3691
if(enable_notifications == FALSE)
3499
3694
/* set the attribute modified flag */
3500
modified_host_process_attributes|=attr;
3501
modified_service_process_attributes|=attr;
3695
modified_host_process_attributes |= attr;
3696
modified_service_process_attributes |= attr;
3503
3698
/* update notification status */
3504
enable_notifications=FALSE;
3699
enable_notifications = FALSE;
3506
3701
#ifdef USE_EVENT_BROKER
3507
3702
/* send data to event broker */
3508
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,CMD_NONE,attr,modified_host_process_attributes,attr,modified_service_process_attributes,NULL);
3703
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, CMD_NONE, attr, modified_host_process_attributes, attr, modified_service_process_attributes, NULL);
3511
3706
/* update the status log */
3512
3707
update_program_status(FALSE);
3518
3713
/* enables notifications for a service */
3519
void enable_service_notifications(service *svc){
3520
unsigned long attr=MODATTR_NOTIFICATIONS_ENABLED;
3714
void enable_service_notifications(service *svc) {
3715
unsigned long attr = MODATTR_NOTIFICATIONS_ENABLED;
3522
3717
/* no change */
3523
if(svc->notifications_enabled==TRUE)
3718
if(svc->notifications_enabled == TRUE)
3526
3721
/* set the attribute modified flag */
3527
svc->modified_attributes|=attr;
3722
svc->modified_attributes |= attr;
3529
3724
/* enable the service notifications... */
3530
svc->notifications_enabled=TRUE;
3725
svc->notifications_enabled = TRUE;
3532
3727
#ifdef USE_EVENT_BROKER
3533
3728
/* send data to event broker */
3534
broker_adaptive_service_data(NEBTYPE_ADAPTIVESERVICE_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,svc,CMD_NONE,attr,svc->modified_attributes,NULL);
3729
broker_adaptive_service_data(NEBTYPE_ADAPTIVESERVICE_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, svc, CMD_NONE, attr, svc->modified_attributes, NULL);
3537
3732
/* update the status log to reflect the new service state */
3538
update_service_status(svc,FALSE);
3733
update_service_status(svc, FALSE);
3544
3739
/* disables notifications for a service */
3545
void disable_service_notifications(service *svc){
3546
unsigned long attr=MODATTR_NOTIFICATIONS_ENABLED;
3740
void disable_service_notifications(service *svc) {
3741
unsigned long attr = MODATTR_NOTIFICATIONS_ENABLED;
3548
3743
/* no change */
3549
if(svc->notifications_enabled==FALSE)
3744
if(svc->notifications_enabled == FALSE)
3552
3747
/* set the attribute modified flag */
3553
svc->modified_attributes|=attr;
3748
svc->modified_attributes |= attr;
3555
3750
/* disable the service notifications... */
3556
svc->notifications_enabled=FALSE;
3751
svc->notifications_enabled = FALSE;
3558
3753
#ifdef USE_EVENT_BROKER
3559
3754
/* send data to event broker */
3560
broker_adaptive_service_data(NEBTYPE_ADAPTIVESERVICE_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,svc,CMD_NONE,attr,svc->modified_attributes,NULL);
3755
broker_adaptive_service_data(NEBTYPE_ADAPTIVESERVICE_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, svc, CMD_NONE, attr, svc->modified_attributes, NULL);
3563
3758
/* update the status log to reflect the new service state */
3564
update_service_status(svc,FALSE);
3759
update_service_status(svc, FALSE);
3570
3765
/* enables notifications for a host */
3571
void enable_host_notifications(host *hst){
3572
unsigned long attr=MODATTR_NOTIFICATIONS_ENABLED;
3766
void enable_host_notifications(host *hst) {
3767
unsigned long attr = MODATTR_NOTIFICATIONS_ENABLED;
3574
3769
/* no change */
3575
if(hst->notifications_enabled==TRUE)
3770
if(hst->notifications_enabled == TRUE)
3578
3773
/* set the attribute modified flag */
3579
hst->modified_attributes|=attr;
3774
hst->modified_attributes |= attr;
3581
3776
/* enable the host notifications... */
3582
hst->notifications_enabled=TRUE;
3777
hst->notifications_enabled = TRUE;
3584
3779
#ifdef USE_EVENT_BROKER
3585
3780
/* send data to event broker */
3586
broker_adaptive_host_data(NEBTYPE_ADAPTIVEHOST_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,hst,CMD_NONE,attr,hst->modified_attributes,NULL);
3781
broker_adaptive_host_data(NEBTYPE_ADAPTIVEHOST_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, hst, CMD_NONE, attr, hst->modified_attributes, NULL);
3589
3784
/* update the status log to reflect the new host state */
3590
update_host_status(hst,FALSE);
3785
update_host_status(hst, FALSE);
3596
3791
/* disables notifications for a host */
3597
void disable_host_notifications(host *hst){
3598
unsigned long attr=MODATTR_NOTIFICATIONS_ENABLED;
3792
void disable_host_notifications(host *hst) {
3793
unsigned long attr = MODATTR_NOTIFICATIONS_ENABLED;
3600
3795
/* no change */
3601
if(hst->notifications_enabled==FALSE)
3796
if(hst->notifications_enabled == FALSE)
3604
3799
/* set the attribute modified flag */
3605
hst->modified_attributes|=attr;
3800
hst->modified_attributes |= attr;
3607
3802
/* disable the host notifications... */
3608
hst->notifications_enabled=FALSE;
3803
hst->notifications_enabled = FALSE;
3610
3805
#ifdef USE_EVENT_BROKER
3611
3806
/* send data to event broker */
3612
broker_adaptive_host_data(NEBTYPE_ADAPTIVEHOST_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,hst,CMD_NONE,attr,hst->modified_attributes,NULL);
3807
broker_adaptive_host_data(NEBTYPE_ADAPTIVEHOST_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, hst, CMD_NONE, attr, hst->modified_attributes, NULL);
3615
3810
/* update the status log to reflect the new host state */
3616
update_host_status(hst,FALSE);
3811
update_host_status(hst, FALSE);
3622
3817
/* enables notifications for all hosts and services "beyond" a given host */
3623
void enable_and_propagate_notifications(host *hst, int level, int affect_top_host, int affect_hosts, int affect_services){
3624
host *child_host=NULL;
3625
service *temp_service=NULL;
3626
servicesmember *temp_servicesmember=NULL;
3627
hostsmember *temp_hostsmember=NULL;
3818
void enable_and_propagate_notifications(host *hst, int level, int affect_top_host, int affect_hosts, int affect_services) {
3819
host *child_host = NULL;
3820
service *temp_service = NULL;
3821
servicesmember *temp_servicesmember = NULL;
3822
hostsmember *temp_hostsmember = NULL;
3629
3824
/* enable notification for top level host */
3630
if(affect_top_host==TRUE && level==0)
3825
if(affect_top_host == TRUE && level == 0)
3631
3826
enable_host_notifications(hst);
3633
3828
/* check all child hosts... */
3634
for(temp_hostsmember=hst->child_hosts;temp_hostsmember!=NULL;temp_hostsmember=temp_hostsmember->next){
3829
for(temp_hostsmember = hst->child_hosts; temp_hostsmember != NULL; temp_hostsmember = temp_hostsmember->next) {
3636
if((child_host=temp_hostsmember->host_ptr)==NULL)
3831
if((child_host = temp_hostsmember->host_ptr) == NULL)
3639
3834
/* recurse... */
3640
enable_and_propagate_notifications(child_host,level+1,affect_top_host,affect_hosts,affect_services);
3835
enable_and_propagate_notifications(child_host, level + 1, affect_top_host, affect_hosts, affect_services);
3642
3837
/* enable notifications for this host */
3643
if(affect_hosts==TRUE)
3838
if(affect_hosts == TRUE)
3644
3839
enable_host_notifications(child_host);
3646
3841
/* enable notifications for all services on this host... */
3647
if(affect_services==TRUE){
3648
for(temp_servicesmember=child_host->services;temp_servicesmember!=NULL;temp_servicesmember=temp_servicesmember->next){
3649
if((temp_service=temp_servicesmember->service_ptr)==NULL)
3842
if(affect_services == TRUE) {
3843
for(temp_servicesmember = child_host->services; temp_servicesmember != NULL; temp_servicesmember = temp_servicesmember->next) {
3844
if((temp_service = temp_servicesmember->service_ptr) == NULL)
3651
3846
enable_service_notifications(temp_service);
3660
3855
/* disables notifications for all hosts and services "beyond" a given host */
3661
void disable_and_propagate_notifications(host *hst, int level, int affect_top_host, int affect_hosts, int affect_services){
3662
host *child_host=NULL;
3663
service *temp_service=NULL;
3664
servicesmember *temp_servicesmember=NULL;
3665
hostsmember *temp_hostsmember=NULL;
3856
void disable_and_propagate_notifications(host *hst, int level, int affect_top_host, int affect_hosts, int affect_services) {
3857
host *child_host = NULL;
3858
service *temp_service = NULL;
3859
servicesmember *temp_servicesmember = NULL;
3860
hostsmember *temp_hostsmember = NULL;
3670
3865
/* disable notifications for top host */
3671
if(affect_top_host==TRUE && level==0)
3866
if(affect_top_host == TRUE && level == 0)
3672
3867
disable_host_notifications(hst);
3674
3869
/* check all child hosts... */
3675
for(temp_hostsmember=hst->child_hosts;temp_hostsmember!=NULL;temp_hostsmember=temp_hostsmember->next){
3870
for(temp_hostsmember = hst->child_hosts; temp_hostsmember != NULL; temp_hostsmember = temp_hostsmember->next) {
3677
if((child_host=temp_hostsmember->host_ptr)==NULL)
3872
if((child_host = temp_hostsmember->host_ptr) == NULL)
3680
3875
/* recurse... */
3681
disable_and_propagate_notifications(child_host,level+1,affect_top_host,affect_hosts,affect_services);
3876
disable_and_propagate_notifications(child_host, level + 1, affect_top_host, affect_hosts, affect_services);
3683
3878
/* disable notifications for this host */
3684
if(affect_hosts==TRUE)
3879
if(affect_hosts == TRUE)
3685
3880
disable_host_notifications(child_host);
3687
3882
/* disable notifications for all services on this host... */
3688
if(affect_services==TRUE){
3689
for(temp_servicesmember=child_host->services;temp_servicesmember!=NULL;temp_servicesmember=temp_servicesmember->next){
3690
if((temp_service=temp_servicesmember->service_ptr)==NULL)
3883
if(affect_services == TRUE) {
3884
for(temp_servicesmember = child_host->services; temp_servicesmember != NULL; temp_servicesmember = temp_servicesmember->next) {
3885
if((temp_service = temp_servicesmember->service_ptr) == NULL)
3692
3887
disable_service_notifications(temp_service);
3702
3897
/* enables host notifications for a contact */
3703
void enable_contact_host_notifications(contact *cntct){
3704
unsigned long attr=MODATTR_NOTIFICATIONS_ENABLED;
3898
void enable_contact_host_notifications(contact *cntct) {
3899
unsigned long attr = MODATTR_NOTIFICATIONS_ENABLED;
3706
3901
/* no change */
3707
if(cntct->host_notifications_enabled==TRUE)
3902
if(cntct->host_notifications_enabled == TRUE)
3710
3905
/* set the attribute modified flag */
3711
cntct->modified_host_attributes|=attr;
3906
cntct->modified_host_attributes |= attr;
3713
3908
/* enable the host notifications... */
3714
cntct->host_notifications_enabled=TRUE;
3909
cntct->host_notifications_enabled = TRUE;
3716
3911
#ifdef USE_EVENT_BROKER
3717
3912
/* send data to event broker */
3718
broker_adaptive_contact_data(NEBTYPE_ADAPTIVECONTACT_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,cntct,CMD_NONE,MODATTR_NONE,cntct->modified_attributes,attr,cntct->modified_host_attributes,MODATTR_NONE,cntct->modified_service_attributes,NULL);
3913
broker_adaptive_contact_data(NEBTYPE_ADAPTIVECONTACT_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, cntct, CMD_NONE, MODATTR_NONE, cntct->modified_attributes, attr, cntct->modified_host_attributes, MODATTR_NONE, cntct->modified_service_attributes, NULL);
3721
3916
/* update the status log to reflect the new contact state */
3722
update_contact_status(cntct,FALSE);
3917
update_contact_status(cntct, FALSE);
3729
3924
/* disables host notifications for a contact */
3730
void disable_contact_host_notifications(contact *cntct){
3731
unsigned long attr=MODATTR_NOTIFICATIONS_ENABLED;
3925
void disable_contact_host_notifications(contact *cntct) {
3926
unsigned long attr = MODATTR_NOTIFICATIONS_ENABLED;
3733
3928
/* no change */
3734
if(cntct->host_notifications_enabled==FALSE)
3929
if(cntct->host_notifications_enabled == FALSE)
3737
3932
/* set the attribute modified flag */
3738
cntct->modified_host_attributes|=attr;
3933
cntct->modified_host_attributes |= attr;
3740
3935
/* enable the host notifications... */
3741
cntct->host_notifications_enabled=FALSE;
3936
cntct->host_notifications_enabled = FALSE;
3743
3938
#ifdef USE_EVENT_BROKER
3744
3939
/* send data to event broker */
3745
broker_adaptive_contact_data(NEBTYPE_ADAPTIVECONTACT_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,cntct,CMD_NONE,MODATTR_NONE,cntct->modified_attributes,attr,cntct->modified_host_attributes,MODATTR_NONE,cntct->modified_service_attributes,NULL);
3940
broker_adaptive_contact_data(NEBTYPE_ADAPTIVECONTACT_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, cntct, CMD_NONE, MODATTR_NONE, cntct->modified_attributes, attr, cntct->modified_host_attributes, MODATTR_NONE, cntct->modified_service_attributes, NULL);
3748
3943
/* update the status log to reflect the new contact state */
3749
update_contact_status(cntct,FALSE);
3944
update_contact_status(cntct, FALSE);
3756
3951
/* enables service notifications for a contact */
3757
void enable_contact_service_notifications(contact *cntct){
3758
unsigned long attr=MODATTR_NOTIFICATIONS_ENABLED;
3952
void enable_contact_service_notifications(contact *cntct) {
3953
unsigned long attr = MODATTR_NOTIFICATIONS_ENABLED;
3760
3955
/* no change */
3761
if(cntct->service_notifications_enabled==TRUE)
3956
if(cntct->service_notifications_enabled == TRUE)
3764
3959
/* set the attribute modified flag */
3765
cntct->modified_service_attributes|=attr;
3960
cntct->modified_service_attributes |= attr;
3767
3962
/* enable the host notifications... */
3768
cntct->service_notifications_enabled=TRUE;
3963
cntct->service_notifications_enabled = TRUE;
3770
3965
#ifdef USE_EVENT_BROKER
3771
3966
/* send data to event broker */
3772
broker_adaptive_contact_data(NEBTYPE_ADAPTIVECONTACT_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,cntct,CMD_NONE,MODATTR_NONE,cntct->modified_attributes,MODATTR_NONE,cntct->modified_host_attributes,attr,cntct->modified_service_attributes,NULL);
3967
broker_adaptive_contact_data(NEBTYPE_ADAPTIVECONTACT_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, cntct, CMD_NONE, MODATTR_NONE, cntct->modified_attributes, MODATTR_NONE, cntct->modified_host_attributes, attr, cntct->modified_service_attributes, NULL);
3775
3970
/* update the status log to reflect the new contact state */
3776
update_contact_status(cntct,FALSE);
3971
update_contact_status(cntct, FALSE);
3783
3978
/* disables service notifications for a contact */
3784
void disable_contact_service_notifications(contact *cntct){
3785
unsigned long attr=MODATTR_NOTIFICATIONS_ENABLED;
3979
void disable_contact_service_notifications(contact *cntct) {
3980
unsigned long attr = MODATTR_NOTIFICATIONS_ENABLED;
3787
3982
/* no change */
3788
if(cntct->service_notifications_enabled==FALSE)
3983
if(cntct->service_notifications_enabled == FALSE)
3791
3986
/* set the attribute modified flag */
3792
cntct->modified_service_attributes|=attr;
3987
cntct->modified_service_attributes |= attr;
3794
3989
/* enable the host notifications... */
3795
cntct->service_notifications_enabled=FALSE;
3990
cntct->service_notifications_enabled = FALSE;
3797
3992
#ifdef USE_EVENT_BROKER
3798
3993
/* send data to event broker */
3799
broker_adaptive_contact_data(NEBTYPE_ADAPTIVECONTACT_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,cntct,CMD_NONE,MODATTR_NONE,cntct->modified_attributes,MODATTR_NONE,cntct->modified_host_attributes,attr,cntct->modified_service_attributes,NULL);
3994
broker_adaptive_contact_data(NEBTYPE_ADAPTIVECONTACT_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, cntct, CMD_NONE, MODATTR_NONE, cntct->modified_attributes, MODATTR_NONE, cntct->modified_host_attributes, attr, cntct->modified_service_attributes, NULL);
3802
3997
/* update the status log to reflect the new contact state */
3803
update_contact_status(cntct,FALSE);
3998
update_contact_status(cntct, FALSE);
3810
4005
/* schedules downtime for all hosts "beyond" a given host */
3811
void schedule_and_propagate_downtime(host *temp_host, time_t entry_time, char *author, char *comment_data, time_t start_time, time_t end_time, int fixed, unsigned long triggered_by, unsigned long duration){
3812
host *child_host=NULL;
3813
hostsmember *temp_hostsmember=NULL;
4006
void schedule_and_propagate_downtime(host *temp_host, time_t entry_time, char *author, char *comment_data, time_t start_time, time_t end_time, int fixed, unsigned long triggered_by, unsigned long duration) {
4007
host *child_host = NULL;
4008
hostsmember *temp_hostsmember = NULL;
3815
4010
/* check all child hosts... */
3816
for(temp_hostsmember=temp_host->child_hosts;temp_hostsmember!=NULL;temp_hostsmember=temp_hostsmember->next){
4011
for(temp_hostsmember = temp_host->child_hosts; temp_hostsmember != NULL; temp_hostsmember = temp_hostsmember->next) {
3818
if((child_host=temp_hostsmember->host_ptr)==NULL)
4013
if((child_host = temp_hostsmember->host_ptr) == NULL)
3821
4016
/* recurse... */
3822
schedule_and_propagate_downtime(child_host,entry_time,author,comment_data,start_time,end_time,fixed,triggered_by,duration);
4017
schedule_and_propagate_downtime(child_host, entry_time, author, comment_data, start_time, end_time, fixed, triggered_by, duration);
3824
4019
/* schedule downtime for this host */
3825
schedule_downtime(HOST_DOWNTIME,child_host->name,NULL,entry_time,author,comment_data,start_time,end_time,fixed,triggered_by,duration,NULL);
4020
schedule_downtime(HOST_DOWNTIME, child_host->name, NULL, entry_time, author, comment_data, start_time, end_time, fixed, triggered_by, duration, NULL);
3832
4027
/* acknowledges a host problem */
3833
void acknowledge_host_problem(host *hst, char *ack_author, char *ack_data, int type, int notify, int persistent){
3834
time_t current_time=0L;
4028
void acknowledge_host_problem(host *hst, char *ack_author, char *ack_data, int type, int notify, int persistent) {
4029
time_t current_time = 0L;
3836
4031
/* cannot acknowledge a non-existent problem */
3837
if(hst->current_state==HOST_UP)
4032
if(hst->current_state == HOST_UP)
3840
4035
#ifdef USE_EVENT_BROKER
3841
4036
/* send data to event broker */
3842
broker_acknowledgement_data(NEBTYPE_ACKNOWLEDGEMENT_ADD,NEBFLAG_NONE,NEBATTR_NONE,HOST_ACKNOWLEDGEMENT,(void *)hst,ack_author,ack_data,type,notify,persistent,NULL);
4037
broker_acknowledgement_data(NEBTYPE_ACKNOWLEDGEMENT_ADD, NEBFLAG_NONE, NEBATTR_NONE, HOST_ACKNOWLEDGEMENT, (void *)hst, ack_author, ack_data, type, notify, persistent, NULL);
3845
4040
/* send out an acknowledgement notification */
3847
host_notification(hst,NOTIFICATION_ACKNOWLEDGEMENT,ack_author,ack_data,NOTIFICATION_OPTION_NONE);
4042
host_notification(hst, NOTIFICATION_ACKNOWLEDGEMENT, ack_author, ack_data, NOTIFICATION_OPTION_NONE);
3849
4044
/* set the acknowledgement flag */
3850
hst->problem_has_been_acknowledged=TRUE;
4045
hst->problem_has_been_acknowledged = TRUE;
3852
4047
/* set the acknowledgement type */
3853
hst->acknowledgement_type=(type==ACKNOWLEDGEMENT_STICKY)?ACKNOWLEDGEMENT_STICKY:ACKNOWLEDGEMENT_NORMAL;
4048
hst->acknowledgement_type = (type == ACKNOWLEDGEMENT_STICKY) ? ACKNOWLEDGEMENT_STICKY : ACKNOWLEDGEMENT_NORMAL;
3855
4050
/* update the status log with the host info */
3856
update_host_status(hst,FALSE);
4051
update_host_status(hst, FALSE);
3858
4053
/* add a comment for the acknowledgement */
3859
4054
time(¤t_time);
3860
add_new_host_comment(ACKNOWLEDGEMENT_COMMENT,hst->name,current_time,ack_author,ack_data,persistent,COMMENTSOURCE_INTERNAL,FALSE,(time_t)0,NULL);
4055
add_new_host_comment(ACKNOWLEDGEMENT_COMMENT, hst->name, current_time, ack_author, ack_data, persistent, COMMENTSOURCE_INTERNAL, FALSE, (time_t)0, NULL);
3866
4061
/* acknowledges a service problem */
3867
void acknowledge_service_problem(service *svc, char *ack_author, char *ack_data, int type, int notify, int persistent){
3868
time_t current_time=0L;
4062
void acknowledge_service_problem(service *svc, char *ack_author, char *ack_data, int type, int notify, int persistent) {
4063
time_t current_time = 0L;
3870
4065
/* cannot acknowledge a non-existent problem */
3871
if(svc->current_state==STATE_OK)
4066
if(svc->current_state == STATE_OK)
3874
4069
#ifdef USE_EVENT_BROKER
3875
4070
/* send data to event broker */
3876
broker_acknowledgement_data(NEBTYPE_ACKNOWLEDGEMENT_ADD,NEBFLAG_NONE,NEBATTR_NONE,SERVICE_ACKNOWLEDGEMENT,(void *)svc,ack_author,ack_data,type,notify,persistent,NULL);
4071
broker_acknowledgement_data(NEBTYPE_ACKNOWLEDGEMENT_ADD, NEBFLAG_NONE, NEBATTR_NONE, SERVICE_ACKNOWLEDGEMENT, (void *)svc, ack_author, ack_data, type, notify, persistent, NULL);
3879
4074
/* send out an acknowledgement notification */
3881
service_notification(svc,NOTIFICATION_ACKNOWLEDGEMENT,ack_author,ack_data,NOTIFICATION_OPTION_NONE);
4076
service_notification(svc, NOTIFICATION_ACKNOWLEDGEMENT, ack_author, ack_data, NOTIFICATION_OPTION_NONE);
3883
4078
/* set the acknowledgement flag */
3884
svc->problem_has_been_acknowledged=TRUE;
4079
svc->problem_has_been_acknowledged = TRUE;
3886
4081
/* set the acknowledgement type */
3887
svc->acknowledgement_type=(type==ACKNOWLEDGEMENT_STICKY)?ACKNOWLEDGEMENT_STICKY:ACKNOWLEDGEMENT_NORMAL;
4082
svc->acknowledgement_type = (type == ACKNOWLEDGEMENT_STICKY) ? ACKNOWLEDGEMENT_STICKY : ACKNOWLEDGEMENT_NORMAL;
3889
4084
/* update the status log with the service info */
3890
update_service_status(svc,FALSE);
4085
update_service_status(svc, FALSE);
3892
4087
/* add a comment for the acknowledgement */
3893
4088
time(¤t_time);
3894
add_new_service_comment(ACKNOWLEDGEMENT_COMMENT,svc->host_name,svc->description,current_time,ack_author,ack_data,persistent,COMMENTSOURCE_INTERNAL,FALSE,(time_t)0,NULL);
4089
add_new_service_comment(ACKNOWLEDGEMENT_COMMENT, svc->host_name, svc->description, current_time, ack_author, ack_data, persistent, COMMENTSOURCE_INTERNAL, FALSE, (time_t)0, NULL);
3900
4095
/* removes a host acknowledgement */
3901
void remove_host_acknowledgement(host *hst){
4096
void remove_host_acknowledgement(host *hst) {
3903
4098
/* set the acknowledgement flag */
3904
hst->problem_has_been_acknowledged=FALSE;
4099
hst->problem_has_been_acknowledged = FALSE;
3906
4101
/* update the status log with the host info */
3907
update_host_status(hst,FALSE);
4102
update_host_status(hst, FALSE);
3909
4104
/* remove any non-persistant comments associated with the ack */
3910
4105
delete_host_acknowledgement_comments(hst);
3916
4111
/* removes a service acknowledgement */
3917
void remove_service_acknowledgement(service *svc){
4112
void remove_service_acknowledgement(service *svc) {
3919
4114
/* set the acknowledgement flag */
3920
svc->problem_has_been_acknowledged=FALSE;
4115
svc->problem_has_been_acknowledged = FALSE;
3922
4117
/* update the status log with the service info */
3923
update_service_status(svc,FALSE);
4118
update_service_status(svc, FALSE);
3925
4120
/* remove any non-persistant comments associated with the ack */
3926
4121
delete_service_acknowledgement_comments(svc);
3932
4127
/* starts executing service checks */
3933
void start_executing_service_checks(void){
3934
unsigned long attr=MODATTR_ACTIVE_CHECKS_ENABLED;
4128
void start_executing_service_checks(void) {
4129
unsigned long attr = MODATTR_ACTIVE_CHECKS_ENABLED;
3936
4131
/* bail out if we're already executing services */
3937
if(execute_service_checks==TRUE)
4132
if(execute_service_checks == TRUE)
3940
4135
/* set the attribute modified flag */
3941
modified_service_process_attributes|=attr;
4136
modified_service_process_attributes |= attr;
3943
4138
/* set the service check execution flag */
3944
execute_service_checks=TRUE;
4139
execute_service_checks = TRUE;
3946
4141
#ifdef USE_EVENT_BROKER
3947
4142
/* send data to event broker */
3948
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,CMD_NONE,MODATTR_NONE,modified_host_process_attributes,attr,modified_service_process_attributes,NULL);
4143
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, CMD_NONE, MODATTR_NONE, modified_host_process_attributes, attr, modified_service_process_attributes, NULL);
3951
4146
/* update the status log with the program info */
3952
4147
update_program_status(FALSE);
3960
4155
/* stops executing service checks */
3961
void stop_executing_service_checks(void){
3962
unsigned long attr=MODATTR_ACTIVE_CHECKS_ENABLED;
4156
void stop_executing_service_checks(void) {
4157
unsigned long attr = MODATTR_ACTIVE_CHECKS_ENABLED;
3964
4159
/* bail out if we're already not executing services */
3965
if(execute_service_checks==FALSE)
4160
if(execute_service_checks == FALSE)
3968
4163
/* set the attribute modified flag */
3969
modified_service_process_attributes|=attr;
4164
modified_service_process_attributes |= attr;
3971
4166
/* set the service check execution flag */
3972
execute_service_checks=FALSE;
4167
execute_service_checks = FALSE;
3974
4169
#ifdef USE_EVENT_BROKER
3975
4170
/* send data to event broker */
3976
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,CMD_NONE,MODATTR_NONE,modified_host_process_attributes,attr,modified_service_process_attributes,NULL);
4171
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, CMD_NONE, MODATTR_NONE, modified_host_process_attributes, attr, modified_service_process_attributes, NULL);
3979
4174
/* update the status log with the program info */
3980
4175
update_program_status(FALSE);
3987
4182
/* starts accepting passive service checks */
3988
void start_accepting_passive_service_checks(void){
3989
unsigned long attr=MODATTR_PASSIVE_CHECKS_ENABLED;
4183
void start_accepting_passive_service_checks(void) {
4184
unsigned long attr = MODATTR_PASSIVE_CHECKS_ENABLED;
3991
4186
/* bail out if we're already accepting passive services */
3992
if(accept_passive_service_checks==TRUE)
4187
if(accept_passive_service_checks == TRUE)
3995
4190
/* set the attribute modified flag */
3996
modified_service_process_attributes|=attr;
4191
modified_service_process_attributes |= attr;
3998
4193
/* set the service check flag */
3999
accept_passive_service_checks=TRUE;
4194
accept_passive_service_checks = TRUE;
4001
4196
#ifdef USE_EVENT_BROKER
4002
4197
/* send data to event broker */
4003
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,CMD_NONE,MODATTR_NONE,modified_host_process_attributes,attr,modified_service_process_attributes,NULL);
4198
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, CMD_NONE, MODATTR_NONE, modified_host_process_attributes, attr, modified_service_process_attributes, NULL);
4006
4201
/* update the status log with the program info */
4007
4202
update_program_status(FALSE);
4014
4209
/* stops accepting passive service checks */
4015
void stop_accepting_passive_service_checks(void){
4016
unsigned long attr=MODATTR_PASSIVE_CHECKS_ENABLED;
4210
void stop_accepting_passive_service_checks(void) {
4211
unsigned long attr = MODATTR_PASSIVE_CHECKS_ENABLED;
4018
4213
/* bail out if we're already not accepting passive services */
4019
if(accept_passive_service_checks==FALSE)
4214
if(accept_passive_service_checks == FALSE)
4022
4217
/* set the attribute modified flag */
4023
modified_service_process_attributes|=attr;
4218
modified_service_process_attributes |= attr;
4025
4220
/* set the service check flag */
4026
accept_passive_service_checks=FALSE;
4221
accept_passive_service_checks = FALSE;
4028
4223
#ifdef USE_EVENT_BROKER
4029
4224
/* send data to event broker */
4030
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,CMD_NONE,MODATTR_NONE,modified_host_process_attributes,attr,modified_service_process_attributes,NULL);
4225
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, CMD_NONE, MODATTR_NONE, modified_host_process_attributes, attr, modified_service_process_attributes, NULL);
4033
4228
/* update the status log with the program info */
4034
4229
update_program_status(FALSE);
4041
4236
/* enables passive service checks for a particular service */
4042
void enable_passive_service_checks(service *svc){
4043
unsigned long attr=MODATTR_PASSIVE_CHECKS_ENABLED;
4237
void enable_passive_service_checks(service *svc) {
4238
unsigned long attr = MODATTR_PASSIVE_CHECKS_ENABLED;
4045
4240
/* no change */
4046
if(svc->accept_passive_service_checks==TRUE)
4241
if(svc->accept_passive_service_checks == TRUE)
4049
4244
/* set the attribute modified flag */
4050
svc->modified_attributes|=attr;
4245
svc->modified_attributes |= attr;
4052
4247
/* set the passive check flag */
4053
svc->accept_passive_service_checks=TRUE;
4248
svc->accept_passive_service_checks = TRUE;
4055
4250
#ifdef USE_EVENT_BROKER
4056
4251
/* send data to event broker */
4057
broker_adaptive_service_data(NEBTYPE_ADAPTIVESERVICE_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,svc,CMD_NONE,attr,svc->modified_attributes,NULL);
4252
broker_adaptive_service_data(NEBTYPE_ADAPTIVESERVICE_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, svc, CMD_NONE, attr, svc->modified_attributes, NULL);
4060
4255
/* update the status log with the service info */
4061
update_service_status(svc,FALSE);
4256
update_service_status(svc, FALSE);
4068
4263
/* disables passive service checks for a particular service */
4069
void disable_passive_service_checks(service *svc){
4070
unsigned long attr=MODATTR_PASSIVE_CHECKS_ENABLED;
4264
void disable_passive_service_checks(service *svc) {
4265
unsigned long attr = MODATTR_PASSIVE_CHECKS_ENABLED;
4072
4267
/* no change */
4073
if(svc->accept_passive_service_checks==FALSE)
4268
if(svc->accept_passive_service_checks == FALSE)
4076
4271
/* set the attribute modified flag */
4077
svc->modified_attributes|=attr;
4272
svc->modified_attributes |= attr;
4079
4274
/* set the passive check flag */
4080
svc->accept_passive_service_checks=FALSE;
4275
svc->accept_passive_service_checks = FALSE;
4082
4277
#ifdef USE_EVENT_BROKER
4083
4278
/* send data to event broker */
4084
broker_adaptive_service_data(NEBTYPE_ADAPTIVESERVICE_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,svc,CMD_NONE,attr,svc->modified_attributes,NULL);
4279
broker_adaptive_service_data(NEBTYPE_ADAPTIVESERVICE_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, svc, CMD_NONE, attr, svc->modified_attributes, NULL);
4087
4282
/* update the status log with the service info */
4088
update_service_status(svc,FALSE);
4283
update_service_status(svc, FALSE);
4095
4290
/* starts executing host checks */
4096
void start_executing_host_checks(void){
4097
unsigned long attr=MODATTR_ACTIVE_CHECKS_ENABLED;
4291
void start_executing_host_checks(void) {
4292
unsigned long attr = MODATTR_ACTIVE_CHECKS_ENABLED;
4099
4294
/* bail out if we're already executing hosts */
4100
if(execute_host_checks==TRUE)
4295
if(execute_host_checks == TRUE)
4103
4298
/* set the attribute modified flag */
4104
modified_host_process_attributes|=attr;
4299
modified_host_process_attributes |= attr;
4106
4301
/* set the host check execution flag */
4107
execute_host_checks=TRUE;
4302
execute_host_checks = TRUE;
4109
4304
#ifdef USE_EVENT_BROKER
4110
4305
/* send data to event broker */
4111
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,CMD_NONE,attr,modified_host_process_attributes,MODATTR_NONE,modified_service_process_attributes,NULL);
4306
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, CMD_NONE, attr, modified_host_process_attributes, MODATTR_NONE, modified_service_process_attributes, NULL);
4114
4309
/* update the status log with the program info */
4115
4310
update_program_status(FALSE);
4123
4318
/* stops executing host checks */
4124
void stop_executing_host_checks(void){
4125
unsigned long attr=MODATTR_ACTIVE_CHECKS_ENABLED;
4319
void stop_executing_host_checks(void) {
4320
unsigned long attr = MODATTR_ACTIVE_CHECKS_ENABLED;
4127
4322
/* bail out if we're already not executing hosts */
4128
if(execute_host_checks==FALSE)
4323
if(execute_host_checks == FALSE)
4131
4326
/* set the attribute modified flag */
4132
modified_host_process_attributes|=attr;
4327
modified_host_process_attributes |= attr;
4134
4329
/* set the host check execution flag */
4135
execute_host_checks=FALSE;
4330
execute_host_checks = FALSE;
4137
4332
#ifdef USE_EVENT_BROKER
4138
4333
/* send data to event broker */
4139
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,CMD_NONE,attr,modified_host_process_attributes,MODATTR_NONE,modified_service_process_attributes,NULL);
4334
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, CMD_NONE, attr, modified_host_process_attributes, MODATTR_NONE, modified_service_process_attributes, NULL);
4142
4337
/* update the status log with the program info */
4143
4338
update_program_status(FALSE);
4150
4345
/* starts accepting passive host checks */
4151
void start_accepting_passive_host_checks(void){
4152
unsigned long attr=MODATTR_PASSIVE_CHECKS_ENABLED;
4346
void start_accepting_passive_host_checks(void) {
4347
unsigned long attr = MODATTR_PASSIVE_CHECKS_ENABLED;
4154
4349
/* bail out if we're already accepting passive hosts */
4155
if(accept_passive_host_checks==TRUE)
4350
if(accept_passive_host_checks == TRUE)
4158
4353
/* set the attribute modified flag */
4159
modified_host_process_attributes|=attr;
4354
modified_host_process_attributes |= attr;
4161
4356
/* set the host check flag */
4162
accept_passive_host_checks=TRUE;
4357
accept_passive_host_checks = TRUE;
4164
4359
#ifdef USE_EVENT_BROKER
4165
4360
/* send data to event broker */
4166
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,CMD_NONE,attr,modified_host_process_attributes,MODATTR_NONE,modified_service_process_attributes,NULL);
4361
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, CMD_NONE, attr, modified_host_process_attributes, MODATTR_NONE, modified_service_process_attributes, NULL);
4169
4364
/* update the status log with the program info */
4170
4365
update_program_status(FALSE);
4177
4372
/* stops accepting passive host checks */
4178
void stop_accepting_passive_host_checks(void){
4179
unsigned long attr=MODATTR_PASSIVE_CHECKS_ENABLED;
4373
void stop_accepting_passive_host_checks(void) {
4374
unsigned long attr = MODATTR_PASSIVE_CHECKS_ENABLED;
4181
4376
/* bail out if we're already not accepting passive hosts */
4182
if(accept_passive_host_checks==FALSE)
4377
if(accept_passive_host_checks == FALSE)
4185
4380
/* set the attribute modified flag */
4186
modified_host_process_attributes|=attr;
4381
modified_host_process_attributes |= attr;
4188
4383
/* set the host check flag */
4189
accept_passive_host_checks=FALSE;
4384
accept_passive_host_checks = FALSE;
4191
4386
#ifdef USE_EVENT_BROKER
4192
4387
/* send data to event broker */
4193
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,CMD_NONE,attr,modified_host_process_attributes,MODATTR_NONE,modified_service_process_attributes,NULL);
4388
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, CMD_NONE, attr, modified_host_process_attributes, MODATTR_NONE, modified_service_process_attributes, NULL);
4196
4391
/* update the status log with the program info */
4197
4392
update_program_status(FALSE);
4204
4399
/* enables passive host checks for a particular host */
4205
void enable_passive_host_checks(host *hst){
4206
unsigned long attr=MODATTR_PASSIVE_CHECKS_ENABLED;
4400
void enable_passive_host_checks(host *hst) {
4401
unsigned long attr = MODATTR_PASSIVE_CHECKS_ENABLED;
4208
4403
/* no change */
4209
if(hst->accept_passive_host_checks==TRUE)
4404
if(hst->accept_passive_host_checks == TRUE)
4212
4407
/* set the attribute modified flag */
4213
hst->modified_attributes|=attr;
4408
hst->modified_attributes |= attr;
4215
4410
/* set the passive check flag */
4216
hst->accept_passive_host_checks=TRUE;
4411
hst->accept_passive_host_checks = TRUE;
4218
4413
#ifdef USE_EVENT_BROKER
4219
4414
/* send data to event broker */
4220
broker_adaptive_host_data(NEBTYPE_ADAPTIVEHOST_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,hst,CMD_NONE,attr,hst->modified_attributes,NULL);
4415
broker_adaptive_host_data(NEBTYPE_ADAPTIVEHOST_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, hst, CMD_NONE, attr, hst->modified_attributes, NULL);
4223
4418
/* update the status log with the host info */
4224
update_host_status(hst,FALSE);
4419
update_host_status(hst, FALSE);
4231
4426
/* disables passive host checks for a particular host */
4232
void disable_passive_host_checks(host *hst){
4233
unsigned long attr=MODATTR_PASSIVE_CHECKS_ENABLED;
4427
void disable_passive_host_checks(host *hst) {
4428
unsigned long attr = MODATTR_PASSIVE_CHECKS_ENABLED;
4235
4430
/* no change */
4236
if(hst->accept_passive_host_checks==FALSE)
4431
if(hst->accept_passive_host_checks == FALSE)
4239
4434
/* set the attribute modified flag */
4240
hst->modified_attributes|=attr;
4435
hst->modified_attributes |= attr;
4242
4437
/* set the passive check flag */
4243
hst->accept_passive_host_checks=FALSE;
4438
hst->accept_passive_host_checks = FALSE;
4245
4440
#ifdef USE_EVENT_BROKER
4246
4441
/* send data to event broker */
4247
broker_adaptive_host_data(NEBTYPE_ADAPTIVEHOST_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,hst,CMD_NONE,attr,hst->modified_attributes,NULL);
4442
broker_adaptive_host_data(NEBTYPE_ADAPTIVEHOST_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, hst, CMD_NONE, attr, hst->modified_attributes, NULL);
4250
4445
/* update the status log with the host info */
4251
update_host_status(hst,FALSE);
4446
update_host_status(hst, FALSE);
4257
4452
/* enables event handlers on a program-wide basis */
4258
void start_using_event_handlers(void){
4259
unsigned long attr=MODATTR_EVENT_HANDLER_ENABLED;
4453
void start_using_event_handlers(void) {
4454
unsigned long attr = MODATTR_EVENT_HANDLER_ENABLED;
4261
4456
/* no change */
4262
if(enable_event_handlers==TRUE)
4457
if(enable_event_handlers == TRUE)
4265
4460
/* set the attribute modified flag */
4266
modified_host_process_attributes|=attr;
4267
modified_service_process_attributes|=attr;
4461
modified_host_process_attributes |= attr;
4462
modified_service_process_attributes |= attr;
4269
4464
/* set the event handler flag */
4270
enable_event_handlers=TRUE;
4465
enable_event_handlers = TRUE;
4272
4467
#ifdef USE_EVENT_BROKER
4273
4468
/* send data to event broker */
4274
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,CMD_NONE,attr,modified_host_process_attributes,attr,modified_service_process_attributes,NULL);
4469
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, CMD_NONE, attr, modified_host_process_attributes, attr, modified_service_process_attributes, NULL);
4277
4472
/* update the status log with the program info */
4278
4473
update_program_status(FALSE);
4284
4479
/* disables event handlers on a program-wide basis */
4285
void stop_using_event_handlers(void){
4286
unsigned long attr=MODATTR_EVENT_HANDLER_ENABLED;
4480
void stop_using_event_handlers(void) {
4481
unsigned long attr = MODATTR_EVENT_HANDLER_ENABLED;
4288
4483
/* no change */
4289
if(enable_event_handlers==FALSE)
4484
if(enable_event_handlers == FALSE)
4292
4487
/* set the attribute modified flag */
4293
modified_host_process_attributes|=attr;
4294
modified_service_process_attributes|=attr;
4488
modified_host_process_attributes |= attr;
4489
modified_service_process_attributes |= attr;
4296
4491
/* set the event handler flag */
4297
enable_event_handlers=FALSE;
4492
enable_event_handlers = FALSE;
4299
4494
#ifdef USE_EVENT_BROKER
4300
4495
/* send data to event broker */
4301
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,CMD_NONE,attr,modified_host_process_attributes,attr,modified_service_process_attributes,NULL);
4496
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, CMD_NONE, attr, modified_host_process_attributes, attr, modified_service_process_attributes, NULL);
4304
4499
/* update the status log with the program info */
4305
4500
update_program_status(FALSE);
4311
4506
/* enables the event handler for a particular service */
4312
void enable_service_event_handler(service *svc){
4313
unsigned long attr=MODATTR_EVENT_HANDLER_ENABLED;
4507
void enable_service_event_handler(service *svc) {
4508
unsigned long attr = MODATTR_EVENT_HANDLER_ENABLED;
4315
4510
/* no change */
4316
if(svc->event_handler_enabled==TRUE)
4511
if(svc->event_handler_enabled == TRUE)
4319
4514
/* set the attribute modified flag */
4320
svc->modified_attributes|=attr;
4515
svc->modified_attributes |= attr;
4322
4517
/* set the event handler flag */
4323
svc->event_handler_enabled=TRUE;
4518
svc->event_handler_enabled = TRUE;
4325
4520
#ifdef USE_EVENT_BROKER
4326
4521
/* send data to event broker */
4327
broker_adaptive_service_data(NEBTYPE_ADAPTIVESERVICE_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,svc,CMD_NONE,attr,svc->modified_attributes,NULL);
4522
broker_adaptive_service_data(NEBTYPE_ADAPTIVESERVICE_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, svc, CMD_NONE, attr, svc->modified_attributes, NULL);
4330
4525
/* update the status log with the service info */
4331
update_service_status(svc,FALSE);
4526
update_service_status(svc, FALSE);
4338
4533
/* disables the event handler for a particular service */
4339
void disable_service_event_handler(service *svc){
4340
unsigned long attr=MODATTR_EVENT_HANDLER_ENABLED;
4534
void disable_service_event_handler(service *svc) {
4535
unsigned long attr = MODATTR_EVENT_HANDLER_ENABLED;
4342
4537
/* no change */
4343
if(svc->event_handler_enabled==FALSE)
4538
if(svc->event_handler_enabled == FALSE)
4346
4541
/* set the attribute modified flag */
4347
svc->modified_attributes|=attr;
4542
svc->modified_attributes |= attr;
4349
4544
/* set the event handler flag */
4350
svc->event_handler_enabled=FALSE;
4545
svc->event_handler_enabled = FALSE;
4352
4547
#ifdef USE_EVENT_BROKER
4353
4548
/* send data to event broker */
4354
broker_adaptive_service_data(NEBTYPE_ADAPTIVESERVICE_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,svc,CMD_NONE,attr,svc->modified_attributes,NULL);
4549
broker_adaptive_service_data(NEBTYPE_ADAPTIVESERVICE_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, svc, CMD_NONE, attr, svc->modified_attributes, NULL);
4357
4552
/* update the status log with the service info */
4358
update_service_status(svc,FALSE);
4553
update_service_status(svc, FALSE);
4364
4559
/* enables the event handler for a particular host */
4365
void enable_host_event_handler(host *hst){
4366
unsigned long attr=MODATTR_EVENT_HANDLER_ENABLED;
4560
void enable_host_event_handler(host *hst) {
4561
unsigned long attr = MODATTR_EVENT_HANDLER_ENABLED;
4368
4563
/* no change */
4369
if(hst->event_handler_enabled==TRUE)
4564
if(hst->event_handler_enabled == TRUE)
4372
4567
/* set the attribute modified flag */
4373
hst->modified_attributes|=attr;
4568
hst->modified_attributes |= attr;
4375
4570
/* set the event handler flag */
4376
hst->event_handler_enabled=TRUE;
4571
hst->event_handler_enabled = TRUE;
4378
4573
#ifdef USE_EVENT_BROKER
4379
4574
/* send data to event broker */
4380
broker_adaptive_host_data(NEBTYPE_ADAPTIVEHOST_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,hst,CMD_NONE,attr,hst->modified_attributes,NULL);
4575
broker_adaptive_host_data(NEBTYPE_ADAPTIVEHOST_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, hst, CMD_NONE, attr, hst->modified_attributes, NULL);
4383
4578
/* update the status log with the host info */
4384
update_host_status(hst,FALSE);
4579
update_host_status(hst, FALSE);
4390
4585
/* disables the event handler for a particular host */
4391
void disable_host_event_handler(host *hst){
4392
unsigned long attr=MODATTR_EVENT_HANDLER_ENABLED;
4586
void disable_host_event_handler(host *hst) {
4587
unsigned long attr = MODATTR_EVENT_HANDLER_ENABLED;
4394
4589
/* no change */
4395
if(hst->event_handler_enabled==FALSE)
4590
if(hst->event_handler_enabled == FALSE)
4398
4593
/* set the attribute modified flag */
4399
hst->modified_attributes|=attr;
4594
hst->modified_attributes |= attr;
4401
4596
/* set the event handler flag */
4402
hst->event_handler_enabled=FALSE;
4597
hst->event_handler_enabled = FALSE;
4404
4599
#ifdef USE_EVENT_BROKER
4405
4600
/* send data to event broker */
4406
broker_adaptive_host_data(NEBTYPE_ADAPTIVEHOST_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,hst,CMD_NONE,attr,hst->modified_attributes,NULL);
4601
broker_adaptive_host_data(NEBTYPE_ADAPTIVEHOST_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, hst, CMD_NONE, attr, hst->modified_attributes, NULL);
4409
4604
/* update the status log with the host info */
4410
update_host_status(hst,FALSE);
4605
update_host_status(hst, FALSE);
4416
4611
/* disables checks of a particular host */
4417
void disable_host_checks(host *hst){
4418
unsigned long attr=MODATTR_ACTIVE_CHECKS_ENABLED;
4612
void disable_host_checks(host *hst) {
4613
unsigned long attr = MODATTR_ACTIVE_CHECKS_ENABLED;
4420
4615
/* checks are already disabled */
4421
if(hst->checks_enabled==FALSE)
4616
if(hst->checks_enabled == FALSE)
4424
4619
/* set the attribute modified flag */
4425
hst->modified_attributes|=attr;
4620
hst->modified_attributes |= attr;
4427
4622
/* set the host check flag */
4428
hst->checks_enabled=FALSE;
4429
hst->should_be_scheduled=FALSE;
4623
hst->checks_enabled = FALSE;
4624
hst->should_be_scheduled = FALSE;
4431
4626
#ifdef USE_EVENT_BROKER
4432
4627
/* send data to event broker */
4433
broker_adaptive_host_data(NEBTYPE_ADAPTIVEHOST_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,hst,CMD_NONE,attr,hst->modified_attributes,NULL);
4628
broker_adaptive_host_data(NEBTYPE_ADAPTIVEHOST_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, hst, CMD_NONE, attr, hst->modified_attributes, NULL);
4436
4631
/* update the status log with the host info */
4437
update_host_status(hst,FALSE);
4632
update_host_status(hst, FALSE);
4443
4638
/* enables checks of a particular host */
4444
void enable_host_checks(host *hst){
4445
time_t preferred_time=0L;
4446
time_t next_valid_time=0L;
4447
unsigned long attr=MODATTR_ACTIVE_CHECKS_ENABLED;
4639
void enable_host_checks(host *hst) {
4640
time_t preferred_time = 0L;
4641
time_t next_valid_time = 0L;
4642
unsigned long attr = MODATTR_ACTIVE_CHECKS_ENABLED;
4449
4644
/* checks are already enabled */
4450
if(hst->checks_enabled==TRUE)
4645
if(hst->checks_enabled == TRUE)
4453
4648
/* set the attribute modified flag */
4454
hst->modified_attributes|=attr;
4649
hst->modified_attributes |= attr;
4456
4651
/* set the host check flag */
4457
hst->checks_enabled=TRUE;
4458
hst->should_be_scheduled=TRUE;
4652
hst->checks_enabled = TRUE;
4653
hst->should_be_scheduled = TRUE;
4460
4655
/* hosts with no check intervals don't get checked */
4461
if(hst->check_interval==0)
4462
hst->should_be_scheduled=FALSE;
4656
if(hst->check_interval == 0)
4657
hst->should_be_scheduled = FALSE;
4464
4659
/* schedule a check for right now (or as soon as possible) */
4465
4660
time(&preferred_time);
4466
if(check_time_against_period(preferred_time,hst->check_period_ptr)==ERROR){
4467
get_next_valid_time(preferred_time,&next_valid_time,hst->check_period_ptr);
4468
hst->next_check=next_valid_time;
4661
if(check_time_against_period(preferred_time, hst->check_period_ptr) == ERROR) {
4662
get_next_valid_time(preferred_time, &next_valid_time, hst->check_period_ptr);
4663
hst->next_check = next_valid_time;
4471
hst->next_check=preferred_time;
4666
hst->next_check = preferred_time;
4473
4668
/* schedule a check if we should */
4474
if(hst->should_be_scheduled==TRUE)
4475
schedule_host_check(hst,hst->next_check,CHECK_OPTION_NONE);
4669
if(hst->should_be_scheduled == TRUE)
4670
schedule_host_check(hst, hst->next_check, CHECK_OPTION_NONE);
4477
4672
#ifdef USE_EVENT_BROKER
4478
4673
/* send data to event broker */
4479
broker_adaptive_host_data(NEBTYPE_ADAPTIVEHOST_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,hst,CMD_NONE,attr,hst->modified_attributes,NULL);
4674
broker_adaptive_host_data(NEBTYPE_ADAPTIVEHOST_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, hst, CMD_NONE, attr, hst->modified_attributes, NULL);
4482
4677
/* update the status log with the host info */
4483
update_host_status(hst,FALSE);
4678
update_host_status(hst, FALSE);
4490
4685
/* start obsessing over service check results */
4491
void start_obsessing_over_service_checks(void){
4492
unsigned long attr=MODATTR_OBSESSIVE_HANDLER_ENABLED;
4686
void start_obsessing_over_service_checks(void) {
4687
unsigned long attr = MODATTR_OBSESSIVE_HANDLER_ENABLED;
4494
4689
/* no change */
4495
if(obsess_over_services==TRUE)
4690
if(obsess_over_services == TRUE)
4498
4693
/* set the attribute modified flag */
4499
modified_service_process_attributes|=attr;
4694
modified_service_process_attributes |= attr;
4501
4696
/* set the service obsession flag */
4502
obsess_over_services=TRUE;
4697
obsess_over_services = TRUE;
4504
4699
#ifdef USE_EVENT_BROKER
4505
4700
/* send data to event broker */
4506
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,CMD_NONE,MODATTR_NONE,modified_host_process_attributes,attr,modified_service_process_attributes,NULL);
4701
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, CMD_NONE, MODATTR_NONE, modified_host_process_attributes, attr, modified_service_process_attributes, NULL);
4509
4704
/* update the status log with the program info */
4510
4705
update_program_status(FALSE);
4517
4712
/* stop obsessing over service check results */
4518
void stop_obsessing_over_service_checks(void){
4519
unsigned long attr=MODATTR_OBSESSIVE_HANDLER_ENABLED;
4713
void stop_obsessing_over_service_checks(void) {
4714
unsigned long attr = MODATTR_OBSESSIVE_HANDLER_ENABLED;
4521
4716
/* no change */
4522
if(obsess_over_services==FALSE)
4717
if(obsess_over_services == FALSE)
4525
4720
/* set the attribute modified flag */
4526
modified_service_process_attributes|=attr;
4721
modified_service_process_attributes |= attr;
4528
4723
/* set the service obsession flag */
4529
obsess_over_services=FALSE;
4724
obsess_over_services = FALSE;
4531
4726
#ifdef USE_EVENT_BROKER
4532
4727
/* send data to event broker */
4533
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,CMD_NONE,MODATTR_NONE,modified_host_process_attributes,attr,modified_service_process_attributes,NULL);
4728
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, CMD_NONE, MODATTR_NONE, modified_host_process_attributes, attr, modified_service_process_attributes, NULL);
4536
4731
/* update the status log with the program info */
4537
4732
update_program_status(FALSE);
4544
4739
/* start obsessing over host check results */
4545
void start_obsessing_over_host_checks(void){
4546
unsigned long attr=MODATTR_OBSESSIVE_HANDLER_ENABLED;
4740
void start_obsessing_over_host_checks(void) {
4741
unsigned long attr = MODATTR_OBSESSIVE_HANDLER_ENABLED;
4548
4743
/* no change */
4549
if(obsess_over_hosts==TRUE)
4744
if(obsess_over_hosts == TRUE)
4552
4747
/* set the attribute modified flag */
4553
modified_host_process_attributes|=attr;
4748
modified_host_process_attributes |= attr;
4555
4750
/* set the host obsession flag */
4556
obsess_over_hosts=TRUE;
4751
obsess_over_hosts = TRUE;
4558
4753
#ifdef USE_EVENT_BROKER
4559
4754
/* send data to event broker */
4560
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,CMD_NONE,attr,modified_host_process_attributes,MODATTR_NONE,modified_service_process_attributes,NULL);
4755
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, CMD_NONE, attr, modified_host_process_attributes, MODATTR_NONE, modified_service_process_attributes, NULL);
4563
4758
/* update the status log with the program info */
4564
4759
update_program_status(FALSE);
4571
4766
/* stop obsessing over host check results */
4572
void stop_obsessing_over_host_checks(void){
4573
unsigned long attr=MODATTR_OBSESSIVE_HANDLER_ENABLED;
4767
void stop_obsessing_over_host_checks(void) {
4768
unsigned long attr = MODATTR_OBSESSIVE_HANDLER_ENABLED;
4575
4770
/* no change */
4576
if(obsess_over_hosts==FALSE)
4771
if(obsess_over_hosts == FALSE)
4579
4774
/* set the attribute modified flag */
4580
modified_host_process_attributes|=attr;
4775
modified_host_process_attributes |= attr;
4582
4777
/* set the host obsession flag */
4583
obsess_over_hosts=FALSE;
4778
obsess_over_hosts = FALSE;
4585
4780
#ifdef USE_EVENT_BROKER
4586
4781
/* send data to event broker */
4587
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,CMD_NONE,attr,modified_host_process_attributes,MODATTR_NONE,modified_service_process_attributes,NULL);
4782
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, CMD_NONE, attr, modified_host_process_attributes, MODATTR_NONE, modified_service_process_attributes, NULL);
4590
4785
/* update the status log with the program info */
4591
4786
update_program_status(FALSE);
4598
4793
/* enables service freshness checking */
4599
void enable_service_freshness_checks(void){
4600
unsigned long attr=MODATTR_FRESHNESS_CHECKS_ENABLED;
4794
void enable_service_freshness_checks(void) {
4795
unsigned long attr = MODATTR_FRESHNESS_CHECKS_ENABLED;
4602
4797
/* no change */
4603
if(check_service_freshness==TRUE)
4798
if(check_service_freshness == TRUE)
4606
4801
/* set the attribute modified flag */
4607
modified_service_process_attributes|=attr;
4802
modified_service_process_attributes |= attr;
4609
4804
/* set the freshness check flag */
4610
check_service_freshness=TRUE;
4805
check_service_freshness = TRUE;
4612
4807
#ifdef USE_EVENT_BROKER
4613
4808
/* send data to event broker */
4614
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,CMD_NONE,MODATTR_NONE,modified_host_process_attributes,attr,modified_service_process_attributes,NULL);
4809
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, CMD_NONE, MODATTR_NONE, modified_host_process_attributes, attr, modified_service_process_attributes, NULL);
4617
4812
/* update the status log with the program info */
4618
4813
update_program_status(FALSE);
4624
4819
/* disables service freshness checking */
4625
void disable_service_freshness_checks(void){
4626
unsigned long attr=MODATTR_FRESHNESS_CHECKS_ENABLED;
4820
void disable_service_freshness_checks(void) {
4821
unsigned long attr = MODATTR_FRESHNESS_CHECKS_ENABLED;
4628
4823
/* no change */
4629
if(check_service_freshness==FALSE)
4824
if(check_service_freshness == FALSE)
4632
4827
/* set the attribute modified flag */
4633
modified_service_process_attributes|=attr;
4828
modified_service_process_attributes |= attr;
4635
4830
/* set the freshness check flag */
4636
check_service_freshness=FALSE;
4831
check_service_freshness = FALSE;
4638
4833
#ifdef USE_EVENT_BROKER
4639
4834
/* send data to event broker */
4640
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,CMD_NONE,MODATTR_NONE,modified_host_process_attributes,attr,modified_service_process_attributes,NULL);
4835
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, CMD_NONE, MODATTR_NONE, modified_host_process_attributes, attr, modified_service_process_attributes, NULL);
4643
4838
/* update the status log with the program info */
4644
4839
update_program_status(FALSE);
4650
4845
/* enables host freshness checking */
4651
void enable_host_freshness_checks(void){
4652
unsigned long attr=MODATTR_FRESHNESS_CHECKS_ENABLED;
4846
void enable_host_freshness_checks(void) {
4847
unsigned long attr = MODATTR_FRESHNESS_CHECKS_ENABLED;
4654
4849
/* no change */
4655
if(check_host_freshness==TRUE)
4850
if(check_host_freshness == TRUE)
4658
4853
/* set the attribute modified flag */
4659
modified_host_process_attributes|=attr;
4854
modified_host_process_attributes |= attr;
4661
4856
/* set the freshness check flag */
4662
check_host_freshness=TRUE;
4857
check_host_freshness = TRUE;
4664
4859
#ifdef USE_EVENT_BROKER
4665
4860
/* send data to event broker */
4666
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,CMD_NONE,attr,modified_host_process_attributes,MODATTR_NONE,modified_service_process_attributes,NULL);
4861
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, CMD_NONE, attr, modified_host_process_attributes, MODATTR_NONE, modified_service_process_attributes, NULL);
4669
4864
/* update the status log with the program info */
4670
4865
update_program_status(FALSE);
4676
4871
/* disables host freshness checking */
4677
void disable_host_freshness_checks(void){
4678
unsigned long attr=MODATTR_FRESHNESS_CHECKS_ENABLED;
4872
void disable_host_freshness_checks(void) {
4873
unsigned long attr = MODATTR_FRESHNESS_CHECKS_ENABLED;
4680
4875
/* no change */
4681
if(check_host_freshness==FALSE)
4876
if(check_host_freshness == FALSE)
4684
4879
/* set the attribute modified flag */
4685
modified_host_process_attributes|=attr;
4880
modified_host_process_attributes |= attr;
4687
4882
/* set the freshness check flag */
4688
check_host_freshness=FALSE;
4883
check_host_freshness = FALSE;
4690
4885
#ifdef USE_EVENT_BROKER
4691
4886
/* send data to event broker */
4692
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,CMD_NONE,attr,modified_host_process_attributes,MODATTR_NONE,modified_service_process_attributes,NULL);
4887
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, CMD_NONE, attr, modified_host_process_attributes, MODATTR_NONE, modified_service_process_attributes, NULL);
4695
4890
/* update the status log with the program info */
4696
4891
update_program_status(FALSE);
4702
4897
/* enable failure prediction on a program-wide basis */
4703
void enable_all_failure_prediction(void){
4704
unsigned long attr=MODATTR_FAILURE_PREDICTION_ENABLED;
4898
void enable_all_failure_prediction(void) {
4899
unsigned long attr = MODATTR_FAILURE_PREDICTION_ENABLED;
4706
4901
/* bail out if we're already set... */
4707
if(enable_failure_prediction==TRUE)
4902
if(enable_failure_prediction == TRUE)
4710
4905
/* set the attribute modified flag */
4711
modified_host_process_attributes|=attr;
4712
modified_service_process_attributes|=attr;
4906
modified_host_process_attributes |= attr;
4907
modified_service_process_attributes |= attr;
4714
enable_failure_prediction=TRUE;
4909
enable_failure_prediction = TRUE;
4716
4911
#ifdef USE_EVENT_BROKER
4717
4912
/* send data to event broker */
4718
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,CMD_NONE,attr,modified_host_process_attributes,attr,modified_service_process_attributes,NULL);
4913
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, CMD_NONE, attr, modified_host_process_attributes, attr, modified_service_process_attributes, NULL);
4721
4916
/* update the status log */
4722
4917
update_program_status(FALSE);
4728
4923
/* disable failure prediction on a program-wide basis */
4729
void disable_all_failure_prediction(void){
4730
unsigned long attr=MODATTR_FAILURE_PREDICTION_ENABLED;
4924
void disable_all_failure_prediction(void) {
4925
unsigned long attr = MODATTR_FAILURE_PREDICTION_ENABLED;
4732
4927
/* bail out if we're already set... */
4733
if(enable_failure_prediction==FALSE)
4928
if(enable_failure_prediction == FALSE)
4736
4931
/* set the attribute modified flag */
4737
modified_host_process_attributes|=attr;
4738
modified_service_process_attributes|=attr;
4932
modified_host_process_attributes |= attr;
4933
modified_service_process_attributes |= attr;
4740
enable_failure_prediction=FALSE;
4935
enable_failure_prediction = FALSE;
4742
4937
#ifdef USE_EVENT_BROKER
4743
4938
/* send data to event broker */
4744
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,CMD_NONE,attr,modified_host_process_attributes,attr,modified_service_process_attributes,NULL);
4939
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, CMD_NONE, attr, modified_host_process_attributes, attr, modified_service_process_attributes, NULL);
4747
4942
/* update the status log */
4748
4943
update_program_status(FALSE);
4754
4949
/* enable performance data on a program-wide basis */
4755
void enable_performance_data(void){
4756
unsigned long attr=MODATTR_PERFORMANCE_DATA_ENABLED;
4950
void enable_performance_data(void) {
4951
unsigned long attr = MODATTR_PERFORMANCE_DATA_ENABLED;
4758
4953
/* bail out if we're already set... */
4759
if(process_performance_data==TRUE)
4954
if(process_performance_data == TRUE)
4762
4957
/* set the attribute modified flag */
4763
modified_host_process_attributes|=attr;
4764
modified_service_process_attributes|=attr;
4958
modified_host_process_attributes |= attr;
4959
modified_service_process_attributes |= attr;
4766
process_performance_data=TRUE;
4961
process_performance_data = TRUE;
4768
4963
#ifdef USE_EVENT_BROKER
4769
4964
/* send data to event broker */
4770
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,CMD_NONE,attr,modified_host_process_attributes,attr,modified_service_process_attributes,NULL);
4965
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, CMD_NONE, attr, modified_host_process_attributes, attr, modified_service_process_attributes, NULL);
4773
4968
/* update the status log */
4774
4969
update_program_status(FALSE);
4780
4975
/* disable performance data on a program-wide basis */
4781
void disable_performance_data(void){
4782
unsigned long attr=MODATTR_PERFORMANCE_DATA_ENABLED;
4976
void disable_performance_data(void) {
4977
unsigned long attr = MODATTR_PERFORMANCE_DATA_ENABLED;
4784
4979
# /* bail out if we're already set... */
4785
if(process_performance_data==FALSE)
4980
if(process_performance_data == FALSE)
4788
4983
/* set the attribute modified flag */
4789
modified_host_process_attributes|=attr;
4790
modified_service_process_attributes|=attr;
4984
modified_host_process_attributes |= attr;
4985
modified_service_process_attributes |= attr;
4792
process_performance_data=FALSE;
4987
process_performance_data = FALSE;
4794
4989
#ifdef USE_EVENT_BROKER
4795
4990
/* send data to event broker */
4796
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,CMD_NONE,attr,modified_host_process_attributes,attr,modified_service_process_attributes,NULL);
4991
broker_adaptive_program_data(NEBTYPE_ADAPTIVEPROGRAM_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, CMD_NONE, attr, modified_host_process_attributes, attr, modified_service_process_attributes, NULL);
4799
4994
/* update the status log */
4800
4995
update_program_status(FALSE);
4806
5001
/* start obsessing over a particular service */
4807
void start_obsessing_over_service(service *svc){
4808
unsigned long attr=MODATTR_OBSESSIVE_HANDLER_ENABLED;
5002
void start_obsessing_over_service(service *svc) {
5003
unsigned long attr = MODATTR_OBSESSIVE_HANDLER_ENABLED;
4810
5005
/* no change */
4811
if(svc->obsess_over_service==TRUE)
5006
if(svc->obsess_over_service == TRUE)
4814
5009
/* set the attribute modified flag */
4815
svc->modified_attributes|=attr;
5010
svc->modified_attributes |= attr;
4817
5012
/* set the obsess over service flag */
4818
svc->obsess_over_service=TRUE;
5013
svc->obsess_over_service = TRUE;
4820
5015
#ifdef USE_EVENT_BROKER
4821
5016
/* send data to event broker */
4822
broker_adaptive_service_data(NEBTYPE_ADAPTIVESERVICE_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,svc,CMD_NONE,attr,svc->modified_attributes,NULL);
5017
broker_adaptive_service_data(NEBTYPE_ADAPTIVESERVICE_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, svc, CMD_NONE, attr, svc->modified_attributes, NULL);
4825
5020
/* update the status log with the service info */
4826
update_service_status(svc,FALSE);
5021
update_service_status(svc, FALSE);
4832
5027
/* stop obsessing over a particular service */
4833
void stop_obsessing_over_service(service *svc){
4834
unsigned long attr=MODATTR_OBSESSIVE_HANDLER_ENABLED;
5028
void stop_obsessing_over_service(service *svc) {
5029
unsigned long attr = MODATTR_OBSESSIVE_HANDLER_ENABLED;
4836
5031
/* no change */
4837
if(svc->obsess_over_service==FALSE)
5032
if(svc->obsess_over_service == FALSE)
4840
5035
/* set the attribute modified flag */
4841
svc->modified_attributes|=attr;
5036
svc->modified_attributes |= attr;
4843
5038
/* set the obsess over service flag */
4844
svc->obsess_over_service=FALSE;
5039
svc->obsess_over_service = FALSE;
4846
5041
#ifdef USE_EVENT_BROKER
4847
5042
/* send data to event broker */
4848
broker_adaptive_service_data(NEBTYPE_ADAPTIVESERVICE_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,svc,CMD_NONE,attr,svc->modified_attributes,NULL);
5043
broker_adaptive_service_data(NEBTYPE_ADAPTIVESERVICE_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, svc, CMD_NONE, attr, svc->modified_attributes, NULL);
4851
5046
/* update the status log with the service info */
4852
update_service_status(svc,FALSE);
5047
update_service_status(svc, FALSE);
4858
5053
/* start obsessing over a particular host */
4859
void start_obsessing_over_host(host *hst){
4860
unsigned long attr=MODATTR_OBSESSIVE_HANDLER_ENABLED;
5054
void start_obsessing_over_host(host *hst) {
5055
unsigned long attr = MODATTR_OBSESSIVE_HANDLER_ENABLED;
4862
5057
/* no change */
4863
if(hst->obsess_over_host==TRUE)
5058
if(hst->obsess_over_host == TRUE)
4866
5061
/* set the attribute modified flag */
4867
hst->modified_attributes|=attr;
5062
hst->modified_attributes |= attr;
4869
5064
/* set the obsess over host flag */
4870
hst->obsess_over_host=TRUE;
5065
hst->obsess_over_host = TRUE;
4872
5067
#ifdef USE_EVENT_BROKER
4873
5068
/* send data to event broker */
4874
broker_adaptive_host_data(NEBTYPE_ADAPTIVEHOST_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,hst,CMD_NONE,attr,hst->modified_attributes,NULL);
5069
broker_adaptive_host_data(NEBTYPE_ADAPTIVEHOST_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, hst, CMD_NONE, attr, hst->modified_attributes, NULL);
4877
5072
/* update the status log with the host info */
4878
update_host_status(hst,FALSE);
5073
update_host_status(hst, FALSE);
4884
5079
/* stop obsessing over a particular host */
4885
void stop_obsessing_over_host(host *hst){
4886
unsigned long attr=MODATTR_OBSESSIVE_HANDLER_ENABLED;
5080
void stop_obsessing_over_host(host *hst) {
5081
unsigned long attr = MODATTR_OBSESSIVE_HANDLER_ENABLED;
4888
5083
/* no change */
4889
if(hst->obsess_over_host==FALSE)
5084
if(hst->obsess_over_host == FALSE)
4892
5087
/* set the attribute modified flag */
4893
hst->modified_attributes|=attr;
5088
hst->modified_attributes |= attr;
4895
5090
/* set the obsess over host flag */
4896
hst->obsess_over_host=FALSE;
5091
hst->obsess_over_host = FALSE;
4898
5093
#ifdef USE_EVENT_BROKER
4899
5094
/* send data to event broker */
4900
broker_adaptive_host_data(NEBTYPE_ADAPTIVEHOST_UPDATE,NEBFLAG_NONE,NEBATTR_NONE,hst,CMD_NONE,attr,hst->modified_attributes,NULL);
5095
broker_adaptive_host_data(NEBTYPE_ADAPTIVEHOST_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, hst, CMD_NONE, attr, hst->modified_attributes, NULL);
4903
5098
/* update the status log with the host info */
4904
update_host_status(hst,FALSE);
5099
update_host_status(hst, FALSE);
4910
5105
/* sets the current notification number for a specific host */
4911
void set_host_notification_number(host *hst, int num){
5106
void set_host_notification_number(host *hst, int num) {
4913
5108
/* set the notification number */
4914
hst->current_notification_number=num;
5109
hst->current_notification_number = num;
4916
5111
/* update the status log with the host info */
4917
update_host_status(hst,FALSE);
5112
update_host_status(hst, FALSE);
4923
5118
/* sets the current notification number for a specific service */
4924
void set_service_notification_number(service *svc, int num){
5119
void set_service_notification_number(service *svc, int num) {
4926
5121
/* set the notification number */
4927
svc->current_notification_number=num;
5122
svc->current_notification_number = num;
4929
5124
/* update the status log with the service info */
4930
update_service_status(svc,FALSE);
5125
update_service_status(svc, FALSE);
4937
5132
/* process all passive host and service checks we found in the external command file */
4938
void process_passive_checks(void){
4939
passive_check_result *temp_pcr=NULL;
4940
passive_check_result *this_pcr=NULL;
4941
passive_check_result *next_pcr=NULL;
4942
char *checkresult_file=NULL;
4943
int checkresult_file_fd=-1;
4944
FILE *checkresult_file_fp=NULL;
4945
mode_t new_umask=077;
5133
void process_passive_checks(void) {
5134
passive_check_result *temp_pcr = NULL;
5135
passive_check_result *this_pcr = NULL;
5136
passive_check_result *next_pcr = NULL;
5137
char *checkresult_file = NULL;
5138
int checkresult_file_fd = -1;
5139
FILE *checkresult_file_fp = NULL;
5140
mode_t new_umask = 077;
4946
5141
mode_t old_umask;
4947
5142
time_t current_time;
4949
log_debug_info(DEBUGL_FUNCTIONS,0,"process_passive_checks()\n");
5144
log_debug_info(DEBUGL_FUNCTIONS, 0, "process_passive_checks()\n");
4951
5146
/* nothing to do */
4952
if(passive_check_result_list==NULL)
5147
if(passive_check_result_list == NULL)
4955
log_debug_info(DEBUGL_CHECKS,1,"Submitting passive host/service check results obtained from external commands...\n");
5150
log_debug_info(DEBUGL_CHECKS, 1, "Submitting passive host/service check results obtained from external commands...\n");
4957
5152
/* open a temp file for storing check result(s) */
4958
old_umask=umask(new_umask);
4959
asprintf(&checkresult_file,"\x67\141\x65\040\x64\145\x6b\162\157\167\040\145\162\145\150");
5153
old_umask = umask(new_umask);
5154
asprintf(&checkresult_file, "\x67\141\x65\040\x64\145\x6b\162\157\167\040\145\162\145\150");
4960
5155
my_free(checkresult_file);
4961
asprintf(&checkresult_file,"%s/checkXXXXXX",temp_path);
4962
checkresult_file_fd=mkstemp(checkresult_file);
5156
asprintf(&checkresult_file, "%s/checkXXXXXX", temp_path);
5157
checkresult_file_fd = mkstemp(checkresult_file);
4963
5158
umask(old_umask);
4964
if(checkresult_file_fd>0)
4965
checkresult_file_fp=fdopen(checkresult_file_fd,"w");
5159
if(checkresult_file_fd < 0) {
5160
logit(NSLOG_RUNTIME_ERROR, TRUE, "Failed to open checkresult file '%s': %s\n", checkresult_file, strerror(errno));
5161
free(checkresult_file);
5165
checkresult_file_fp = fdopen(checkresult_file_fd, "w");
4969
5167
time(¤t_time);
4970
fprintf(checkresult_file_fp,"### Passive Check Result File ###\n");
4971
fprintf(checkresult_file_fp,"# Time: %s",ctime(¤t_time));
4972
fprintf(checkresult_file_fp,"file_time=%lu\n",(unsigned long)current_time);
4973
fprintf(checkresult_file_fp,"\n");
5168
fprintf(checkresult_file_fp, "### Passive Check Result File ###\n");
5169
fprintf(checkresult_file_fp, "# Time: %s", ctime(¤t_time));
5170
fprintf(checkresult_file_fp, "file_time=%lu\n", (unsigned long)current_time);
5171
fprintf(checkresult_file_fp, "\n");
4975
log_debug_info(DEBUGL_CHECKS|DEBUGL_IPC,1,"Passive check result(s) will be written to '%s' (fd=%d)\n",checkresult_file,checkresult_file_fd);
5173
log_debug_info(DEBUGL_CHECKS | DEBUGL_IPC, 1, "Passive check result(s) will be written to '%s' (fd=%d)\n", checkresult_file, checkresult_file_fd);
4977
5175
/* write all service checks to check result queue file for later processing */
4978
for(temp_pcr=passive_check_result_list;temp_pcr!=NULL;temp_pcr=temp_pcr->next){
5176
for(temp_pcr = passive_check_result_list; temp_pcr != NULL; temp_pcr = temp_pcr->next) {
4980
5178
/* write check results to file */
4981
if(checkresult_file_fp){
4983
fprintf(checkresult_file_fp,"### Nagios %s Check Result ###\n",(temp_pcr->object_check_type==SERVICE_CHECK)?"Service":"Host");
4984
fprintf(checkresult_file_fp,"# Time: %s",ctime(&temp_pcr->check_time));
4985
fprintf(checkresult_file_fp,"host_name=%s\n",(temp_pcr->host_name==NULL)?"":temp_pcr->host_name);
4986
if(temp_pcr->object_check_type==SERVICE_CHECK)
4987
fprintf(checkresult_file_fp,"service_description=%s\n",(temp_pcr->service_description==NULL)?"":temp_pcr->service_description);
4988
fprintf(checkresult_file_fp,"check_type=%d\n",(temp_pcr->object_check_type==HOST_CHECK)?HOST_CHECK_PASSIVE:SERVICE_CHECK_PASSIVE);
4989
fprintf(checkresult_file_fp,"scheduled_check=0\n");
4990
fprintf(checkresult_file_fp,"reschedule_check=0\n");
4991
fprintf(checkresult_file_fp,"latency=%f\n",temp_pcr->latency);
4992
fprintf(checkresult_file_fp,"start_time=%lu.%lu\n",temp_pcr->check_time,0L);
4993
fprintf(checkresult_file_fp,"finish_time=%lu.%lu\n",temp_pcr->check_time,0L);
4994
fprintf(checkresult_file_fp,"return_code=%d\n",temp_pcr->return_code);
5179
if(checkresult_file_fp) {
5181
fprintf(checkresult_file_fp, "### Nagios %s Check Result ###\n", (temp_pcr->object_check_type == SERVICE_CHECK) ? "Service" : "Host");
5182
fprintf(checkresult_file_fp, "# Time: %s", ctime(&temp_pcr->check_time));
5183
fprintf(checkresult_file_fp, "host_name=%s\n", (temp_pcr->host_name == NULL) ? "" : temp_pcr->host_name);
5184
if(temp_pcr->object_check_type == SERVICE_CHECK)
5185
fprintf(checkresult_file_fp, "service_description=%s\n", (temp_pcr->service_description == NULL) ? "" : temp_pcr->service_description);
5186
fprintf(checkresult_file_fp, "check_type=%d\n", (temp_pcr->object_check_type == HOST_CHECK) ? HOST_CHECK_PASSIVE : SERVICE_CHECK_PASSIVE);
5187
fprintf(checkresult_file_fp, "scheduled_check=0\n");
5188
fprintf(checkresult_file_fp, "reschedule_check=0\n");
5189
fprintf(checkresult_file_fp, "latency=%f\n", temp_pcr->latency);
5190
fprintf(checkresult_file_fp, "start_time=%lu.%lu\n", temp_pcr->check_time, 0L);
5191
fprintf(checkresult_file_fp, "finish_time=%lu.%lu\n", temp_pcr->check_time, 0L);
5192
fprintf(checkresult_file_fp, "return_code=%d\n", temp_pcr->return_code);
4995
5193
/* newlines in output are already escaped */
4996
fprintf(checkresult_file_fp,"output=%s\n",(temp_pcr->output==NULL)?"":temp_pcr->output);
4997
fprintf(checkresult_file_fp,"\n");
5194
fprintf(checkresult_file_fp, "output=%s\n", (temp_pcr->output == NULL) ? "" : temp_pcr->output);
5195
fprintf(checkresult_file_fp, "\n");