Status Age display for Last Check time

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
User avatar
johndou
Posts: 1
Joined: Sun Oct 21, 2018 9:43 pm

Status Age display for Last Check time

Post by johndou »

I'd love to see the status age (0d 0h 0m 10s ago) show on Host and service status info windows. My installations are based on UTC date - while I am in the Pacific time zone - I always have to look at the UTC date, then the currently displayed Last check time to think about how long ago this item was actually checked. Adding this would most helpful to me.

Also - I have looked into the source code (but I'm not really a coder) - the extinfo.c module already has this feature for the Last Update entry.
It looks like this would be pretty easy to do - just update the last_update value to use last_check - there's even a comment that makes it look like someone has already thought of this, yet didn't implement it? The code segment would need to used copied up a few lines.
A quick update to the printf line for the last check would required as well (see below).

Is this something easy to do? Since I'm not really a coder, I'd compile and test this, but I don't really know how :). If I could get an updated extinfo.cgi file from this update, I'd love to try it out. If its easy to describe, could someone tell me how to compile the change so I could try it?


A quick copy of the logic used for that:

t = 0;
duration_error = FALSE;
if(temp_hoststatus->last_check > current_time)
duration_error = TRUE;
else
/*t=current_time-temp_hoststatus->last_check;*/
t = current_time - temp_hoststatus->last_check;
get_time_breakdown((unsigned long)t, &days, &hours, &minutes, &seconds);
if(duration_error == TRUE)
snprintf(status_age, sizeof(status_age) - 1, "???");
else if(temp_hoststatus->last_check == (time_t)0)
snprintf(status_age, sizeof(status_age) - 1, "N/A");
else
snprintf(status_age, sizeof(status_age) - 1, "%2dd %2dh %2dm %2ds", days, hours, minutes, seconds);
status_age[sizeof(status_age) - 1] = '\x0';

get_time_string(&temp_hoststatus->last_check, date_time, (int)sizeof(date_time), SHORT_DATE_TIME);
printf("<TR><TD CLASS='dataVar'>Last Check Time:</td><td CLASS='dataVal'>%s  (%s ago)</td></tr>\n", date_time, status_age);
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Status Age display for Last Check time

Post by scottwilkerson »

They do, see highlighted field
duration.PNG
duration.PNG (7.48 KiB) Viewed 1194 times
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Status Age display for Last Check time

Post by cdienger »

Which version of core are you using? My 4.4.1 machine is showing the duration on both the host status and service status details screen. Please provide a screenshot to clarify where you'd like to see it added if needed.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked