Uptime on login page

General discussion about Gargoyle, OpenWrt or anything else even remotely related to the project

Moderator: Moderators

Post Reply
fperkins
Posts: 6
Joined: Tue May 30, 2017 9:51 am

Uptime on login page

Post 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

fperkins
Posts: 6
Joined: Tue May 30, 2017 9:51 am

Re: Uptime on login page

Post 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."}')"

Lantis
Moderator
Posts: 6753
Joined: Mon Jan 05, 2015 5:33 am
Location: Australia

Re: Uptime on login page

Post 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.
http://lantisproject.com/downloads/gargoyle_ispyisail.php for the latest releases
Please be respectful when posting. I do this in my free time on a volunteer basis.

Post Reply