mirror of
https://2025-dev.shylinux.com/x/20250213-machine
synced 2025-04-25 04:28:04 +08:00
opt some
This commit is contained in:
parent
77e0afefb5
commit
62404b6637
@ -6,6 +6,7 @@ import (
|
||||
"shylinux.com/x/ice"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
"shylinux.com/x/icebergs/core/code"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
|
||||
_ "2025-dev.shylinux.com/x/20250215-cluster/src/travel"
|
||||
@ -16,9 +17,9 @@ import (
|
||||
)
|
||||
|
||||
type monitor struct {
|
||||
fields string `data:"ModelName,Mhz,Core,Thread,CorePercent,ThreadPercent,Total,Free,Available,Used,UsedPercent,DiskTotal,DiskFree,DiskUsed,DiskUsedPercent,BytesRecv,BytesSent,PacketsRecv,PacketsSent"`
|
||||
fields string `data:"version,Total,Free,Available,Used,UsedPercent,ModelName,Mhz,Core,Thread,CorePercent,ThreadPercent,DiskTotal,DiskFree,DiskUsed,DiskUsedPercent,BytesRecv,BytesSent,PacketsRecv,PacketsSent"`
|
||||
list string `name:"list space auto" help:"设备监控"`
|
||||
travel string `name:"travel" help:"遍历"`
|
||||
travel string `name:"travel" help:"遍历" icon:"bi bi-card-list"`
|
||||
}
|
||||
|
||||
func (s monitor) List(m *ice.Message, arg ...string) {
|
||||
@ -29,6 +30,8 @@ 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 "version":
|
||||
m.Push(field, ice.Info.Make.Version)
|
||||
case "ModelName":
|
||||
m.Push(field, c[0].ModelName)
|
||||
case "Mhz":
|
||||
@ -83,18 +86,26 @@ func (s monitor) List(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(web.SPACE, arg[0], m.PrefixKey())
|
||||
}
|
||||
}
|
||||
func (s monitor) Upgrade(m *ice.Message, arg ...string) {
|
||||
s.travelCmdy(m, code.UPGRADE)
|
||||
}
|
||||
func (s monitor) Travel(m *ice.Message, arg ...string) {
|
||||
m.Cmdy("web.chat.dev.cluster.travel", ice.Info.Make.Module, m.PrefixKey()).PushAction(s.Open)
|
||||
s.travelCmdy(m, m.PrefixKey()).PushAction(s.Open).Action(s.Travel, s.Upgrade)
|
||||
stats := map[string]int{}
|
||||
m.Table(func(value ice.Maps) {
|
||||
kit.For([]string{"Thread", "Used", "Available", "DiskUsed", "DiskFree"}, func(key string) { stats[key] += kit.Int(value[key]) })
|
||||
})
|
||||
list := []string{}
|
||||
kit.For(stats, func(key string, value int) { list = append(list, key, kit.FmtSize(value)) })
|
||||
m.StatusTime(list)
|
||||
m.StatusTimeCount(list)
|
||||
m.Sort("Available,space", ice.INT)
|
||||
}
|
||||
func (s monitor) Open(m *ice.Message, arg ...string) {
|
||||
m.ProcessOpen(web.S(m.Option(web.SPACE)))
|
||||
}
|
||||
|
||||
func init() { ice.Cmd("web.chat.dev.machine.monitor", monitor{}) }
|
||||
|
||||
func (s monitor) travelCmdy(m *ice.Message, arg ...string) *ice.Message {
|
||||
return m.Cmdy("web.chat.dev.cluster.travel", ice.Info.Make.Module, arg)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user