From 8c7d6c6ed18d02b5a062c4cc275170ff3e3b5da6 Mon Sep 17 00:00:00 2001 From: hirenp Date: Wed, 19 May 2010 15:49:45 +0200 Subject: [PATCH] tracker feature 306 regarding escalations --- base/checks.c | 9 +++ base/notifications.c | 172 +++++++++++++++++++++++++++++++++++++++---- base/sehandlers.c | 5 +- cgi/config.c | 29 +++++++- common/objects.c | 19 ++++- include/objects.h | 23 +++++- include/statusdata.h | 5 ++ xdata/xodtemplate.c | 130 +++++++++++++++++++++++++++++++- xdata/xodtemplate.h | 20 +++++ xdata/xrddefault.c | 15 ++++ xdata/xsddefault.c | 15 ++++ 11 files changed, 415 insertions(+), 27 deletions(-) diff --git a/base/checks.c b/base/checks.c index 746058a6e..ad62d699b 100644 --- a/base/checks.c +++ b/base/checks.c @@ -1291,6 +1291,9 @@ int handle_async_service_check_result(service *temp_service, check_result *queue temp_service->last_notification=(time_t)0; temp_service->next_notification=(time_t)0; temp_service->current_notification_number=0; + temp_service->current_warning_notification_number=0; + temp_service->current_critical_notification_number=0; + temp_service->current_unknown_notification_number=0; temp_service->problem_has_been_acknowledged=FALSE; temp_service->acknowledgement_type=ACKNOWLEDGEMENT_NONE; temp_service->notified_on_unknown=FALSE; @@ -1520,6 +1523,12 @@ int handle_async_service_check_result(service *temp_service, check_result *queue check_for_host_flapping(temp_host,TRUE,FALSE,TRUE); flapping_check_done=TRUE; + if (hard_state_change==TRUE){ + temp_service->current_warning_notification_number=0; + temp_service->current_critical_notification_number=0; + temp_service->current_unknown_notification_number=0; + } + /* (re)send notifications out about this service problem if the host is up (and was at last check also) and the dependencies were okay... */ service_notification(temp_service,NOTIFICATION_NORMAL,NULL,NULL,NOTIFICATION_OPTION_NONE); diff --git a/base/notifications.c b/base/notifications.c index a7d6063bb..8cda11a60 100644 --- a/base/notifications.c +++ b/base/notifications.c @@ -98,10 +98,23 @@ int service_notification(service *svc, int type, char *not_author, char *not_dat /* should the notification number be increased? */ if(type==NOTIFICATION_NORMAL || (options & NOTIFICATION_OPTION_INCREMENT)){ svc->current_notification_number++; + /* also increment the warning/critical/unknown state counter */ + if (svc->current_state == STATE_WARNING) { + svc->current_warning_notification_number++; + } + if (svc->current_state == STATE_CRITICAL) { + svc->current_critical_notification_number++; + } + if (svc->current_state == STATE_UNKNOWN) { + svc->current_unknown_notification_number++; + } increment_notification_number=TRUE; } log_debug_info(DEBUGL_NOTIFICATIONS,1,"Current notification number: %d (%s)\n",svc->current_notification_number,(increment_notification_number==TRUE)?"incremented":"unchanged"); + log_debug_info(DEBUGL_NOTIFICATIONS,1,"Current warning notification number: %d (%s)\n",svc->current_warning_notification_number,(increment_notification_number==TRUE)?"incremented":"unchanged"); + log_debug_info(DEBUGL_NOTIFICATIONS,1,"Current critical notification number: %d (%s)\n",svc->current_critical_notification_number,(increment_notification_number==TRUE)?"incremented":"unchanged"); + log_debug_info(DEBUGL_NOTIFICATIONS,1,"Current unknown notification number: %d (%s)\n",svc->current_unknown_notification_number,(increment_notification_number==TRUE)?"incremented":"unchanged"); /* save and increase the current notification id */ svc->current_notification_id=next_notification_id; @@ -256,6 +269,15 @@ int service_notification(service *svc, int type, char *not_author, char *not_dat /* adjust current notification number */ svc->current_notification_number--; + if (svc->current_state == STATE_WARNING) { + svc->current_warning_notification_number--; + } + if (svc->current_state == STATE_CRITICAL) { + svc->current_critical_notification_number--; + } + if (svc->current_state == STATE_UNKNOWN) { + svc->current_unknown_notification_number--; + } log_debug_info(DEBUGL_NOTIFICATIONS,0,"No contacts were notified. Next possible notification time: %s",ctime(&svc->next_notification)); } @@ -269,8 +291,18 @@ int service_notification(service *svc, int type, char *not_author, char *not_dat else{ /* readjust current notification number, since one didn't go out */ - if(increment_notification_number==TRUE) + if(increment_notification_number==TRUE) { svc->current_notification_number--; + if (svc->current_state == STATE_WARNING) { + svc->current_warning_notification_number--; + } + if (svc->current_state == STATE_CRITICAL) { + svc->current_critical_notification_number--; + } + if (svc->current_state == STATE_UNKNOWN) { + svc->current_unknown_notification_number--; + } + } log_debug_info(DEBUGL_NOTIFICATIONS,0,"No contacts were found for notification purposes. No notification was sent out.\n"); } @@ -793,6 +825,10 @@ int notify_contact_of_service(contact *cntct, service *svc, int type, char *not_ /* checks to see if a service escalation entry is a match for the current service notification */ int is_valid_escalation_for_service_notification(service *svc, serviceescalation *se, int options){ int notification_number=0; + int warning_notification_number=0; + int critical_notification_number=0; + int unknown_notification_number=0; + int widematch=1; time_t current_time=0L; service *temp_service=NULL; @@ -802,10 +838,14 @@ int is_valid_escalation_for_service_notification(service *svc, serviceescalation time(¤t_time); /* if this is a recovery, really we check for who got notified about a previous problem */ - if(svc->current_state==STATE_OK) + if(svc->current_state==STATE_OK) notification_number=svc->current_notification_number-1; else notification_number=svc->current_notification_number; + /* These will not be incremented in the case of a recovery, so use the current values regardless of the state */ + warning_notification_number=svc->current_warning_notification_number; + critical_notification_number=svc->current_critical_notification_number; + unknown_notification_number=svc->current_unknown_notification_number; /* this entry if it is not for this service */ temp_service=se->service_ptr; @@ -817,13 +857,59 @@ int is_valid_escalation_for_service_notification(service *svc, serviceescalation if(options & NOTIFICATION_OPTION_BROADCAST) return TRUE; - /* skip this escalation if it happens later */ - if(se->first_notification > notification_number) - return FALSE; + /* skip this escalation if it happens later + * Only skip if none of the notifications numbers match */ + + if(se->first_notification == -2 || se->first_notification > notification_number) + widematch=0; + + if (!widematch){ + switch (svc->current_state){ + case STATE_WARNING:{ + if (se->first_warning_notification == -2 || se->first_warning_notification > warning_notification_number) + return FALSE; + break; + } + case STATE_CRITICAL:{ + if (se->first_critical_notification == -2 || se->first_critical_notification > critical_notification_number) + return FALSE; + break; + } + case STATE_UNKNOWN:{ + if (se->first_unknown_notification == -2 || se->first_unknown_notification > unknown_notification_number) + return FALSE; + break; + } + } + } - /* skip this escalation if it has already passed */ - if(se->last_notification!=0 && se->last_notification < notification_number) - return FALSE; + /* skip this escalation if it has already passed + * only skip if none of the notifications numbers match */ + + widematch=1; + if(se->last_notification == -2 || se->last_notification!=0 && se->last_notification < notification_number) + widematch=0; + + + if (!widematch){ + switch (svc->current_state){ + case STATE_WARNING:{ + if (se->last_warning_notification == -2 || ((se->last_warning_notification!=0) && (se->last_warning_notification < warning_notification_number))) + return FALSE; + break; + } + case STATE_CRITICAL:{ + if (se->last_critical_notification == -2 || ((se->last_critical_notification!=0) && (se->last_critical_notification < critical_notification_number))) + return FALSE; + break; + } + case STATE_UNKNOWN:{ + if (se->last_unknown_notification == -2 || ((se->last_unknown_notification!=0) && (se->last_unknown_notification < unknown_notification_number))) + return FALSE; + break; + } + } + } /* skip this escalation if it has a timeperiod and the current time isn't valid */ if(se->escalation_period!=NULL && check_time_against_period(current_time,se->escalation_period_ptr)==ERROR) @@ -1076,6 +1162,13 @@ int host_notification(host *hst, int type, char *not_author, char *not_data, int /* should the notification number be increased? */ if(type==NOTIFICATION_NORMAL || (options & NOTIFICATION_OPTION_INCREMENT)){ hst->current_notification_number++; + /* also increment down/unreachable state counter */ + if (hst->current_state == HOST_DOWN) { + hst->current_down_notification_number++; + } + if (hst->current_state == HOST_UNREACHABLE) { + hst->current_unreachable_notification_number++; + } increment_notification_number=TRUE; } @@ -1231,6 +1324,12 @@ int host_notification(host *hst, int type, char *not_author, char *not_data, int /* adjust current notification number */ hst->current_notification_number--; + if (hst->current_state == HOST_DOWN) { + hst->current_down_notification_number--; + } + if (hst->current_state == HOST_UNREACHABLE) { + hst->current_unreachable_notification_number--; + } log_debug_info(DEBUGL_NOTIFICATIONS,0,"No contacts were notified. Next possible notification time: %s",ctime(&hst->next_host_notification)); } @@ -1243,8 +1342,15 @@ int host_notification(host *hst, int type, char *not_author, char *not_data, int else{ /* adjust notification number, since no notification actually went out */ - if(increment_notification_number==TRUE) + if(increment_notification_number==TRUE) { hst->current_notification_number--; + if (hst->current_state == HOST_DOWN) { + hst->current_down_notification_number--; + } + if (hst->current_state == HOST_UNREACHABLE) { + hst->current_unreachable_notification_number--; + } + } log_debug_info(DEBUGL_NOTIFICATIONS,0,"No contacts were found for notification purposes. No notification was sent out.\n"); } @@ -1730,7 +1836,10 @@ int notify_contact_of_host(contact *cntct, host *hst, int type, char *not_author /* checks to see if a host escalation entry is a match for the current host notification */ int is_valid_escalation_for_host_notification(host *hst, hostescalation *he, int options){ int notification_number=0; + int down_notification_number=0; + int unreachable_notification_number=0; time_t current_time=0L; + int widematch=1; host *temp_host=NULL; log_debug_info(DEBUGL_FUNCTIONS,0,"is_valid_escalation_for_host_notification()\n"); @@ -1743,6 +1852,10 @@ int is_valid_escalation_for_host_notification(host *hst, hostescalation *he, int notification_number=hst->current_notification_number-1; else notification_number=hst->current_notification_number; + /* these are not incremented in the case of recovery, so don't need special handling */ + down_notification_number=hst->current_down_notification_number; + unreachable_notification_number=hst->current_unreachable_notification_number; + /* find the host this escalation entry is associated with */ temp_host=he->host_ptr; @@ -1755,12 +1868,43 @@ int is_valid_escalation_for_host_notification(host *hst, hostescalation *he, int return TRUE; /* skip this escalation if it happens later */ - if(he->first_notification > notification_number) - return FALSE; + if(he->first_notification == -2 || he->first_notification > notification_number) + widematch=0; + + if (!widematch){ + switch (hst->current_state){ + case HOST_DOWN:{ + if (he->first_down_notification == -2 || he->first_down_notification > down_notification_number) + return FALSE; + break; + } + case HOST_UNREACHABLE:{ + if (he->first_unreachable_notification == -2 || he->first_unreachable_notification > unreachable_notification_number) + return FALSE; + break; + } + } + } - /* skip this escalation if it has already passed */ - if(he->last_notification!=0 && he->last_notification < notification_number) - return FALSE; + /* skip this escalation if it has already passed. only skip if none match */ + widematch=1; + if(he->last_notification == -2 || he->last_notification!=0 && he->last_notification < notification_number) + widematch=0; + + if (!widematch){ + switch (hst->current_state){ + case HOST_DOWN:{ + if (he->last_down_notification == -2 || he->last_down_notification!=0 && he->last_down_notification < down_notification_number) + return FALSE; + break; + } + case HOST_UNREACHABLE:{ + if (he->last_unreachable_notification == -2 || he->last_unreachable_notification && he->last_unreachable_notification < unreachable_notification_number) + return FALSE; + break; + } + } + } /* skip this escalation if it has a timeperiod and the current time isn't valid */ if(he->escalation_period!=NULL && check_time_against_period(current_time,he->escalation_period_ptr)==ERROR) diff --git a/base/sehandlers.c b/base/sehandlers.c index fec976983..8ab9e7c98 100644 --- a/base/sehandlers.c +++ b/base/sehandlers.c @@ -747,8 +747,11 @@ int handle_host_state(host *hst){ check_pending_flex_host_downtime(hst); /* notify contacts about the recovery or problem if its a "hard" state */ - if(hst->state_type==HARD_STATE) + if(hst->state_type==HARD_STATE){ + hst->current_down_notification_number=0; + hst->current_unreachable_notification_number=0; host_notification(hst,NOTIFICATION_NORMAL,NULL,NULL,NOTIFICATION_OPTION_NONE); + } /* handle the host state change */ handle_host_event(hst); diff --git a/cgi/config.c b/cgi/config.c index e0d4e41f0..15f4a27a5 100644 --- a/cgi/config.c +++ b/cgi/config.c @@ -1872,13 +1872,26 @@ void display_serviceescalations(void){ printf(" "); printf("\n"); - printf("%d",bg_class,temp_se->first_notification); + printf("%d, %d, %d, %d",bg_class,temp_se->first_notification,temp_se->first_warning_notification,temp_se->first_critical_notification, temp_se->first_unknown_notification); printf("",bg_class); + if(temp_se->last_notification==0) + printf("Infinity, "); + else + printf("%d, ",temp_se->last_notification); + if(temp_se->last_warning_notification==0) + printf("Infinity, "); + else + printf("%d, ",temp_se->last_warning_notification); + if(temp_se->last_critical_notification==0) printf("Infinity"); else - printf("%d",temp_se->last_notification); + printf("%d",temp_se->last_critical_notification); + if(temp_se->last_unknown_notification==0) + printf("Infinity"); + else + printf("%d", temp_se->last_unknown_notification); printf("\n"); get_interval_time_string(temp_se->notification_interval,time_string,sizeof(time_string)); @@ -2081,13 +2094,21 @@ void display_hostescalations(void){ printf(" "); printf("\n"); - printf("%d",bg_class,temp_he->first_notification); + printf("%d, %d, %d",bg_class,temp_he->first_notification,temp_he->first_down_notification,temp_he->first_unreachable_notification); printf("",bg_class); if(temp_he->last_notification==0) + printf("Infinity, "); + else + printf("%d, ",temp_he->last_notification); + if(temp_he->last_down_notification==0) + printf("Infinity, "); + else + printf("%d, ",temp_he->last_down_notification); + if(temp_he->last_unreachable_notification==0) printf("Infinity"); else - printf("%d",temp_he->last_notification); + printf("%d",temp_he->last_unreachable_notification); printf("\n"); get_interval_time_string(temp_he->notification_interval,time_string,sizeof(time_string)); diff --git a/common/objects.c b/common/objects.c index 251926efb..42df52d15 100644 --- a/common/objects.c +++ b/common/objects.c @@ -764,6 +764,8 @@ host *add_host(char *name, char *display_name, char *alias, char *address, char new_host->notified_on_down=FALSE; new_host->notified_on_unreachable=FALSE; new_host->current_notification_number=0; + new_host->current_down_notification_number=0; + new_host->current_unreachable_notification_number=0; new_host->current_notification_id=0L; new_host->no_more_notifications=FALSE; new_host->check_flapping_recovery_notification=FALSE; @@ -1695,6 +1697,9 @@ service *add_service(char *host_name, char *description, char *display_name, cha new_service->notified_on_warning=FALSE; new_service->notified_on_critical=FALSE; new_service->current_notification_number=0; + new_service->current_warning_notification_number=0; + new_service->current_critical_notification_number=0; + new_service->current_unknown_notification_number=0; new_service->current_notification_id=0L; new_service->latency=0.0; new_service->execution_time=0.0; @@ -1874,7 +1879,7 @@ command *add_command(char *name,char *value){ /* add a new service escalation to the list in memory */ -serviceescalation *add_serviceescalation(char *host_name,char *description, int first_notification, int last_notification, double notification_interval, char *escalation_period, int escalate_on_warning, int escalate_on_unknown, int escalate_on_critical, int escalate_on_recovery){ +serviceescalation *add_serviceescalation(char *host_name,char *description, int first_notification, int last_notification, int first_warning_notification, int last_warning_notification, int first_critical_notification, int last_critical_notification, int first_unknown_notification, int last_unknown_notification, double notification_interval, char *escalation_period, int escalate_on_warning, int escalate_on_unknown, int escalate_on_critical, int escalate_on_recovery){ serviceescalation *new_serviceescalation=NULL; int result=OK; @@ -1904,6 +1909,12 @@ serviceescalation *add_serviceescalation(char *host_name,char *description, int new_serviceescalation->first_notification=first_notification; new_serviceescalation->last_notification=last_notification; + new_serviceescalation->first_warning_notification=first_warning_notification; + new_serviceescalation->last_warning_notification=last_warning_notification; + new_serviceescalation->first_critical_notification=first_critical_notification; + new_serviceescalation->last_critical_notification=last_critical_notification; + new_serviceescalation->first_unknown_notification=first_unknown_notification; + new_serviceescalation->last_unknown_notification=last_unknown_notification; new_serviceescalation->notification_interval=(notification_interval<=0)?0:notification_interval; new_serviceescalation->escalate_on_recovery=(escalate_on_recovery>0)?TRUE:FALSE; new_serviceescalation->escalate_on_warning=(escalate_on_warning>0)?TRUE:FALSE; @@ -2148,7 +2159,7 @@ hostdependency *add_host_dependency(char *dependent_host_name, char *host_name, /* add a new host escalation to the list in memory */ -hostescalation *add_hostescalation(char *host_name,int first_notification,int last_notification, double notification_interval, char *escalation_period, int escalate_on_down, int escalate_on_unreachable, int escalate_on_recovery){ +hostescalation *add_hostescalation(char *host_name,int first_notification,int last_notification, int first_down_notification, int last_down_notification, int first_unreachable_notification, int last_unreachable_notification, double notification_interval, char *escalation_period, int escalate_on_down, int escalate_on_unreachable, int escalate_on_recovery){ hostescalation *new_hostescalation=NULL; int result=OK; @@ -2176,6 +2187,10 @@ hostescalation *add_hostescalation(char *host_name,int first_notification,int la new_hostescalation->first_notification=first_notification; new_hostescalation->last_notification=last_notification; + new_hostescalation->first_down_notification=first_down_notification; + new_hostescalation->last_down_notification=last_down_notification; + new_hostescalation->first_unreachable_notification=first_unreachable_notification; + new_hostescalation->last_unreachable_notification=last_unreachable_notification; new_hostescalation->notification_interval=(notification_interval<=0)?0:notification_interval; new_hostescalation->escalate_on_recovery=(escalate_on_recovery>0)?TRUE:FALSE; new_hostescalation->escalate_on_down=(escalate_on_down>0)?TRUE:FALSE; diff --git a/include/objects.h b/include/objects.h index 8425cfa07..b2e7b3157 100644 --- a/include/objects.h +++ b/include/objects.h @@ -371,6 +371,8 @@ struct host_struct{ int notified_on_down; int notified_on_unreachable; int current_notification_number; + int current_down_notification_number; + int current_unreachable_notification_number; int no_more_notifications; unsigned long current_notification_id; int check_flapping_recovery_notification; @@ -477,7 +479,7 @@ struct service_struct{ char *plugin_output; char *long_plugin_output; char *perf_data; - int state_type; + int state_type; time_t next_check; int should_be_scheduled; time_t last_check; @@ -502,7 +504,10 @@ struct service_struct{ int notified_on_warning; int notified_on_critical; int current_notification_number; - unsigned long current_notification_id; + int current_warning_notification_number; + int current_critical_notification_number; + int current_unknown_notification_number; + unsigned long current_notification_id; double latency; double execution_time; int is_executing; @@ -564,6 +569,12 @@ typedef struct serviceescalation_struct{ char *description; int first_notification; int last_notification; + int first_warning_notification; + int last_warning_notification; + int first_critical_notification; + int last_critical_notification; + int first_unknown_notification; + int last_unknown_notification; double notification_interval; char *escalation_period; int escalate_on_recovery; @@ -614,6 +625,10 @@ typedef struct hostescalation_struct{ char *host_name; int first_notification; int last_notification; + int first_down_notification; + int last_down_notification; + int first_unreachable_notification; + int last_unreachable_notification; double notification_interval; char *escalation_period; int escalate_on_recovery; @@ -700,13 +715,13 @@ command *add_command(char *,char *); /* adds a command definition */ service *add_service(char *,char *,char *,char *,int,int,int,int,double,double,double,double,char *,int,int,int,int,int,int,int,int,char *,int,char *,int,int,double,double,int,int,int,int,int,int,int,int,int,int,char *,int,int,char *,char *,char *,char *,char *,int,int,int); /* adds a service definition */ contactgroupsmember *add_contactgroup_to_service(service *,char *); /* adds a contact group to a service definition */ contactsmember *add_contact_to_service(service *,char *); /* adds a contact to a host definition */ -serviceescalation *add_serviceescalation(char *,char *,int,int,double,char *,int,int,int,int); /* adds a service escalation definition */ +serviceescalation *add_serviceescalation(char *,char *,int,int,int,int,int,int,int,int,double,char *,int,int,int,int); /* adds a service escalation definition */ contactgroupsmember *add_contactgroup_to_serviceescalation(serviceescalation *,char *); /* adds a contact group to a service escalation definition */ contactsmember *add_contact_to_serviceescalation(serviceescalation *,char *); /* adds a contact to a service escalation definition */ customvariablesmember *add_custom_variable_to_service(service *,char *,char *); /* adds a custom variable to a service definition */ servicedependency *add_service_dependency(char *,char *,char *,char *,int,int,int,int,int,int,int,char *); /* adds a service dependency definition */ hostdependency *add_host_dependency(char *,char *,int,int,int,int,int,int,char *); /* adds a host dependency definition */ -hostescalation *add_hostescalation(char *,int,int,double,char *,int,int,int); /* adds a host escalation definition */ +hostescalation *add_hostescalation(char *,int,int,int,int,int,int,double,char *,int,int,int); /* adds a host escalation definition */ contactsmember *add_contact_to_hostescalation(hostescalation *,char *); /* adds a contact to a host escalation definition */ contactgroupsmember *add_contactgroup_to_hostescalation(hostescalation *,char *); /* adds a contact group to a host escalation definition */ diff --git a/include/statusdata.h b/include/statusdata.h index a64cba7d3..ae024254f 100644 --- a/include/statusdata.h +++ b/include/statusdata.h @@ -83,6 +83,8 @@ typedef struct hoststatus_struct{ int problem_has_been_acknowledged; int acknowledgement_type; int current_notification_number; + int current_down_notification_number; + int current_unreachable_notification_number; int accept_passive_host_checks; int event_handler_enabled; int checks_enabled; @@ -133,6 +135,9 @@ typedef struct servicestatus_struct{ int problem_has_been_acknowledged; int acknowledgement_type; int current_notification_number; + int current_warning_notification_number; + int current_critical_notification_number; + int current_unknown_notification_number; int accept_passive_service_checks; int event_handler_enabled; int flap_detection_enabled; diff --git a/xdata/xodtemplate.c b/xdata/xodtemplate.c index ed4480db2..deef61d89 100644 --- a/xdata/xodtemplate.c +++ b/xdata/xodtemplate.c @@ -1027,6 +1027,15 @@ int xodtemplate_begin_object_definition(char *input, int options, int config_fil case XODTEMPLATE_SERVICEESCALATION: xod_begin_def(serviceescalation); + new_serviceescalation->first_notification=-2; + new_serviceescalation->last_notification=-2; + new_serviceescalation->first_warning_notification=-2; + new_serviceescalation->last_warning_notification=-2; + new_serviceescalation->first_critical_notification=-2; + new_serviceescalation->last_critical_notification=-2; + new_serviceescalation->first_unknown_notification=-2; + new_serviceescalation->last_unknown_notification=-2; + new_serviceescalation->notification_interval=-2.0; break; case XODTEMPLATE_CONTACT: @@ -1094,6 +1103,13 @@ int xodtemplate_begin_object_definition(char *input, int options, int config_fil case XODTEMPLATE_HOSTESCALATION: xod_begin_def(hostescalation); + new_hostescalation->first_notification=-2; + new_hostescalation->last_notification=-2; + new_hostescalation->first_down_notification=-2; + new_hostescalation->last_down_notification=-2; + new_hostescalation->first_unreachable_notification=-2; + new_hostescalation->last_unreachable_notification=-2; + new_hostescalation->notification_interval=-2.0; break; case XODTEMPLATE_HOSTEXTINFO: @@ -2017,6 +2033,30 @@ int xodtemplate_add_object_property(char *input, int options){ temp_serviceescalation->last_notification=atoi(value); temp_serviceescalation->have_last_notification=TRUE; } + else if(!strcmp(variable,"first_warning_notification")){ + temp_serviceescalation->first_warning_notification=atoi(value); + temp_serviceescalation->have_first_warning_notification=TRUE; + } + else if(!strcmp(variable,"last_warning_notification")){ + temp_serviceescalation->last_warning_notification=atoi(value); + temp_serviceescalation->have_last_warning_notification=TRUE; + } + else if(!strcmp(variable,"first_critical_notification")){ + temp_serviceescalation->first_critical_notification=atoi(value); + temp_serviceescalation->have_first_critical_notification=TRUE; + } + else if(!strcmp(variable,"last_critical_notification")){ + temp_serviceescalation->last_critical_notification=atoi(value); + temp_serviceescalation->have_last_critical_notification=TRUE; + } + else if(!strcmp(variable,"first_unknown_notification")){ + temp_serviceescalation->first_unknown_notification=atoi(value); + temp_serviceescalation->have_first_unknown_notification=TRUE; + } + else if(!strcmp(variable,"last_unknown_notification")){ + temp_serviceescalation->last_unknown_notification=atoi(value); + temp_serviceescalation->have_last_unknown_notification=TRUE; + } else if(!strcmp(variable,"notification_interval")){ temp_serviceescalation->notification_interval=strtod(value,NULL); temp_serviceescalation->have_notification_interval=TRUE; @@ -3408,6 +3448,22 @@ int xodtemplate_add_object_property(char *input, int options){ temp_hostescalation->last_notification=atoi(value); temp_hostescalation->have_last_notification=TRUE; } + else if(!strcmp(variable,"first_down_notification")){ + temp_hostescalation->first_down_notification=atoi(value); + temp_hostescalation->have_first_down_notification=TRUE; + } + else if(!strcmp(variable,"last_down_notification")){ + temp_hostescalation->last_down_notification=atoi(value); + temp_hostescalation->have_last_down_notification=TRUE; + } + else if(!strcmp(variable,"first_unreachable_notification")){ + temp_hostescalation->first_unreachable_notification=atoi(value); + temp_hostescalation->have_first_unreachable_notification=TRUE; + } + else if(!strcmp(variable,"last_unreachable_notification")){ + temp_hostescalation->last_unreachable_notification=atoi(value); + temp_hostescalation->have_last_unreachable_notification=TRUE; + } else if(!strcmp(variable,"notification_interval")){ temp_hostescalation->notification_interval=strtod(value,NULL); temp_hostescalation->have_notification_interval=TRUE; @@ -5345,8 +5401,16 @@ int xodtemplate_duplicate_hostescalation(xodtemplate_hostescalation *temp_hostes /* duplicate non-string members */ new_hostescalation->first_notification=temp_hostescalation->first_notification; new_hostescalation->last_notification=temp_hostescalation->last_notification; + new_hostescalation->first_down_notification=temp_hostescalation->first_down_notification; + new_hostescalation->last_down_notification=temp_hostescalation->last_down_notification; + new_hostescalation->first_unreachable_notification=temp_hostescalation->first_unreachable_notification; + new_hostescalation->last_unreachable_notification=temp_hostescalation->last_unreachable_notification; new_hostescalation->have_first_notification=temp_hostescalation->have_first_notification; new_hostescalation->have_last_notification=temp_hostescalation->have_last_notification; + new_hostescalation->have_first_down_notification=temp_hostescalation->have_first_down_notification; + new_hostescalation->have_last_down_notification=temp_hostescalation->have_last_down_notification; + new_hostescalation->have_first_unreachable_notification=temp_hostescalation->have_first_unreachable_notification; + new_hostescalation->have_last_unreachable_notification=temp_hostescalation->have_last_unreachable_notification; new_hostescalation->notification_interval=temp_hostescalation->notification_interval; new_hostescalation->have_notification_interval=temp_hostescalation->have_notification_interval; new_hostescalation->escalate_on_down=temp_hostescalation->escalate_on_down; @@ -5481,8 +5545,20 @@ int xodtemplate_duplicate_serviceescalation(xodtemplate_serviceescalation *temp_ /* duplicate non-string members */ new_serviceescalation->first_notification=temp_serviceescalation->first_notification; new_serviceescalation->last_notification=temp_serviceescalation->last_notification; + new_serviceescalation->first_warning_notification=temp_serviceescalation->first_warning_notification; + new_serviceescalation->last_warning_notification=temp_serviceescalation->last_warning_notification; + new_serviceescalation->first_critical_notification=temp_serviceescalation->first_critical_notification; + new_serviceescalation->last_critical_notification=temp_serviceescalation->last_critical_notification; + new_serviceescalation->first_unknown_notification=temp_serviceescalation->first_unknown_notification; + new_serviceescalation->last_unknown_notification=temp_serviceescalation->last_unknown_notification; new_serviceescalation->have_first_notification=temp_serviceescalation->have_first_notification; new_serviceescalation->have_last_notification=temp_serviceescalation->have_last_notification; + new_serviceescalation->have_first_warning_notification=temp_serviceescalation->have_first_warning_notification; + new_serviceescalation->have_last_warning_notification=temp_serviceescalation->have_last_warning_notification; + new_serviceescalation->have_first_critical_notification=temp_serviceescalation->have_first_critical_notification; + new_serviceescalation->have_last_critical_notification=temp_serviceescalation->have_last_critical_notification; + new_serviceescalation->have_first_unknown_notification=temp_serviceescalation->have_first_unknown_notification; + new_serviceescalation->have_last_unknown_notification=temp_serviceescalation->have_last_unknown_notification; new_serviceescalation->notification_interval=temp_serviceescalation->notification_interval; new_serviceescalation->have_notification_interval=temp_serviceescalation->have_notification_interval; new_serviceescalation->escalate_on_warning=temp_serviceescalation->escalate_on_warning; @@ -6672,6 +6748,30 @@ int xodtemplate_resolve_serviceescalation(xodtemplate_serviceescalation *this_se this_serviceescalation->last_notification=template_serviceescalation->last_notification; this_serviceescalation->have_last_notification=TRUE; } + if(this_serviceescalation->have_first_warning_notification==FALSE && template_serviceescalation->have_first_warning_notification==TRUE){ + this_serviceescalation->first_warning_notification=template_serviceescalation->first_warning_notification; + this_serviceescalation->have_first_warning_notification=TRUE; + } + if(this_serviceescalation->have_last_warning_notification==FALSE && template_serviceescalation->have_last_warning_notification==TRUE){ + this_serviceescalation->last_warning_notification=template_serviceescalation->last_warning_notification; + this_serviceescalation->have_last_warning_notification=TRUE; + } + if(this_serviceescalation->have_first_critical_notification==FALSE && template_serviceescalation->have_first_critical_notification==TRUE){ + this_serviceescalation->first_critical_notification=template_serviceescalation->first_critical_notification; + this_serviceescalation->have_first_critical_notification=TRUE; + } + if(this_serviceescalation->have_last_critical_notification==FALSE && template_serviceescalation->have_last_critical_notification==TRUE){ + this_serviceescalation->last_critical_notification=template_serviceescalation->last_critical_notification; + this_serviceescalation->have_last_critical_notification=TRUE; + } + if(this_serviceescalation->have_first_unknown_notification==FALSE && template_serviceescalation->have_first_unknown_notification==TRUE){ + this_serviceescalation->first_unknown_notification=template_serviceescalation->first_unknown_notification; + this_serviceescalation->have_first_unknown_notification=TRUE; + } + if(this_serviceescalation->have_last_unknown_notification==FALSE && template_serviceescalation->have_last_unknown_notification==TRUE){ + this_serviceescalation->last_unknown_notification=template_serviceescalation->last_unknown_notification; + this_serviceescalation->have_last_unknown_notification=TRUE; + } if(this_serviceescalation->have_notification_interval==FALSE && template_serviceescalation->have_notification_interval==TRUE){ this_serviceescalation->notification_interval=template_serviceescalation->notification_interval; this_serviceescalation->have_notification_interval=TRUE; @@ -7448,6 +7548,22 @@ int xodtemplate_resolve_hostescalation(xodtemplate_hostescalation *this_hostesca this_hostescalation->last_notification=template_hostescalation->last_notification; this_hostescalation->have_last_notification=TRUE; } + if(this_hostescalation->have_first_down_notification==FALSE && template_hostescalation->have_first_down_notification==TRUE){ + this_hostescalation->first_down_notification=template_hostescalation->first_down_notification; + this_hostescalation->have_first_down_notification=TRUE; + } + if(this_hostescalation->have_last_down_notification==FALSE && template_hostescalation->have_last_down_notification==TRUE){ + this_hostescalation->last_down_notification=template_hostescalation->last_down_notification; + this_hostescalation->have_last_down_notification=TRUE; + } + if(this_hostescalation->have_first_unreachable_notification==FALSE && template_hostescalation->have_first_unreachable_notification==TRUE){ + this_hostescalation->first_unreachable_notification=template_hostescalation->first_unreachable_notification; + this_hostescalation->have_first_unreachable_notification=TRUE; + } + if(this_hostescalation->have_last_unreachable_notification==FALSE && template_hostescalation->have_last_unreachable_notification==TRUE){ + this_hostescalation->last_unreachable_notification=template_hostescalation->last_unreachable_notification; + this_hostescalation->have_last_unreachable_notification=TRUE; + } if(this_hostescalation->have_notification_interval==FALSE && template_hostescalation->have_notification_interval==TRUE){ this_hostescalation->notification_interval=template_hostescalation->notification_interval; this_hostescalation->have_notification_interval=TRUE; @@ -9026,7 +9142,7 @@ int xodtemplate_register_serviceescalation(xodtemplate_serviceescalation *this_s } /* add the serviceescalation */ - new_serviceescalation=add_serviceescalation(this_serviceescalation->host_name,this_serviceescalation->service_description,this_serviceescalation->first_notification,this_serviceescalation->last_notification,this_serviceescalation->notification_interval,this_serviceescalation->escalation_period,this_serviceescalation->escalate_on_warning,this_serviceescalation->escalate_on_unknown,this_serviceescalation->escalate_on_critical,this_serviceescalation->escalate_on_recovery); + new_serviceescalation=add_serviceescalation(this_serviceescalation->host_name,this_serviceescalation->service_description,this_serviceescalation->first_notification,this_serviceescalation->last_notification,this_serviceescalation->first_warning_notification,this_serviceescalation->last_warning_notification,this_serviceescalation->first_critical_notification,this_serviceescalation->last_critical_notification,this_serviceescalation->first_unknown_notification,this_serviceescalation->last_unknown_notification,this_serviceescalation->notification_interval,this_serviceescalation->escalation_period,this_serviceescalation->escalate_on_warning,this_serviceescalation->escalate_on_unknown,this_serviceescalation->escalate_on_critical,this_serviceescalation->escalate_on_recovery); /* return with an error if we couldn't add the serviceescalation */ if(new_serviceescalation==NULL){ @@ -9358,7 +9474,7 @@ int xodtemplate_register_hostescalation(xodtemplate_hostescalation *this_hostesc } /* add the hostescalation */ - new_hostescalation=add_hostescalation(this_hostescalation->host_name,this_hostescalation->first_notification,this_hostescalation->last_notification,this_hostescalation->notification_interval,this_hostescalation->escalation_period,this_hostescalation->escalate_on_down,this_hostescalation->escalate_on_unreachable,this_hostescalation->escalate_on_recovery); + new_hostescalation=add_hostescalation(this_hostescalation->host_name,this_hostescalation->first_notification,this_hostescalation->last_notification,this_hostescalation->first_down_notification,this_hostescalation->last_down_notification,this_hostescalation->first_unreachable_notification,this_hostescalation->last_unreachable_notification,this_hostescalation->notification_interval,this_hostescalation->escalation_period,this_hostescalation->escalate_on_down,this_hostescalation->escalate_on_unreachable,this_hostescalation->escalate_on_recovery); /* return with an error if we couldn't add the hostescalation */ if(new_hostescalation==NULL){ @@ -10886,6 +11002,12 @@ int xodtemplate_cache_objects(char *cache_file){ fprintf(fp,"\tservice_description\t%s\n",temp_serviceescalation->service_description); fprintf(fp,"\tfirst_notification\t%d\n",temp_serviceescalation->first_notification); fprintf(fp,"\tlast_notification\t%d\n",temp_serviceescalation->last_notification); + fprintf(fp,"\tfirst_warning_notification\t%d\n",temp_serviceescalation->first_warning_notification); + fprintf(fp,"\tlast_warning_notification\t%d\n",temp_serviceescalation->last_warning_notification); + fprintf(fp,"\tfirst_critical_notification\t%d\n",temp_serviceescalation->first_critical_notification); + fprintf(fp,"\tlast_critical_notification\t%d\n",temp_serviceescalation->last_critical_notification); + fprintf(fp,"\tfirst_unknown_notification\t%d\n",temp_serviceescalation->first_unknown_notification); + fprintf(fp,"\tlast_unknown_notification\t%d\n",temp_serviceescalation->last_unknown_notification); fprintf(fp,"\tnotification_interval\t%f\n",temp_serviceescalation->notification_interval); if(temp_serviceescalation->escalation_period) fprintf(fp,"\tescalation_period\t%s\n",temp_serviceescalation->escalation_period); @@ -10969,6 +11091,10 @@ int xodtemplate_cache_objects(char *cache_file){ fprintf(fp,"\thost_name\t%s\n",temp_hostescalation->host_name); fprintf(fp,"\tfirst_notification\t%d\n",temp_hostescalation->first_notification); fprintf(fp,"\tlast_notification\t%d\n",temp_hostescalation->last_notification); + fprintf(fp,"\tfirst_down_notification\t%d\n",temp_hostescalation->first_down_notification); + fprintf(fp,"\tlast_down_notification\t%d\n",temp_hostescalation->last_down_notification); + fprintf(fp,"\tfirst_unreachable_notification\t%d\n",temp_hostescalation->first_unreachable_notification); + fprintf(fp,"\tlast_unreachable_notification\t%d\n",temp_hostescalation->last_unreachable_notification); fprintf(fp,"\tnotification_interval\t%f\n",temp_hostescalation->notification_interval); if(temp_hostescalation->escalation_period) fprintf(fp,"\tescalation_period\t%s\n",temp_hostescalation->escalation_period); diff --git a/xdata/xodtemplate.h b/xdata/xodtemplate.h index df1a230f1..e8e31609c 100644 --- a/xdata/xodtemplate.h +++ b/xdata/xodtemplate.h @@ -595,6 +595,12 @@ typedef struct xodtemplate_serviceescalation_struct{ char *hostgroup_name; int first_notification; int last_notification; + int first_warning_notification; + int last_warning_notification; + int first_critical_notification; + int last_critical_notification; + int first_unknown_notification; + int last_unknown_notification; double notification_interval; char *escalation_period; int escalate_on_warning; @@ -614,6 +620,12 @@ typedef struct xodtemplate_serviceescalation_struct{ int have_first_notification; int have_last_notification; + int have_first_warning_notification; + int have_last_warning_notification; + int have_first_critical_notification; + int have_last_critical_notification; + int have_first_unknown_notification; + int have_last_unknown_notification; int have_notification_interval; int have_escalation_options; @@ -674,6 +686,10 @@ typedef struct xodtemplate_hostescalation_struct{ char *hostgroup_name; int first_notification; int last_notification; + int first_down_notification; + int last_down_notification; + int first_unreachable_notification; + int last_unreachable_notification; double notification_interval; char *escalation_period; int escalate_on_down; @@ -690,6 +706,10 @@ typedef struct xodtemplate_hostescalation_struct{ int have_first_notification; int have_last_notification; + int have_first_down_notification; + int have_last_down_notification; + int have_first_unreachable_notification; + int have_last_unreachable_notification; int have_notification_interval; int have_escalation_options; diff --git a/xdata/xrddefault.c b/xdata/xrddefault.c index 977144302..944c75c61 100644 --- a/xdata/xrddefault.c +++ b/xdata/xrddefault.c @@ -397,6 +397,8 @@ int xrddefault_save_state_information(void){ fprintf(fp,"notified_on_unreachable=%d\n",temp_host->notified_on_unreachable); fprintf(fp,"last_notification=%lu\n",temp_host->last_host_notification); fprintf(fp,"current_notification_number=%d\n",temp_host->current_notification_number); + fprintf(fp,"current_down_notification_number=%d\n",temp_host->current_down_notification_number); + fprintf(fp,"current_unreachable_notification_number=%d\n",temp_host->current_unreachable_notification_number); fprintf(fp,"current_notification_id=%lu\n",temp_host->current_notification_id); fprintf(fp,"notifications_enabled=%d\n",temp_host->notifications_enabled); fprintf(fp,"problem_has_been_acknowledged=%d\n",temp_host->problem_has_been_acknowledged); @@ -469,6 +471,9 @@ int xrddefault_save_state_information(void){ fprintf(fp,"notified_on_warning=%d\n",temp_service->notified_on_warning); fprintf(fp,"notified_on_critical=%d\n",temp_service->notified_on_critical); fprintf(fp,"current_notification_number=%d\n",temp_service->current_notification_number); + fprintf(fp,"current_warning_notification_number=%d\n",temp_service->current_warning_notification_number); + fprintf(fp,"current_critical_notification_number=%d\n",temp_service->current_critical_notification_number); + fprintf(fp,"current_unknown_notification_number=%d\n",temp_service->current_unknown_notification_number); fprintf(fp,"current_notification_id=%lu\n",temp_service->current_notification_id); fprintf(fp,"last_notification=%lu\n",temp_service->last_notification); fprintf(fp,"notifications_enabled=%d\n",temp_service->notifications_enabled); @@ -1295,6 +1300,10 @@ int xrddefault_read_retention_file_information(char *retention_file, int overwri temp_host->last_host_notification=strtoul(val,NULL,10); else if(!strcmp(var,"current_notification_number")) temp_host->current_notification_number=atoi(val); + else if(!strcmp(var,"current_down_notification_number")) + temp_host->current_down_notification_number=atoi(val); + else if(!strcmp(var,"current_unreachable_notification_number")) + temp_host->current_unreachable_notification_number=atoi(val); else if(!strcmp(var,"current_notification_id")) temp_host->current_notification_id=strtoul(val,NULL,10); else if(!strcmp(var,"is_flapping")) @@ -1574,6 +1583,12 @@ int xrddefault_read_retention_file_information(char *retention_file, int overwri temp_service->notified_on_critical=(atoi(val)>0)?TRUE:FALSE; else if(!strcmp(var,"current_notification_number")) temp_service->current_notification_number=atoi(val); + else if(!strcmp(var,"current_warning_notification_number")) + temp_service->current_warning_notification_number=atoi(val); + else if(!strcmp(var,"current_critical_notification_number")) + temp_service->current_critical_notification_number=atoi(val); + else if(!strcmp(var,"current_unknown_notification_number")) + temp_service->current_unknown_notification_number=atoi(val); else if(!strcmp(var,"current_notification_id")) temp_service->current_notification_id=strtoul(val,NULL,10); else if(!strcmp(var,"last_notification")) diff --git a/xdata/xsddefault.c b/xdata/xsddefault.c index 034c3e26f..317a22e7c 100644 --- a/xdata/xsddefault.c +++ b/xdata/xsddefault.c @@ -501,6 +501,8 @@ int xsddefault_save_status_data(void){ fprintf(fp,"\tnext_notification=%lu\n",temp_host->next_host_notification); fprintf(fp,"\tno_more_notifications=%d\n",temp_host->no_more_notifications); fprintf(fp,"\tcurrent_notification_number=%d\n",temp_host->current_notification_number); + fprintf(fp,"\tcurrent_down_notification_number=%d\n",temp_host->current_down_notification_number); + fprintf(fp,"\tcurrent_unreachable_notification_number=%d\n",temp_host->current_unreachable_notification_number); fprintf(fp,"\tcurrent_notification_id=%lu\n",temp_host->current_notification_id); fprintf(fp,"\tnotifications_enabled=%d\n",temp_host->notifications_enabled); fprintf(fp,"\tproblem_has_been_acknowledged=%d\n",temp_host->problem_has_been_acknowledged); @@ -572,6 +574,9 @@ int xsddefault_save_status_data(void){ fprintf(fp,"\tnext_check=%lu\n",temp_service->next_check); fprintf(fp,"\tcheck_options=%d\n",temp_service->check_options); fprintf(fp,"\tcurrent_notification_number=%d\n",temp_service->current_notification_number); + fprintf(fp,"\tcurrent_warning_notification_number=%d\n",temp_service->current_warning_notification_number); + fprintf(fp,"\tcurrent_critical_notification_number=%d\n",temp_service->current_critical_notification_number); + fprintf(fp,"\tcurrent_unknown_notification_number=%d\n",temp_service->current_unknown_notification_number); fprintf(fp,"\tcurrent_notification_id=%lu\n",temp_service->current_notification_id); fprintf(fp,"\tlast_notification=%lu\n",temp_service->last_notification); fprintf(fp,"\tnext_notification=%lu\n",temp_service->next_notification); @@ -1087,6 +1092,10 @@ int xsddefault_read_status_data(char *config_file,int options){ temp_hoststatus->no_more_notifications=(atoi(val)>0)?TRUE:FALSE; else if(!strcmp(var,"current_notification_number")) temp_hoststatus->current_notification_number=atoi(val); + else if(!strcmp(var,"current_down_notification_number")) + temp_hoststatus->current_down_notification_number=atoi(val); + else if(!strcmp(var,"current_unreachable_notification_number")) + temp_hoststatus->current_unreachable_notification_number=atoi(val); else if(!strcmp(var,"notifications_enabled")) temp_hoststatus->notifications_enabled=(atoi(val)>0)?TRUE:FALSE; else if(!strcmp(var,"problem_has_been_acknowledged")) @@ -1183,6 +1192,12 @@ int xsddefault_read_status_data(char *config_file,int options){ temp_servicestatus->check_options=atoi(val); else if(!strcmp(var,"current_notification_number")) temp_servicestatus->current_notification_number=atoi(val); + else if(!strcmp(var,"current_warning_notification_number")) + temp_servicestatus->current_warning_notification_number=atoi(val); + else if(!strcmp(var,"current_critical_notification_number")) + temp_servicestatus->current_critical_notification_number=atoi(val); + else if(!strcmp(var,"current_unknown_notification_number")) + temp_servicestatus->current_unknown_notification_number=atoi(val); else if(!strcmp(var,"last_notification")) temp_servicestatus->last_notification=strtoul(val,NULL,10); else if(!strcmp(var,"next_notification"))