mirror of
https://github.com/xjasonlyu/tun2socks.git
synced 2025-10-08 18:20:41 +08:00
add cpu & mem usage info
This commit is contained in:
@@ -4,6 +4,9 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
C "github.com/shirou/gopsutil/cpu"
|
||||
M "github.com/shirou/gopsutil/mem"
|
||||
)
|
||||
|
||||
var startTime time.Time
|
||||
@@ -12,6 +15,16 @@ func init() {
|
||||
startTime = time.Now()
|
||||
}
|
||||
|
||||
func cpu() string {
|
||||
c, _ := C.Percent(0, false)
|
||||
return fmt.Sprintf("%.1f%%", c[0])
|
||||
}
|
||||
|
||||
func mem() string {
|
||||
m, _ := M.VirtualMemory()
|
||||
return fmt.Sprintf("%.1f%%", m.UsedPercent)
|
||||
}
|
||||
|
||||
func date(t time.Time) string {
|
||||
return t.Format("Mon Jan 2 15:04:05")
|
||||
}
|
||||
|
Reference in New Issue
Block a user