mirror of
https://github.com/edgebox-iot/edgeboxctl.git
synced 2026-09-24 05:41:43 +02:00
Added system module, GetUptimeSeconds and GetUptimeFormatted funcs, taskGetSystemUptime
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/shirou/gopsutil/host"
|
||||
)
|
||||
|
||||
func GetUptimeInSeconds() string {
|
||||
uptime, _ := host.Uptime()
|
||||
|
||||
return strconv.FormatUint(uptime, 10)
|
||||
}
|
||||
|
||||
func GetUptimeFormatted() string {
|
||||
uptime, _ := host.Uptime()
|
||||
|
||||
days := uptime / (60 * 60 * 24)
|
||||
hours := (uptime - (days * 60 * 60 * 24)) / (60 * 60)
|
||||
minutes := ((uptime - (days * 60 * 60 * 24)) - (hours * 60 * 60)) / 60
|
||||
return fmt.Sprintf("%d days, %d hours, %d minutes", days, hours, minutes)
|
||||
}
|
||||
Reference in New Issue
Block a user