forked from x/icebergs
opt web.stats
This commit is contained in:
parent
2832fe1819
commit
c434e334a9
@ -268,8 +268,8 @@ func init() {
|
|||||||
stats[cli.START]++
|
stats[cli.START]++
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
PushStats(m, kit.Keys(m.CommandKey(), cli.START), stats[cli.START], "")
|
PushStats(m, kit.Keys(m.CommandKey(), cli.START), stats[cli.START], "", "空间总数")
|
||||||
PushStats(m, kit.Keys(m.CommandKey(), mdb.TOTAL), msg.Length(), "")
|
PushStats(m, kit.Keys(m.CommandKey(), mdb.TOTAL), msg.Length(), "", "已启动空间")
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
}, aaa.RoleAction(), StatsAction(), DreamAction(), mdb.ImportantHashAction(ctx.TOOLS, "web.route",
|
}, aaa.RoleAction(), StatsAction(), DreamAction(), mdb.ImportantHashAction(ctx.TOOLS, "web.route",
|
||||||
|
@ -113,7 +113,7 @@ func init() {
|
|||||||
RenderMain(m)
|
RenderMain(m)
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
}, aaa.WhiteAction(), StatsAction(), mdb.HashAction(mdb.FIELD, "time,hash,type,name,text,usernick,username,userrole", mdb.EXPIRE, mdb.DAYS)), Hand: func(m *ice.Message, arg ...string) {
|
}, aaa.WhiteAction(), StatsAction("", "共享总数"), mdb.HashAction(mdb.FIELD, "time,hash,type,name,text,usernick,username,userrole", mdb.EXPIRE, mdb.DAYS)), Hand: func(m *ice.Message, arg ...string) {
|
||||||
if kit.IsIn(m.Option(ice.MSG_USERROLE), aaa.ROOT, aaa.TECH) || len(arg) > 0 && arg[0] != "" {
|
if kit.IsIn(m.Option(ice.MSG_USERROLE), aaa.ROOT, aaa.TECH) || len(arg) > 0 && arg[0] != "" {
|
||||||
mdb.HashSelect(m, arg...)
|
mdb.HashSelect(m, arg...)
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
"shylinux.com/x/icebergs/base/ctx"
|
"shylinux.com/x/icebergs/base/ctx"
|
||||||
"shylinux.com/x/icebergs/base/gdb"
|
"shylinux.com/x/icebergs/base/gdb"
|
||||||
"shylinux.com/x/icebergs/base/mdb"
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
"shylinux.com/x/icebergs/base/web/html"
|
|
||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -17,56 +16,34 @@ const STATS = "stats"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
STATS: {Help: "汇总量", Meta: kit.Dict(
|
STATS: {Help: "汇总量", Hand: func(m *ice.Message, arg ...string) {
|
||||||
ice.CTX_TRANS, kit.Dict(html.INPUT, kit.Dict(
|
|
||||||
"goods.amount", "商品总额",
|
|
||||||
"goods.count", "商品数量",
|
|
||||||
"asset.amount", "资产总额",
|
|
||||||
"asset.count", "资产数量",
|
|
||||||
"task.total", "任务总数",
|
|
||||||
"dream.total", "空间总数",
|
|
||||||
"dream.start", "已启动空间",
|
|
||||||
"repos.total", "代码库总数",
|
|
||||||
"command.total", "命令总数",
|
|
||||||
"share.total", "共享总数",
|
|
||||||
"token.total", "令牌总数",
|
|
||||||
"user.total", "用户总数",
|
|
||||||
"sess.total", "会话总数",
|
|
||||||
"cpu.total", "处理器核数",
|
|
||||||
"cpu.used", "处理器使用率",
|
|
||||||
"mem.used", "内存用量",
|
|
||||||
"mem.total", "内存总量",
|
|
||||||
"disk.used", "磁盘用量",
|
|
||||||
"disk.total", "磁盘总量",
|
|
||||||
)),
|
|
||||||
), Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
defer ctx.DisplayStory(m, "")
|
defer ctx.DisplayStory(m, "")
|
||||||
if m.Option(ice.MSG_USERPOD) == "" {
|
if m.Option(ice.MSG_USERPOD) == "" {
|
||||||
PushStats(m, kit.Keys(aaa.SESS, mdb.TOTAL), m.Cmd(aaa.SESS).Length(), "")
|
PushStats(m, kit.Keys(aaa.SESS, mdb.TOTAL), m.Cmd(aaa.SESS).Length(), "", "会话总数")
|
||||||
if ice.Info.Username == ice.Info.Make.Username {
|
if ice.Info.Username == ice.Info.Make.Username {
|
||||||
PushStats(m, kit.Keys(aaa.USER, mdb.TOTAL), m.Cmd(aaa.USER).Length()-1, "")
|
PushStats(m, kit.Keys(aaa.USER, mdb.TOTAL), m.Cmd(aaa.USER).Length()-1, "", "用户总数")
|
||||||
} else {
|
} else {
|
||||||
PushStats(m, kit.Keys(aaa.USER, mdb.TOTAL), m.Cmd(aaa.USER).Length()-2, "")
|
PushStats(m, kit.Keys(aaa.USER, mdb.TOTAL), m.Cmd(aaa.USER).Length()-2, "", "用户总数")
|
||||||
}
|
}
|
||||||
PushStats(m, kit.Keys(ctx.COMMAND, mdb.TOTAL), m.Cmd(ctx.COMMAND).Length(), "")
|
PushStats(m, kit.Keys(ctx.COMMAND, mdb.TOTAL), m.Cmd(ctx.COMMAND).Length(), "", "命令总数")
|
||||||
}
|
}
|
||||||
gdb.Event(m, STATS_TABLES)
|
gdb.Event(m, STATS_TABLES)
|
||||||
PushPodCmd(m, "", arg...)
|
PushPodCmd(m, "", arg...)
|
||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
func StatsAction() ice.Actions {
|
func StatsAction(arg ...string) ice.Actions {
|
||||||
return ice.MergeActions(ice.Actions{
|
return ice.MergeActions(ice.Actions{
|
||||||
STATS_TABLES: {Hand: func(m *ice.Message, arg ...string) {
|
STATS_TABLES: {Hand: func(m *ice.Message, _ ...string) {
|
||||||
if msg := mdb.HashSelects(m.Spawn()); msg.Length() > 0 {
|
if msg := mdb.HashSelects(m.Spawn()); msg.Length() > 0 {
|
||||||
PushStats(m, kit.Keys(m.CommandKey(), mdb.TOTAL), msg.Length(), "")
|
PushStats(m, kit.Keys(m.CommandKey(), mdb.TOTAL), msg.Length(), arg...)
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
}, gdb.EventsAction(STATS_TABLES))
|
}, gdb.EventsAction(STATS_TABLES))
|
||||||
}
|
}
|
||||||
func PushStats(m *ice.Message, name string, value ice.Any, units string) {
|
func PushStats(m *ice.Message, name string, value ice.Any, arg ...string) {
|
||||||
kit.If(value != 0, func() {
|
kit.If(value != 0, func() {
|
||||||
m.Push(mdb.NAME, name).Push(mdb.VALUE, value).Push(mdb.UNITS, units)
|
m.Push(mdb.NAME, name).Push(mdb.VALUE, value).Push(mdb.UNITS, kit.Select("", arg, 0)).Push(ctx.TRANS, kit.Select("", arg, 1))
|
||||||
m.Push(ctx.INDEX, m.PrefixKey())
|
m.Push(ctx.INDEX, m.PrefixKey())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ func init() {
|
|||||||
m.Cmd(cli.SYSTEM, "git", "config", "--global", "credential.helper", "store")
|
m.Cmd(cli.SYSTEM, "git", "config", "--global", "credential.helper", "store")
|
||||||
m.ProcessClose()
|
m.ProcessClose()
|
||||||
}},
|
}},
|
||||||
}, StatsAction(), mdb.HashAction(mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,type,name,text", mdb.EXPIRE, mdb.MONTH)), Hand: func(m *ice.Message, arg ...string) {
|
}, StatsAction("", "令牌总数"), mdb.HashAction(mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,type,name,text", mdb.EXPIRE, mdb.MONTH)), Hand: func(m *ice.Message, arg ...string) {
|
||||||
mdb.HashSelect(m, arg...)
|
mdb.HashSelect(m, arg...)
|
||||||
if len(arg) > 0 {
|
if len(arg) > 0 {
|
||||||
m.EchoScript(kit.Format("ish_miss_serve_log dev %s token %s", UserHost(m), arg[0]))
|
m.EchoScript(kit.Format("ish_miss_serve_log dev %s token %s", UserHost(m), arg[0]))
|
||||||
|
@ -63,7 +63,7 @@ func _go_navigate(m *ice.Message, arg ...string) {
|
|||||||
}
|
}
|
||||||
func _go_show(m *ice.Message, arg ...string) {
|
func _go_show(m *ice.Message, arg ...string) {
|
||||||
if arg[1] == MAIN_GO {
|
if arg[1] == MAIN_GO {
|
||||||
ProcessXterm(m, "ish", "", arg[1])
|
ProcessXterm(m, kit.JoinWord("ish", arg[1]), "", "")
|
||||||
} else if cmd := ctx.GetFileCmd(path.Join(arg[2], arg[1])); cmd != "" {
|
} else if cmd := ctx.GetFileCmd(path.Join(arg[2], arg[1])); cmd != "" {
|
||||||
ctx.ProcessField(m, cmd, kit.Simple())
|
ctx.ProcessField(m, cmd, kit.Simple())
|
||||||
} else if msg := m.Cmd(yac.STACK, path.Join(arg[2], arg[1])); msg.Option("__index") != "" {
|
} else if msg := m.Cmd(yac.STACK, path.Join(arg[2], arg[1])); msg.Option("__index") != "" {
|
||||||
|
@ -32,8 +32,8 @@ func init() {
|
|||||||
web.STATS_TABLES: {Hand: func(m *ice.Message, arg ...string) {
|
web.STATS_TABLES: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
if msg := mdb.HashSelects(m.Spawn()); msg.Length() > 0 {
|
if msg := mdb.HashSelects(m.Spawn()); msg.Length() > 0 {
|
||||||
amount := msg.TableAmount(func(value ice.Maps) float64 { return kit.Float(value[mdb.COUNT]) * kit.Float(value[PRICE]) })
|
amount := msg.TableAmount(func(value ice.Maps) float64 { return kit.Float(value[mdb.COUNT]) * kit.Float(value[PRICE]) })
|
||||||
web.PushStats(m, kit.Keys(m.CommandKey(), AMOUNT), amount, "元")
|
web.PushStats(m, kit.Keys(m.CommandKey(), AMOUNT), amount, "元", "商品总额")
|
||||||
web.PushStats(m, kit.Keys(m.CommandKey(), mdb.COUNT), msg.Length(), "")
|
web.PushStats(m, kit.Keys(m.CommandKey(), mdb.COUNT), msg.Length(), "", "商品数量")
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
}, aaa.RoleAction(), web.StatsAction(), web.ExportCacheAction(nfs.IMAGE), mdb.ExportHashAction(ctx.TOOLS, kit.Fields(Prefix(CART), Prefix(ORDER)), mdb.FIELD, "time,hash,zone,name,text,price,count,units,image")), Hand: func(m *ice.Message, arg ...string) {
|
}, aaa.RoleAction(), web.StatsAction(), web.ExportCacheAction(nfs.IMAGE), mdb.ExportHashAction(ctx.TOOLS, kit.Fields(Prefix(CART), Prefix(ORDER)), mdb.FIELD, "time,hash,zone,name,text,price,count,units,image")), Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
@ -101,8 +101,8 @@ func init() {
|
|||||||
web.STATS_TABLES: {Hand: func(m *ice.Message, arg ...string) {
|
web.STATS_TABLES: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
if msg := mdb.HashSelects(m.Spawn()); msg.Length() > 0 {
|
if msg := mdb.HashSelects(m.Spawn()); msg.Length() > 0 {
|
||||||
amount := msg.TableAmount(func(value ice.Maps) float64 { return kit.Float(value[AMOUNT]) })
|
amount := msg.TableAmount(func(value ice.Maps) float64 { return kit.Float(value[AMOUNT]) })
|
||||||
web.PushStats(m, kit.Keys(m.CommandKey(), AMOUNT), amount, "元")
|
web.PushStats(m, kit.Keys(m.CommandKey(), AMOUNT), amount, "元", "资产总额")
|
||||||
web.PushStats(m, kit.Keys(m.CommandKey(), mdb.COUNT), msg.Length(), "")
|
web.PushStats(m, kit.Keys(m.CommandKey(), mdb.COUNT), msg.Length(), "", "资产数量")
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
}, web.StatsAction(), mdb.ExportZoneAction(mdb.SHORT, ACCOUNT, mdb.FIELD, "time,account,type,amount,count", mdb.FIELDS, "time,id,type,amount,name,text")), Hand: func(m *ice.Message, arg ...string) {
|
}, web.StatsAction(), mdb.ExportZoneAction(mdb.SHORT, ACCOUNT, mdb.FIELD, "time,account,type,amount,count", mdb.FIELDS, "time,id,type,amount,name,text")), Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
@ -101,7 +101,7 @@ func init() {
|
|||||||
if msg := mdb.HashSelects(m.Spawn()); msg.Length() > 0 {
|
if msg := mdb.HashSelects(m.Spawn()); msg.Length() > 0 {
|
||||||
count := 0
|
count := 0
|
||||||
msg.Table(func(value ice.Maps) { count += kit.Int(value[mdb.COUNT]) })
|
msg.Table(func(value ice.Maps) { count += kit.Int(value[mdb.COUNT]) })
|
||||||
web.PushStats(m, kit.Keys(m.CommandKey(), mdb.TOTAL), count, "")
|
web.PushStats(m, kit.Keys(m.CommandKey(), mdb.TOTAL), count, "", "任务总数")
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
}, web.StatsAction(), mdb.ExportZoneAction(mdb.FIELD, "time,zone,count", mdb.FIELDS, "begin_time,end_time,id,status,level,score,type,name,text")), Hand: func(m *ice.Message, arg ...string) {
|
}, web.StatsAction(), mdb.ExportZoneAction(mdb.FIELD, "time,zone,count", mdb.FIELDS, "begin_time,end_time,id,status,level,score,type,name,text")), Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
@ -606,7 +606,7 @@ func init() {
|
|||||||
web.DREAM_TRASH: {Hand: func(m *ice.Message, arg ...string) {
|
web.DREAM_TRASH: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmd("", mdb.REMOVE, kit.Dict(REPOS, m.Option(mdb.NAME)))
|
m.Cmd("", mdb.REMOVE, kit.Dict(REPOS, m.Option(mdb.NAME)))
|
||||||
}},
|
}},
|
||||||
}, aaa.RoleAction(REMOTE), web.StatsAction(), web.DreamAction(), mdb.HashAction(mdb.SHORT, REPOS, mdb.FIELD, "time,repos,branch,version,message,origin"), mdb.ClearOnExitHashAction()), Hand: func(m *ice.Message, arg ...string) {
|
}, aaa.RoleAction(REMOTE), web.StatsAction("", "代码库总数"), web.DreamAction(), mdb.HashAction(mdb.SHORT, REPOS, mdb.FIELD, "time,repos,branch,version,message,origin"), mdb.ClearOnExitHashAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||||
if len(arg) == 0 {
|
if len(arg) == 0 {
|
||||||
mdb.HashSelect(m, arg...).Sort(REPOS).PushAction(STATUS, mdb.REMOVE).Action(STATUS, PULL, PUSH, CLONE)
|
mdb.HashSelect(m, arg...).Sort(REPOS).PushAction(STATUS, mdb.REMOVE).Action(STATUS, PULL, PUSH, CLONE)
|
||||||
} else if len(arg) == 1 {
|
} else if len(arg) == 1 {
|
||||||
|
@ -59,6 +59,7 @@ type relay struct {
|
|||||||
ice.Code
|
ice.Code
|
||||||
short string `data:"machine"`
|
short string `data:"machine"`
|
||||||
field string `data:"time,machine,username,password,host,port,portal,module,version,commit,compile,package,shell,kernel,arch,ncpu,vcpu,mhz,mem,disk,network,listen,socket,proc,vendor"`
|
field string `data:"time,machine,username,password,host,port,portal,module,version,commit,compile,package,shell,kernel,arch,ncpu,vcpu,mhz,mem,disk,network,listen,socket,proc,vendor"`
|
||||||
|
statsTables string `name:"statsTables" event:"stats.tables"`
|
||||||
create string `name:"create machine* username* password host* port*=22 portal vendor"`
|
create string `name:"create machine* username* password host* port*=22 portal vendor"`
|
||||||
pubkey string `name:"pubkey" help:"公钥"`
|
pubkey string `name:"pubkey" help:"公钥"`
|
||||||
version string `name:"version" help:"版本"`
|
version string `name:"version" help:"版本"`
|
||||||
@ -80,6 +81,11 @@ func (s relay) Init(m *ice.Message, arg ...string) {
|
|||||||
msg := m.Spawn(ice.Maps{ice.MSG_FIELDS: ""})
|
msg := m.Spawn(ice.Maps{ice.MSG_FIELDS: ""})
|
||||||
m.GoSleep3s(func() { s.Hash.List(msg).Table(func(value ice.Maps) { s.xterm(m.Spawn(value)) }) })
|
m.GoSleep3s(func() { s.Hash.List(msg).Table(func(value ice.Maps) { s.xterm(m.Spawn(value)) }) })
|
||||||
}
|
}
|
||||||
|
func (s relay) StatsTables(m *ice.Message, arg ...string) {
|
||||||
|
if msg := mdb.HashSelects(m.Spawn().Message); msg.Length() > 0 {
|
||||||
|
web.PushStats(m.Message, "relay.total", msg.Length(), "", "服务器数量")
|
||||||
|
}
|
||||||
|
}
|
||||||
func (s relay) Inputs(m *ice.Message, arg ...string) {
|
func (s relay) Inputs(m *ice.Message, arg ...string) {
|
||||||
switch s.Hash.Inputs(m, arg...); arg[0] {
|
switch s.Hash.Inputs(m, arg...); arg[0] {
|
||||||
case MACHINE:
|
case MACHINE:
|
||||||
|
@ -143,7 +143,7 @@ func init() {
|
|||||||
defer web.ToastProcess(m)()
|
defer web.ToastProcess(m)()
|
||||||
m.Cmd(web.SPACE, m.Option(web.WEIXIN), lex.PARSE, m.Cmdx("", m.Option(mdb.HASH)))
|
m.Cmd(web.SPACE, m.Option(web.WEIXIN), lex.PARSE, m.Cmdx("", m.Option(mdb.HASH)))
|
||||||
}},
|
}},
|
||||||
}, mdb.ExportHashAction(
|
}, web.StatsAction("", "小程序场景数"), mdb.ExportHashAction(
|
||||||
mdb.FIELD, "time,hash,name,pages,space,index,args,wifi",
|
mdb.FIELD, "time,hash,name,pages,space,index,args,wifi",
|
||||||
cli.DARWIN, "/Applications/wechatwebdevtools.app/Contents/MacOS/cli",
|
cli.DARWIN, "/Applications/wechatwebdevtools.app/Contents/MacOS/cli",
|
||||||
)), Hand: func(m *ice.Message, arg ...string) {
|
)), Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user