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
62404b6637
commit
098aede490
@ -5,11 +5,13 @@ import (
|
||||
|
||||
"shylinux.com/x/ice"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"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"
|
||||
"2025-dev.shylinux.com/x/20250215-cluster/src/travel"
|
||||
|
||||
"github.com/shirou/gopsutil/v4/cpu"
|
||||
"github.com/shirou/gopsutil/v4/disk"
|
||||
"github.com/shirou/gopsutil/v4/mem"
|
||||
@ -17,9 +19,9 @@ import (
|
||||
)
|
||||
|
||||
type monitor struct {
|
||||
fields string `data:"version,Total,Free,Available,Used,UsedPercent,ModelName,Mhz,Core,Thread,CorePercent,ThreadPercent,DiskTotal,DiskFree,DiskUsed,DiskUsedPercent,BytesRecv,BytesSent,PacketsRecv,PacketsSent"`
|
||||
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"`
|
||||
list string `name:"list space auto" help:"设备监控"`
|
||||
travel string `name:"travel" help:"遍历" icon:"bi bi-card-list"`
|
||||
}
|
||||
|
||||
func (s monitor) List(m *ice.Message, arg ...string) {
|
||||
@ -30,8 +32,10 @@ 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":
|
||||
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,31 +85,21 @@ func (s monitor) List(m *ice.Message, arg ...string) {
|
||||
m.Push(field, "")
|
||||
}
|
||||
})
|
||||
m.Action(s.Travel)
|
||||
m.Action(s.Foreach)
|
||||
m.Cmdy(code.PUBLISH, nfs.BINARY)
|
||||
} else {
|
||||
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) {
|
||||
s.travelCmdy(m, m.PrefixKey()).PushAction(s.Open).Action(s.Travel, s.Upgrade)
|
||||
func (s monitor) Foreach(m *ice.Message, arg ...string) {
|
||||
s.Travel.Foreach(m, arg...)
|
||||
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.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)))
|
||||
m.StatusTimeCount(list).Sort("Available,space", ice.INT)
|
||||
}
|
||||
|
||||
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