*affected_services=total_child_services_affected+number_of_host_services(hst);
return;
}
/* tests whether or not a host is "blocked" by upstream parents (host is already assumed to be down or unreachable) */
int is_route_to_host_blocked(host *hst){
hostsmember *temp_hostsmember;
hoststatus *temp_hoststatus;
/* if the host has no parents, it is not being blocked by anyone */
if(hst->parent_hosts==NULL)
return FALSE;
/* check all parent hosts */
for(temp_hostsmember=hst->parent_hosts;temp_hostsmember!=NULL;temp_hostsmember=temp_hostsmember->next){
/* find the parent host's status */
temp_hoststatus=find_hoststatus(temp_hostsmember->host_name);
if(temp_hoststatus==NULL)
continue;
/* at least one parent it up (or pending), so this host is not blocked */
if(temp_hoststatus->status==HOST_UP || temp_hoststatus->status==HOST_PENDING)
return FALSE;
}
return TRUE;
}
/* calculates the number of services associated a particular host */
int number_of_host_services(host *hst){
int total_services=0;
service *temp_service;
/* check all services */
for(temp_service=service_list;temp_service!=NULL;temp_service=temp_service->next){
if(!strcmp(temp_service->host_name,hst->name))
total_services++;
}
return total_services;
}
/* sort the host outages by severity */
void sort_hostoutages(void){
hostoutagesort *last_hostoutagesort;
hostoutagesort *new_hostoutagesort;
hostoutagesort *temp_hostoutagesort;
hostoutage *temp_hostoutage;
if(hostoutage_list==NULL)
return;
/* sort all host outage entries */
for(temp_hostoutage=hostoutage_list;temp_hostoutage!=NULL;temp_hostoutage=temp_hostoutage->next){
/* allocate memory for a new sort structure */
new_hostoutagesort=(hostoutagesort *)malloc(sizeof(hostoutagesort));
if(new_hostoutagesort==NULL)
return;
new_hostoutagesort->outage=temp_hostoutage;
last_hostoutagesort=hostoutagesort_list;
for(temp_hostoutagesort=hostoutagesort_list;temp_hostoutagesort!=NULL;temp_hostoutagesort=temp_hostoutagesort->next){
if(new_hostoutagesort->outage->severity >= temp_hostoutagesort->outage->severity){
new_hostoutagesort->next=temp_hostoutagesort;
if(temp_hostoutagesort==hostoutagesort_list)
hostoutagesort_list=new_hostoutagesort;
else
last_hostoutagesort->next=new_hostoutagesort;
break;
}
else
last_hostoutagesort=temp_hostoutagesort;
}
if(hostoutagesort_list==NULL){
new_hostoutagesort->next=NULL;
hostoutagesort_list=new_hostoutagesort;
}
else if(temp_hostoutagesort==NULL){
new_hostoutagesort->next=NULL;
last_hostoutagesort->next=new_hostoutagesort;
}
}
return;
}
=7=
THE END |