Page 1 of 1

Uptime on login page

Posted: Fri Jun 16, 2017 10:46 am
by fperkins
I have been having some issues with an access point so I would like to add uptime to the login.sh page. I was able to do it by adding my own section:

Code: Select all

<fieldset id="up_time" style="display:block">                                                                                                               
        <legend class="sectionheader">Uptime</legend>                                                                                                       
        <div class="nocolumn" id="up_time"><% echo "$(uptime | awk -F'( |,|:)+' '{print $6,$7",",$8,"hours,",$9,"minutes."}')" %></div>                     
</fieldset>
However, the formatting isn't the same as what Gargoyle provides on the overview page. I can't seem to find how Garoyle computes the uptime.

It puts uptime in a variable and then it magically turns into output. Can anyone tell me where the logic is?

Code: Select all

echo "var uptime=\"$(cat /proc/uptime)\";"
		<div>
			<span class='leftcolumn'><%~ Uptm %>:</span><span id="uptime" class='rightcolumn'></span>
		</div>
Thanks

Re: Uptime on login page

Posted: Fri Jun 16, 2017 12:51 pm
by fperkins
For now, I just changed the parsing code to this snippet. Seems to work well:

Code: Select all

echo "$(uptime | awk -F'( |,|:)+' '{if ($7=="min") m=$6; else {if ($7~/^day/) {d=$6;h=$8;m=$9} else {h=$6;m=$7}}} {print d+0,"days,",h+0,"hours,",m+0,"minutes."}')"

Re: Uptime on login page

Posted: Fri Jun 16, 2017 5:08 pm
by Lantis
It's in the first few lines of JavaScript for the page.
It breaks uptime into uptimeseconds, then formats that into a proper string.