humanize uptime
Anirudh Oppiliappan x@icyphox.sh
Tue, 15 Nov 2022 09:16:19 +0530
2 files changed,
8 insertions(+),
6 deletions(-)
M
sensors.go
→
sensors.go
@@ -18,11 +18,13 @@
import ( "syscall" "time" + + "github.com/dustin/go-humanize" ) type Sensors struct { Memory float64 - Uptime float64 + Uptime string CPU float64 }@@ -36,7 +38,7 @@ now := time.Now()
var sensors Sensors sensors.Memory = float64(usage.Maxrss) / 1024.0 - sensors.Uptime = now.Sub(boottime).Seconds() + sensors.Uptime = humanize.RelTime(boottime, now, "", "") sensors.CPU = time.Duration(usage.Utime.Nano()).Seconds() return sensors
M
views/about.html
→
views/about.html
@@ -5,10 +5,10 @@ {{ .AboutMsg }}
<p> <table class="font08em"> <tbody> -<tr><td>version:<td class="textright">{{ .HonkVersion }} -<tr><td>memory:<td class="textright">{{ printf "%.02f" .Sensors.Memory }}MB -<tr><td>uptime:<td class="textright">{{ printf "%.02f" .Sensors.Uptime }}s -<tr><td>cputime:<td class="textright">{{ printf "%.02f" .Sensors.CPU }}s +<tr><td>version:<td style="text-align:right">{{ .HonkVersion }} +<tr><td>memory:<td style="text-align:right">{{ printf "%.02f" .Sensors.Memory }}MB +<tr><td>uptime:<td style="text-align:right">{{ .Sensors.Uptime }} +<tr><td>cputime:<td style="text-align:right">{{ printf "%.02f" .Sensors.CPU }}s </table> <p> </div>