[Nagios-devel] Avail.cgi - Bug in Scheduled Downtimes

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

[Nagios-devel] Avail.cgi - Bug in Scheduled Downtimes

Post by Guest »

This is a multi-part message in MIME format.
--------------020801020706000104040802
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Folks:

After some research in this list archives, we have found some reports
about bugs in periods not computed into scheduled downtimes, with no
answer. And after some work, we corrected the funcion (attached in this
e-mails; just change it in avail.c and recompile), with good results. It
works perfectly in 2.0b4 version and seems to work into 1.3 also. Any
feedback is appreciated.

Credits to Alesssandro Ren, from OpServices, Brasil.

--
Sandro Vaz
[email protected]

****************************
In God we trust.
The rest, we monitor.
****************************


--------------020801020706000104040802
Content-Type: text/plain;
name="compute_subject_downtime_times.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="compute_subject_downtime_times.txt"

void compute_subject_downtime_times(time_t start_time, time_t end_time, avail_subject *subject, archived_state *sd) {
archived_state *temp_as;
time_t part_start_time;
time_t part_subject_state;

int save_status=0;
int saved_status=0;
int saved_stamp=0;
int calc_temp=0;
int count=0;
archived_state *temp_before;
archived_state *last;

#ifdef DEBUG2
printf("ENTERING COMPUTE_SUBJECT_DOWNTIME_TIMES: start=%lu, end=%lu, t1=%lu, t2=%lu ",start_time,end_time,t1,t2);
/* OPSERVICES */
#endif
//printf("ENTERING COMPUTE_SUBJECT_DOWNTIME_TIMES: start=%lu, end=%lu, t1=%lu, t2=%lu ",start_time,end_time,t1,t2);

/* times are weird, so bail out... */
if(start_time>end_time)
return;
if(start_timet2)
return;

/* find starting point in archived state list */
if(sd==NULL) {
#ifdef DEBUG2
printf("TEMP_AS=SUBJECT->AS_LIST ");
#endif
temp_as=subject->as_list;
}
else if(sd->misc_ptr==NULL) {
#ifdef DEBUG2
printf("TEMP_AS=SUBJECT->AS_LIST");
#endif
temp_as=subject->as_list;
}
else if(sd->misc_ptr->next==NULL) {
#ifdef DEBUG2
printf("TEMP_AS=SD->MISC_PTR");
#endif
temp_as=sd->misc_ptr;
}
else {
#ifdef DEBUG2
printf("TEMP_AS=SD->MISC_PTR->NEXT");
#endif
temp_as=sd->misc_ptr->next;
}

/* initialize values */
part_start_time=start_time;
if(temp_as==NULL)
part_subject_state=AS_NO_DATA;
else if(temp_as->processed_state==AS_PROGRAM_START || temp_as->processed_state==AS_PROGRAM_END || temp_as->processed_state==AS_NO_DATA){
#ifdef DEBUG2
printf("ENTRY TYPE #1: %d",temp_as->entry_type);
#endif
part_subject_state=AS_NO_DATA;
}
else{
#ifdef DEBUG2
printf("ENTRY TYPE #2: %d",temp_as->entry_type);
#endif
part_subject_state=temp_as->processed_state;
}

#ifdef DEBUG2
printf("TEMP_AS=%s",(temp_as==NULL)?"NULL":"Not NULL");
printf("SD=%s",(sd==NULL)?"NULL":"Not NULL");
#endif

temp_before=NULL;
saved_status=0;
saved_stamp=0;
count=0;
//printf(" 0 ",count, start_time,end_time,part_subject_state);
/* temp_as now points to first event to possibly "break" this chunk */
//time_t start_time, time_t end_time
for(;temp_as!=NULL;temp_as=temp_as->next) {
count++;
//if ( (temp_as->entry_type==AS_PROGRAM_END) || (temp_as->entry_type==AS_PROGRAM_START) ) {
// last=temp_as;
// continue;
//}
last=temp_as;
if (temp_before==NULL) {
if (last->time_stamp>start_time) {
if (last->time_stamp>end_time) {
//printf(" 1 ",count, start_time,last->time_stamp,part_subject_state);
compute_subject_downtime_part_times(start_time,end_time,part_subject_state,subject);
}
else {
//printf(" 1.1 ",count, start_time,last->time_stamp,part_subject_state);
compute_subject_downtime_part_times(start_time,last->time_stamp,part_subject_state,subject);
}
}
temp_before=temp_as;
saved_status=temp_as->entry_type;
saved_stamp=temp_as->time_stamp;
/* Check if first time is before schedule downtime */
if (saved_stampentry_type) {
if(temp_as->time_stamp

...[email truncated]...


This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
Locked