mirror of
https://2025-dev.shylinux.com/x/20250213-machine
synced 2025-04-25 04:28:04 +08:00
add some
This commit is contained in:
parent
098aede490
commit
e4ad59c903
@ -1,4 +1,5 @@
|
||||
title "machine"
|
||||
title "ContextOS-Machine"
|
||||
section "gopsutil"
|
||||
refer `
|
||||
源码 https://github.com/shirou/gopsutil
|
||||
https://zhuanlan.zhihu.com/p/126362239
|
||||
|
@ -4,8 +4,10 @@ import (
|
||||
"time"
|
||||
|
||||
"shylinux.com/x/ice"
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/tcp"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
"shylinux.com/x/icebergs/core/code"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
@ -20,7 +22,7 @@ import (
|
||||
|
||||
type monitor struct {
|
||||
travel.Travel
|
||||
fields string `data:"version,time,Total,Free,Available,Used,UsedPercent,ModelName,Mhz,Core,Thread,CorePercent,ThreadPercent,DiskTotal,DiskFree,DiskUsed,DiskUsedPercent,BytesRecv,BytesSent,PacketsRecv,PacketsSent"`
|
||||
fields string `data:"Total,Free,Available,Used,UsedPercent,ModelName,Mhz,Core,Thread,CorePercent,ThreadPercent,DiskTotal,DiskFree,DiskUsed,DiskUsedPercent,BytesRecv,BytesSent,PacketsRecv,PacketsSent,version,time"`
|
||||
list string `name:"list space auto" help:"设备监控"`
|
||||
}
|
||||
|
||||
@ -32,10 +34,6 @@ func (s monitor) List(m *ice.Message, arg ...string) {
|
||||
n, _ := net.IOCounters(false)
|
||||
kit.For(kit.Split(m.OptionDefault(mdb.FIELDS, m.Config(mdb.FIELDS))), func(field string) {
|
||||
switch field {
|
||||
case nfs.VERSION:
|
||||
m.Push(field, ice.Info.Make.Version)
|
||||
case mdb.TIME:
|
||||
m.Push(field, ice.Info.Make.Time)
|
||||
case "ModelName":
|
||||
m.Push(field, c[0].ModelName)
|
||||
case "Mhz":
|
||||
@ -81,12 +79,17 @@ func (s monitor) List(m *ice.Message, arg ...string) {
|
||||
m.Push(field, kit.FmtSize(n[0].PacketsRecv))
|
||||
case "PacketsSent":
|
||||
m.Push(field, kit.FmtSize(n[0].PacketsSent))
|
||||
case nfs.VERSION:
|
||||
m.Push(field, ice.Info.Make.Version)
|
||||
case mdb.TIME:
|
||||
m.Push(field, ice.Info.Make.Time)
|
||||
default:
|
||||
m.Push(field, "")
|
||||
}
|
||||
})
|
||||
m.Action(s.Foreach)
|
||||
m.Cmdy(code.PUBLISH, nfs.BINARY)
|
||||
m.Option(cli.CTX_ARG, kit.JoinCmdArgs(tcp.NODENAME, m.Option(ice.MSG_USERPOD)))
|
||||
m.Cmdy(code.PUBLISH, nfs.CONTEXTS, ice.APP)
|
||||
} else {
|
||||
m.Cmdy(web.SPACE, arg[0], m.PrefixKey())
|
||||
}
|
||||
@ -99,7 +102,7 @@ func (s monitor) Foreach(m *ice.Message, arg ...string) {
|
||||
})
|
||||
list := []string{}
|
||||
kit.For(stats, func(key string, value int) { list = append(list, key, kit.FmtSize(value)) })
|
||||
m.StatusTimeCount(list).Sort("Available,space", ice.INT)
|
||||
m.StatusTimeCount(list)
|
||||
}
|
||||
|
||||
func init() { ice.Cmd("web.chat.dev.machine.monitor", monitor{}) }
|
||||
|
Loading…
x
Reference in New Issue
Block a user