humanize uptime
Anirudh Oppiliappan x@icyphox.sh
Tue, 15 Nov 2022 09:16:19 +0530
2 files changed,
5 insertions(+),
3 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
@@ -7,7 +7,7 @@ <table style="font-size:0.8em">
<tbody> <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">{{ printf "%.02f" .Sensors.Uptime }}s +<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>