[Nagios-devel] Bug in up/down-times in avail.cgi.

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] Bug in up/down-times in avail.cgi.

Post by Guest »

--1yeeQ81UyVL57Vl7
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

This is concerning avail.cgi. I use Nagios 1.0b5.

The problem; Log-lines looking like:

[1029483368] Caught SIGTERM, shutting down...
[1029483368] Nagios 1.0b5 starting... (PID=5086)
[1029483368] Finished daemonizing... (New PID=5087)
[1029483378] HOST ALERT: foo;UP;HARD;1;(Host assumed to be up)
[1029483378] SERVICE ALERT: foo;NTP;OK;HARD;1;OK: Time difference 0.000193 seconds
[1029483378] HOST ALERT: bar;UP;HARD;1;(Host assumed to be up)
[1029483378] SERVICE ALERT: bar;SSH;OK;HARD;1;SSH ok - protocol version 1.99- - server version
[...etc...]
[1029484924] PROGRAM_RESTART event encountered, restarting...
[1029484924] Nagios 1.0b5 starting... (PID=5087)

...would result in avail.cgi-summaries like:

2002-08-16 09:36:08 2002-08-16 09:36:08 0d 0h 0m 0s PROGRAM (RE)START Program start
2002-08-16 09:36:08 2002-08-16 10:02:04 0d 0h 25m 56s PROGRAM END Normal program termination
2002-08-16 10:02:04 2002-08-16 10:02:04 0d 0h 0m 0s PROGRAM (RE)START Program start

This leads to strange holes in the availability information (with
Undetermined - "Nagios not running"), even though it actually was.

This only happens when Nagios start messages are logged with the same
timestamp as the termination message.

With DEBUG enabled, avail.cgi also says:

HOST 'shutdown.linpro.no'... COMPUTING 2->2 FROM 1029419881 to 1029483368 (63487 seconds) FOR HOST
PASSED TIME CHECKS, CLIPPED VALUES: START=1029419881, END=1029483368

HOST 'shutdown.linpro.no'... COMPUTING 2->1 FROM 1029483368 to 1029483368 (0 seconds) FOR HOST
PASSED TIME CHECKS, CLIPPED VALUES: START=1029483368, END=1029483368

HOST 'shutdown.linpro.no'... COMPUTING 1->2 FROM 1029483368 to 1029484924 (1556 seconds) FOR HOST

HOST 'shutdown.linpro.no'... COMPUTING 2->2 FROM 1029484924 to 1029484924 (0 seconds) FOR HOST
PASSED TIME CHECKS, CLIPPED VALUES: START=1029484924, END=1029484924

(Linebreaks added.)

After the pach, the avail.cgi-script says:

2002-08-16 09:36:08 2002-08-16 09:36:08 0d 0h 0m 0s PROGRAM END Normal program termination
2002-08-16 09:36:08 2002-08-16 10:02:04 0d 0h 25m 56s PROGRAM (RE)START Program start
2002-08-16 10:02:04 2002-08-16 10:02:04 0d 0h 0m 0s PROGRAM (RE)START Program restart

...and...

HOST 'shutdown.linpro.no'... COMPUTING 2->1 FROM 1029419881 to 1029483368 (63487 seconds) FOR HOST
PASSED TIME CHECKS, CLIPPED VALUES: START=1029419881, END=1029483368

HOST 'shutdown.linpro.no'... COMPUTING 1->2 FROM 1029483368 to 1029483368 (0 seconds) FOR HOST

HOST 'shutdown.linpro.no'... COMPUTING 2->2 FROM 1029483368 to 1029484924 (1556 seconds) FOR HOST
PASSED TIME CHECKS, CLIPPED VALUES: START=1029483368, END=1029484924

...which seems more correct to me. :)

Patch attached. (Must be the largest one I've ever made. :-)


-jo :)

--1yeeQ81UyVL57Vl7
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="funky_downtime.diff"

*** avail.c-virgin Thu Aug 15 13:03:39 2002
--- avail.c Tue Aug 20 11:24:38 2002
***************
*** 2333,2339 ****
/* add the new entry to the list in memory, sorted by time (more recent entries should appear towards end of list) */
last_as=subject->as_list;
for(temp_as=subject->as_list;temp_as!=NULL;temp_as=temp_as->next){
! if(new_as->time_stamptime_stamp){
new_as->next=temp_as;
if(temp_as==subject->as_list)
subject->as_list=new_as;
--- 2334,2340 ----
/* add the new entry to the list in memory, sorted by time (more recent entries should appear towards end of list) */
last_as=subject->as_list;
for(temp_as=subject->as_list;temp_as!=NULL;temp_as=temp_as->next){
! if(new_as->time_stamptime_stamp){
new_as->next=temp_as;
if(temp_as==subject->as_list)
subject->as_list=new_as;

--1yeeQ81UyVL57Vl7--





This post was automatically imported from historical nagios-devel mailing list archives
Original poster: jo@linpro.no
Locked