/* calculates network outage effect of a particular host being down or unreachable */ void calculate_outage_effect_of_host(host *hst, int *affected_hosts, int *affected_services) { int total_child_hosts_affected = 0; int total_child_services_affected = 0; int temp_child_hosts_affected = 0; int temp_child_services_affected = 0; host *temp_host; /* find all child hosts of this host */ for (temp_host = host_list; temp_host != NULL; temp_host = temp_host->next) { /* skip this host if it is not a child */ if (is_host_immediate_child_of_host(hst, temp_host) == FALSE) continue; /* calculate the outage effect of the child */ calculate_outage_effect_of_host(temp_host, &temp_child_hosts_affected, &temp_child_services_affected); /* keep a running total of outage effects */ total_child_hosts_affected += temp_child_hosts_affected; total_child_services_affected += temp_child_services_affected; add_affected_host(temp_host->name); } *affected_hosts = total_child_hosts_affected + 1; *affected_services = total_child_services_affected + number_of_host_services(hst); return; }
/* calculates network outage effect of all hosts that are causing blockages */ void calculate_outage_effects(void) { hostoutage *temp_hostoutage; /* check all hosts causing problems */ for(temp_hostoutage = hostoutage_list; temp_hostoutage != NULL; temp_hostoutage = temp_hostoutage->next) { /* calculate the outage effect of this particular hosts */ calculate_outage_effect_of_host(temp_hostoutage->hst, &temp_hostoutage->affected_child_hosts, &temp_hostoutage->affected_child_services); temp_hostoutage->severity = (temp_hostoutage->affected_child_hosts + (temp_hostoutage->affected_child_services / service_severity_divisor)); } return; }