"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "cgi/avail.c" between
nagios-4.4.3.tar.gz and nagios-4.4.4.tar.gz

About: Nagios (Core) is an host/service/network monitoring system to identify and resolve IT infrastructure problems.

avail.c  (nagios-4.4.3):avail.c  (nagios-4.4.4)
skipping to change at line 1797 skipping to change at line 1797
if (have_some_real_data == FALSE) if (have_some_real_data == FALSE)
return; return;
last_as = NULL; last_as = NULL;
subject->earliest_time = t2; subject->earliest_time = t2;
subject->latest_time = t1; subject->latest_time = t1;
#ifdef DEBUG #ifdef DEBUG
printf("--- BEGINNING/MIDDLE SECTION ---<BR>\n"); printf("--- BEGINNING/MIDDLE SECTION ---<BR>\n");
#endif #endif
#ifdef DEBUG2
printf("<pre>");
#endif
/**********************************/ /**********************************/
/* BEGINNING/MIDDLE SECTION */ /* BEGINNING/MIDDLE SECTION */
/**********************************/ /**********************************/
for (temp_as = subject->as_list; temp_as != NULL; temp_as = temp_as->next ) { for (temp_as = subject->as_list; temp_as != NULL; temp_as = temp_as->next ) {
/* keep this as last known state if this is the first entry or if it occurs before the starting point of the graph */ /* keep this as last known state if this is the first entry or if it occurs before the starting point of the graph */
if ((temp_as->time_stamp <= t1 || temp_as == subject->as_list) && (temp_as->entry_type != AS_NO_DATA && temp_as->entry_type != AS_PROGRAM_END && temp_as->entry_type != AS_PROGRAM_START)) { if ((temp_as->time_stamp <= t1 || temp_as == subject->as_list) && (temp_as->entry_type != AS_NO_DATA && temp_as->entry_type != AS_PROGRAM_END && temp_as->entry_type != AS_PROGRAM_START)) {
subject->last_known_state = temp_as->entry_type; subject->last_known_state = temp_as->entry_type;
skipping to change at line 1902 skipping to change at line 1905
if (subject->type == HOST_SUBJECT) if (subject->type == HOST_SUBJECT)
current_state = AS_HOST_UP; current_state = AS_HOST_UP;
else else
current_state = AS_SVC_OK; current_state = AS_SVC_OK;
/* compute availability times for last state */ /* compute availability times for last state */
compute_subject_availability_times(last_as->entry_type, c urrent_state, last_as->time_stamp, a, b, subject, last_as); compute_subject_availability_times(last_as->entry_type, c urrent_state, last_as->time_stamp, a, b, subject, last_as);
} }
} }
#ifdef DEBUG2
printf("</pre>");
#endif
return; return;
} }
/* computes availability times */ /* computes availability times */
void compute_subject_availability_times(int first_state, int last_state, time_t real_start_time, time_t start_time, time_t end_time, avail_subject *subject, arc hived_state *as) void compute_subject_availability_times(int first_state, int last_state, time_t real_start_time, time_t start_time, time_t end_time, avail_subject *subject, arc hived_state *as)
{ {
int start_state = 0; int start_state = 0;
unsigned long state_duration = 0L; unsigned long state_duration = 0L;
struct tm *t = NULL; struct tm *t = NULL;
time_t midnight_today = 0L; time_t midnight_today = 0L;
int weekday = 0; int weekday = 0;
timerange *temp_timerange = NULL; timerange *temp_timerange = NULL;
unsigned long temp_duration = 0L; unsigned long temp_duration = 0L;
unsigned long temp_end = 0L; unsigned long temp_end = 0L;
unsigned long temp_start = 0L; unsigned long temp_start = 0L;
unsigned long start = 0L; unsigned long start = 0L;
unsigned long end = 0L; unsigned long end = 0L;
#ifdef DEBUG #ifdef DEBUG2
if (subject->type == HOST_SUBJECT) { if (subject->type == HOST_SUBJECT) {
printf("HOST '%s'...\n", subject->host_name); printf("\nHOST '%s'...\n", subject->host_name);
} }
else { else {
printf("SERVICE '%s' ON HOST '%s'...\n", subject->service_descrip tion, subject->host_name); printf("\nSERVICE '%s' ON HOST '%s'...\n", subject->service_descr iption, subject->host_name);
} }
printf("COMPUTING %d->%d FROM %lu to %lu (%lu seconds) FOR %s<br>\n", fir st_state, last_state, start_time, end_time, (end_time - start_time), (subject->t ype == HOST_SUBJECT) ? "HOST" : "SERVICE"); printf("COMPUTING %d->%d FROM %lu to %lu (%lu seconds) FOR %s\n", first_s tate, last_state, start_time, end_time, (end_time - start_time), (subject->type == HOST_SUBJECT) ? "HOST" : "SERVICE");
#endif #endif
/* clip times if necessary */ /* clip times if necessary */
if (start_time < t1) { if (start_time < t1) {
start_time = t1; start_time = t1;
} }
if (end_time > t2) { if (end_time > t2) {
end_time = t2; end_time = t2;
} }
skipping to change at line 2050 skipping to change at line 2057
else { else {
if (subject->type == HOST_SUBJECT) { if (subject->type == HOST_SUBJECT) {
start_state = AS_HOST_UP; start_state = AS_HOST_UP;
} }
else { else {
start_state = AS_SVC_OK; start_state = AS_SVC_OK;
} }
} }
} }
else { else {
as->processed_state = AS_NO_DATA;
return; return;
} }
} }
else { else {
start_state = first_state; start_state = first_state;
subject->last_known_state = first_state; subject->last_known_state = first_state;
} }
/* save "processed state" info */ /* save "processed state" info */
as->processed_state = start_state; as->processed_state = start_state;
#ifdef DEBUG2
printf("PROCESSED_STATE: %d\n", start_state);
#endif
#ifdef DEBUG #ifdef DEBUG
printf("PASSED TIME CHECKS, CLIPPED VALUES: START=%lu, END=%lu\n", start_ time, end_time); printf("PASSED TIME CHECKS, CLIPPED VALUES: START=%lu, END=%lu\n", start_ time, end_time);
#endif #endif
/* add time in this state to running totals */ /* add time in this state to running totals */
switch (start_state) { switch (start_state) {
case AS_HOST_UP: case AS_HOST_UP:
subject->time_up += state_duration; subject->time_up += state_duration;
break; break;
skipping to change at line 2112 skipping to change at line 2124
void compute_subject_downtime(avail_subject *subject, time_t current_time) void compute_subject_downtime(avail_subject *subject, time_t current_time)
{ {
archived_state *temp_sd = NULL; archived_state *temp_sd = NULL;
time_t start_time = 0L; time_t start_time = 0L;
time_t end_time = 0L; time_t end_time = 0L;
int host_downtime_state = 0; int host_downtime_state = 0;
int service_downtime_state = 0; int service_downtime_state = 0;
int process_chunk = FALSE; int process_chunk = FALSE;
#ifdef DEBUG2 #ifdef DEBUG2
printf("<pre>");
printf("COMPUTE_SUBJECT_DOWNTIME\n"); printf("COMPUTE_SUBJECT_DOWNTIME\n");
#endif #endif
/* if left hand of graph is after current time, we can't do anything at a ll.... */ /* if left hand of graph is after current time, we can't do anything at a ll.... */
if (t1 > current_time) { if (t1 > current_time) {
return; return;
} }
/* no scheduled downtime data for subject... */ /* no scheduled downtime data for subject... */
if (subject->sd_list == NULL) { if (subject->sd_list == NULL) {
skipping to change at line 2205 skipping to change at line 2218
if (start_time < t1) { if (start_time < t1) {
start_time = t1; start_time = t1;
} }
if (end_time > t2) { if (end_time > t2) {
end_time = t2; end_time = t2;
} }
compute_subject_downtime_times(start_time, end_time, subj ect, temp_sd); compute_subject_downtime_times(start_time, end_time, subj ect, temp_sd);
} }
} }
#ifdef DEBUG2
printf("</pre>");
#endif
} }
/* computes downtime times */ /* computes downtime times */
void compute_subject_downtime_times(time_t start_time, time_t end_time, avail_su bject *subject, archived_state *sd) void compute_subject_downtime_times(time_t start_time, time_t end_time, avail_su bject *subject, archived_state *sd)
{ {
archived_state *temp_as = NULL; archived_state *temp_as = NULL;
time_t part_subject_state = 0L; time_t part_subject_state = 0L;
int saved_status = 0; int saved_status = 0;
time_t saved_stamp = 0; time_t saved_stamp = 0;
int count = 0; int count = 0;
archived_state *temp_before = NULL; archived_state *temp_before = NULL;
archived_state *last = NULL; archived_state *last = NULL;
#ifdef DEBUG2 #ifdef DEBUG2
printf("<P><b>ENTERING COMPUTE_SUBJECT_DOWNTIME_TIMES: start=%lu, end=%lu , t1=%lu, t2=%lu </b></P>", start_time, end_time, t1, t2); printf("\n<b>ENTERING COMPUTE_SUBJECT_DOWNTIME_TIMES: start=%lu, end=%lu, t1=%lu, t2=%lu </b>\n\n", start_time, end_time, t1, t2);
#endif #endif
/* times are weird, so bail out... */ /* times are weird, so bail out... */
if (start_time > end_time) { if (start_time > end_time) {
return; return;
} }
if (start_time < t1 || end_time > t2) { if (start_time < t1 || end_time > t2) {
return; return;
} }
/* find starting point in archived state list */ /* find starting point in archived state list */
if (sd == NULL) { if (sd == NULL) {
#ifdef DEBUG2 #ifdef DEBUG2
printf("<P>TEMP_AS=SUBJECT->AS_LIST </P>"); printf("TEMP_AS=SUBJECT->AS_LIST\n");
#endif #endif
temp_as = subject->as_list; temp_as = subject->as_list;
} }
else if (sd->misc_ptr == NULL) { else if (sd->misc_ptr == NULL) {
#ifdef DEBUG2 #ifdef DEBUG2
printf("<P>TEMP_AS=SUBJECT->AS_LIST</P>"); printf("TEMP_AS=SUBJECT->AS_LIST\n");
#endif #endif
temp_as = subject->as_list; temp_as = subject->as_list;
} }
else if (sd->misc_ptr->next == NULL) { else if (sd->misc_ptr->next == NULL) {
#ifdef DEBUG2 #ifdef DEBUG2
printf("<P>TEMP_AS=SD->MISC_PTR</P>"); printf("TEMP_AS=SD->MISC_PTR\n");
#endif #endif
temp_as = sd->misc_ptr; temp_as = sd->misc_ptr;
} }
else { else {
#ifdef DEBUG2 #ifdef DEBUG2
printf("<P>TEMP_AS=SD->MISC_PTR->NEXT</P>"); printf("TEMP_AS=SD->MISC_PTR->NEXT\n");
#endif #endif
temp_as = sd->misc_ptr->next; temp_as = sd->misc_ptr->next;
} }
/* initialize values */ /* initialize values */
if (temp_as == NULL) { if (temp_as == NULL) {
part_subject_state = AS_NO_DATA; part_subject_state = AS_NO_DATA;
} }
else if (temp_as->processed_state == AS_PROGRAM_START || temp_as->process ed_state == AS_PROGRAM_END || temp_as->processed_state == AS_NO_DATA) { else if (temp_as->processed_state == AS_PROGRAM_START || temp_as->process ed_state == AS_PROGRAM_END || temp_as->processed_state == AS_NO_DATA) {
#ifdef DEBUG2 #ifdef DEBUG2
printf("<P>ENTRY TYPE #1: %d</P>", temp_as->entry_type); printf("ENTRY TYPE #1: %d\n", temp_as->entry_type);
#endif #endif
part_subject_state = AS_NO_DATA; part_subject_state = AS_NO_DATA;
} }
else { else {
#ifdef DEBUG2 #ifdef DEBUG2
printf("<P>ENTRY TYPE #2: %d</P>", temp_as->entry_type); printf("ENTRY TYPE #2: %d\n", temp_as->entry_type);
printf("STATE: %d\n", temp_as->processed_state);
#endif #endif
part_subject_state = temp_as->processed_state; part_subject_state = temp_as->processed_state;
} }
#ifdef DEBUG2 #ifdef DEBUG2
printf("<P>TEMP_AS=%s</P>", (temp_as == NULL) ? "NULL" : "Not NULL"); printf("TEMP_AS=%s\n", (temp_as == NULL) ? "NULL" : "Not NULL");
printf("<P>SD=%s</P>", (sd == NULL) ? "NULL" : "Not NULL"); printf("SD=%s\n\n", (sd == NULL) ? "NULL" : "Not NULL");
#endif #endif
/* temp_as now points to first event to possibly "break" this chunk */ /* temp_as now points to first event to possibly "break" this chunk */
for (; temp_as != NULL; temp_as = temp_as->next) { for (; temp_as != NULL; temp_as = temp_as->next) {
count++; count++;
last = temp_as; last = temp_as;
if (temp_before == NULL) { if (temp_before == NULL) {
if (last->time_stamp > start_time) { if (last->time_stamp > start_time) {
skipping to change at line 2308 skipping to change at line 2326
if (saved_stamp < start_time) { if (saved_stamp < start_time) {
saved_stamp = start_time; saved_stamp = start_time;
} }
continue; continue;
} }
/* if status changed, we have to calculate */ /* if status changed, we have to calculate */
if (saved_status != temp_as->entry_type) { if (saved_status != temp_as->entry_type) {
/* accommodate status for program start/end */
if (saved_status == AS_PROGRAM_START || saved_status == A
S_PROGRAM_END) {
saved_status = temp_as->processed_state;
}
/* is outside schedule time, use end schdule downtime */ /* is outside schedule time, use end schdule downtime */
if (temp_as->time_stamp > end_time) { if (temp_as->time_stamp > end_time) {
if (saved_stamp < start_time) { if (saved_stamp < start_time) {
compute_subject_downtime_part_times(start _time, end_time, saved_status, subject); compute_subject_downtime_part_times(start _time, end_time, saved_status, subject);
} }
else { else {
compute_subject_downtime_part_times(saved _stamp, end_time, saved_status, subject); compute_subject_downtime_part_times(saved _stamp, end_time, saved_status, subject);
} }
} }
else { else {
skipping to change at line 2341 skipping to change at line 2364
} }
} }
} }
/* just one entry inside the scheduled downtime */ /* just one entry inside the scheduled downtime */
if (count == 0) { if (count == 0) {
compute_subject_downtime_part_times(start_time, end_time, part_su bject_state, subject); compute_subject_downtime_part_times(start_time, end_time, part_su bject_state, subject);
} }
else { else {
/* is outside scheduled time, use end schdule downtime */ /* is outside scheduled time, or at the end of the log, so fake t
if (last->time_stamp > end_time) { he end of scheduled downtime */
#ifdef DEBUG2
printf("<b>LAST ENTRY TYPE: %d</b>\n", last->entry_type);
#endif
if (last->entry_type == AS_PROGRAM_START || last->entry_type == A
S_PROGRAM_END) {
/* if we are NOT assuming initial states, then we do not
want to add this data into the downtime */
if (last->entry_type == AS_PROGRAM_START && assume_initia
l_states == FALSE) {
return;
}
compute_subject_downtime_part_times(saved_stamp, end_time
, part_subject_state, subject);
} else {
compute_subject_downtime_part_times(saved_stamp, end_time , saved_status, subject); compute_subject_downtime_part_times(saved_stamp, end_time , saved_status, subject);
} }
else {
compute_subject_downtime_part_times(saved_stamp, last->ti
me_stamp, saved_status, subject);
}
} }
} }
/* computes downtime times */ /* computes downtime times */
void compute_subject_downtime_part_times(time_t start_time, time_t end_time, int subject_state, avail_subject *subject) void compute_subject_downtime_part_times(time_t start_time, time_t end_time, int subject_state, avail_subject *subject)
{ {
unsigned long state_duration = 0L; unsigned long state_duration = 0L;
#ifdef DEBUG2 #ifdef DEBUG2
printf("ENTERING COMPUTE_SUBJECT_DOWNTIME_PART_TIMES\n"); printf("ENTERING COMPUTE_SUBJECT_DOWNTIME_PART_TIMES\n");
skipping to change at line 3438 skipping to change at line 3467
} }
entry_type = "?"; entry_type = "?";
ebgclass = "INDETERMINATE"; ebgclass = "INDETERMINATE";
} }
get_time_string(&(temp_as->time_stamp), start_date_time, sizeof(s tart_date_time) - 1, SHORT_DATE_TIME); get_time_string(&(temp_as->time_stamp), start_date_time, sizeof(s tart_date_time) - 1, SHORT_DATE_TIME);
if (temp_as->next == NULL) { if (temp_as->next == NULL) {
get_time_string(&t2, end_date_time, sizeof(end_date_time) - 1, SHORT_DATE_TIME); get_time_string(&t2, end_date_time, sizeof(end_date_time) - 1, SHORT_DATE_TIME);
get_time_breakdown((time_t)(t2 - temp_as->time_stamp), &d ays, &hours, &minutes, &seconds); get_time_breakdown((time_t)(t2 - temp_as->time_stamp), &d ays, &hours, &minutes, &seconds);
snprintf(duration, sizeof(duration) - 1, "%dd %dh %dm %ds
+", days, hours, minutes, seconds); /* show blank event duration if the end time is past the
start time */
if ((t2 - temp_as->time_stamp) > end_date_time) {
snprintf(duration, sizeof(duration), "");
} else {
snprintf(duration, sizeof(duration) - 1, "%dd %dh
%dm %ds+", days, hours, minutes, seconds);
}
} }
else { else {
get_time_string(&(temp_as->next->time_stamp), end_date_ti me, sizeof(end_date_time) - 1, SHORT_DATE_TIME); get_time_string(&(temp_as->next->time_stamp), end_date_ti me, sizeof(end_date_time) - 1, SHORT_DATE_TIME);
get_time_breakdown((time_t)(temp_as->next->time_stamp - t emp_as->time_stamp), &days, &hours, &minutes, &seconds); get_time_breakdown((time_t)(temp_as->next->time_stamp - t emp_as->time_stamp), &days, &hours, &minutes, &seconds);
snprintf(duration, sizeof(duration) - 1, "%dd %dh %dm %ds ", days, hours, minutes, seconds); snprintf(duration, sizeof(duration) - 1, "%dd %dh %dm %ds ", days, hours, minutes, seconds);
} }
if (odd) { if (odd) {
bgclass = "Odd"; bgclass = "Odd";
odd = 0; odd = 0;
skipping to change at line 4259 skipping to change at line 4294
printf("<TH CLASS='data'>Type / Reason</TH>"); printf("<TH CLASS='data'>Type / Reason</TH>");
printf("<TH CLASS='data'>Time</TH>"); printf("<TH CLASS='data'>Time</TH>");
printf("<TH CLASS='data'>%% Total Time</TH>"); printf("<TH CLASS='data'>%% Total Time</TH>");
printf("<TH CLASS='data'>%% Known Time</TH></TR>\n"); printf("<TH CLASS='data'>%% Known Time</TH></TR>\n");
/* up times */ /* up times */
printf("<tr CLASS='dataEven'>"); printf("<tr CLASS='dataEven'>");
printf("<td CLASS='hostUP' rowspan=3>UP</td>"); printf("<td CLASS='hostUP' rowspan=3>UP</td>");
printf("<td CLASS='dataEven'>Unscheduled</td>"); printf("<td CLASS='dataEven'>Unscheduled</td>");
printf("<td CLASS='dataEven'>%s</td>", time_up_unschedule d_string); printf("<td CLASS='dataEven'>%s</td>", time_up_unschedule d_string);
printf("<td CLASS='dataEven'>%2.3f%%</td>", percent_time_ printf("<td CLASS='dataEven'>%2.3f%%</td>", percent_time_
up); up_unscheduled);
printf("<td class='dataEven'>%2.3f%%</td></tr>\n", percen printf("<td class='dataEven'>%2.3f%%</td></tr>\n", percen
t_time_up_known); t_time_up_unscheduled_known);
printf("<tr CLASS='dataEven'>"); printf("<tr CLASS='dataEven'>");
printf("<td CLASS='dataEven'>Scheduled</td>"); printf("<td CLASS='dataEven'>Scheduled</td>");
printf("<td CLASS='dataEven'>%s</td>", time_up_scheduled_ string); printf("<td CLASS='dataEven'>%s</td>", time_up_scheduled_ string);
printf("<td CLASS='dataEven'>%2.3f%%</td>", percent_time_ up_scheduled); printf("<td CLASS='dataEven'>%2.3f%%</td>", percent_time_ up_scheduled);
printf("<td class='dataEven'>%2.3f%%</td></tr>\n", percen t_time_up_scheduled_known); printf("<td class='dataEven'>%2.3f%%</td></tr>\n", percen t_time_up_scheduled_known);
printf("<tr CLASS='hostUP'>"); printf("<tr CLASS='hostUP'>");
printf("<td CLASS='hostUP'>Total</td>"); printf("<td CLASS='hostUP'>Total</td>");
printf("<td CLASS='hostUP'>%s</td>", time_up_string); printf("<td CLASS='hostUP'>%s</td>", time_up_string);
printf("<td CLASS='hostUP'>%2.3f%%</td>", percent_time_up ); printf("<td CLASS='hostUP'>%2.3f%%</td>", percent_time_up );
printf("<td class='hostUP'>%2.3f%%</td></tr>\n", percent_ time_up_known); printf("<td class='hostUP'>%2.3f%%</td></tr>\n", percent_ time_up_known);
 End of changes. 23 change blocks. 
25 lines changed or deleted 66 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)