forked from x/icebergs
add stats
This commit is contained in:
parent
08befa2f96
commit
104c0752e3
@ -44,8 +44,8 @@ func _runtime_init(m *ice.Message) {
|
|||||||
ice.Info.Pathname = m.Conf(RUNTIME, kit.Keys(BOOT, PATHNAME))
|
ice.Info.Pathname = m.Conf(RUNTIME, kit.Keys(BOOT, PATHNAME))
|
||||||
ice.Info.Username = m.Conf(RUNTIME, kit.Keys(BOOT, USERNAME))
|
ice.Info.Username = m.Conf(RUNTIME, kit.Keys(BOOT, USERNAME))
|
||||||
ice.Info.System = m.Conf(RUNTIME, kit.Keys(HOST, OSID))
|
ice.Info.System = m.Conf(RUNTIME, kit.Keys(HOST, OSID))
|
||||||
aaa.UserRoot(ice.Pulse, "", ice.Info.Username, aaa.ROOT, ice.OPS)
|
|
||||||
aaa.UserRoot(ice.Pulse, "", ice.Info.Make.Username, aaa.TECH, ice.DEV)
|
aaa.UserRoot(ice.Pulse, "", ice.Info.Make.Username, aaa.TECH, ice.DEV)
|
||||||
|
aaa.UserRoot(ice.Pulse, "", ice.Info.Username, aaa.ROOT, ice.OPS)
|
||||||
if runtime.GOARCH != MIPSLE {
|
if runtime.GOARCH != MIPSLE {
|
||||||
msg := m.Cmd(nfs.DIR, _system_find(m, os.Args[0]), "time,path,size,hash")
|
msg := m.Cmd(nfs.DIR, _system_find(m, os.Args[0]), "time,path,size,hash")
|
||||||
m.Conf(RUNTIME, kit.Keys(BOOT, mdb.TIME), msg.Append(mdb.TIME))
|
m.Conf(RUNTIME, kit.Keys(BOOT, mdb.TIME), msg.Append(mdb.TIME))
|
||||||
|
@ -93,6 +93,7 @@ const (
|
|||||||
FSIZE = kit.MDB_FSIZE
|
FSIZE = kit.MDB_FSIZE
|
||||||
|
|
||||||
ICONS = "icons"
|
ICONS = "icons"
|
||||||
|
UNITS = "units"
|
||||||
TOOLS = "tools"
|
TOOLS = "tools"
|
||||||
SOURCE = "_source"
|
SOURCE = "_source"
|
||||||
TARGET = "_target"
|
TARGET = "_target"
|
||||||
|
@ -46,12 +46,7 @@ func _dream_list(m *ice.Message) *ice.Message {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
mem, disk := 0, 0
|
return m.Sort("status,type,name", ice.STR, ice.STR, ice.STR_R).StatusTimeCount()
|
||||||
PushPodCmd(m.Spawn(), ROUTE, "travel").Table(func(value ice.Maps) {
|
|
||||||
mem += kit.Int(kit.Select("", kit.Split(value[nfs.SIZE], nfs.PS), 0))
|
|
||||||
disk += kit.Int(kit.Select("", kit.Split(value[nfs.SIZE], nfs.PS), 2))
|
|
||||||
})
|
|
||||||
return m.Sort("status,type,name", ice.STR, ice.STR, ice.STR_R).StatusTimeCount(stats, nfs.SIZE, kit.Format("%s/%s", kit.FmtSize(mem), kit.FmtSize(disk)))
|
|
||||||
|
|
||||||
}
|
}
|
||||||
func _dream_start(m *ice.Message, name string) {
|
func _dream_start(m *ice.Message, name string) {
|
||||||
@ -260,10 +255,8 @@ func init() {
|
|||||||
stats[cli.START]++
|
stats[cli.START]++
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
m.Push(mdb.NAME, kit.Keys(m.CommandKey(), cli.START)).Push(mdb.VALUE, stats[cli.START])
|
PushStats(m, kit.Keys(m.CommandKey(), cli.START), stats[cli.START], "")
|
||||||
m.Push(mdb.NAME, kit.Keys(m.CommandKey(), mdb.TOTAL)).Push(mdb.VALUE, msg.Length())
|
PushStats(m, kit.Keys(m.CommandKey(), mdb.TOTAL), msg.Length(), "")
|
||||||
m.Push("units", "")
|
|
||||||
m.Push("units", "")
|
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
}, aaa.RoleAction(), StatsAction(), DreamAction(), mdb.ImportantHashAction(ctx.TOOLS, "web.space,web.route,web.code.git.search", mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,icon,repos,binary,template")), Hand: func(m *ice.Message, arg ...string) {
|
}, aaa.RoleAction(), StatsAction(), DreamAction(), mdb.ImportantHashAction(ctx.TOOLS, "web.space,web.route,web.code.git.search", mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,icon,repos,binary,template")), Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
@ -17,8 +17,9 @@ const STATS = "stats"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
STATS: {Name: "stats name auto", Help: "汇总量", Meta: kit.Dict(
|
STATS: {Name: "stats refresh", Help: "汇总量", Meta: kit.Dict(
|
||||||
ice.CTX_TRANS, kit.Dict(html.INPUT, kit.Dict(
|
ice.CTX_TRANS, kit.Dict(html.INPUT, kit.Dict(
|
||||||
|
"command.total", "命令总数",
|
||||||
"repos.total", "代码库总数",
|
"repos.total", "代码库总数",
|
||||||
"dream.total", "空间总数",
|
"dream.total", "空间总数",
|
||||||
"dream.start", "已启动空间",
|
"dream.start", "已启动空间",
|
||||||
@ -36,11 +37,16 @@ func init() {
|
|||||||
"cpu.total", "处理器核数",
|
"cpu.total", "处理器核数",
|
||||||
)),
|
)),
|
||||||
), Hand: func(m *ice.Message, arg ...string) {
|
), Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Push(mdb.NAME, kit.Keys(aaa.SESS, mdb.TOTAL)).Push(mdb.VALUE, m.Cmd(aaa.SESS).Length())
|
defer ctx.DisplayStory(m, "stats.js")
|
||||||
m.Push(mdb.NAME, kit.Keys(aaa.USER, mdb.TOTAL)).Push(mdb.VALUE, m.Cmd(aaa.USER).Length()-1)
|
if m.Option(ice.MSG_USERPOD) == "" {
|
||||||
m.Push("units", "")
|
PushStats(m, kit.Keys(aaa.SESS, mdb.TOTAL), m.Cmd(aaa.SESS).Length(), "")
|
||||||
m.Push("units", "")
|
if ice.Info.Username == ice.Info.Make.Username {
|
||||||
ctx.DisplayStory(m, "stats.js")
|
PushStats(m, kit.Keys(aaa.USER, mdb.TOTAL), m.Cmd(aaa.USER).Length()-1, "")
|
||||||
|
} else {
|
||||||
|
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(), "")
|
||||||
|
}
|
||||||
gdb.Event(m, STATS_TABLES)
|
gdb.Event(m, STATS_TABLES)
|
||||||
PushPodCmd(m, "", arg...)
|
PushPodCmd(m, "", arg...)
|
||||||
}},
|
}},
|
||||||
@ -50,9 +56,11 @@ func StatsAction() 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, arg ...string) {
|
||||||
if msg := mdb.HashSelects(m.Spawn()); msg.Length() > 0 {
|
if msg := mdb.HashSelects(m.Spawn()); msg.Length() > 0 {
|
||||||
m.Push(mdb.NAME, kit.Keys(m.CommandKey(), mdb.TOTAL)).Push(mdb.VALUE, msg.Length())
|
PushStats(m, kit.Keys(m.CommandKey(), mdb.TOTAL), msg.Length(), "")
|
||||||
m.Push("units", "")
|
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
}, gdb.EventsAction(STATS_TABLES))
|
}, gdb.EventsAction(STATS_TABLES))
|
||||||
}
|
}
|
||||||
|
func PushStats(m *ice.Message, name string, value ice.Any, units string) {
|
||||||
|
kit.If(value != 0, func() { m.Push(mdb.NAME, name).Push(mdb.VALUE, value).Push(mdb.UNITS, units) })
|
||||||
|
}
|
||||||
|
@ -83,7 +83,7 @@ func _autogen_gits(m *ice.Message, arg ...string) string {
|
|||||||
}
|
}
|
||||||
func _autogen_git(m *ice.Message, arg ...string) ice.Map {
|
func _autogen_git(m *ice.Message, arg ...string) ice.Map {
|
||||||
msg := m.Cmd(REPOS, REMOTE)
|
msg := m.Cmd(REPOS, REMOTE)
|
||||||
return kit.Dict(arg, aaa.USERNAME, ice.Info.Username, tcp.HOSTNAME, ice.Info.Hostname, nfs.PATH, kit.Path("")+nfs.PS, mdb.TIME, m.Time(),
|
return kit.Dict(arg, aaa.USERNAME, m.Option(ice.MSG_USERNAME), tcp.HOSTNAME, ice.Info.Hostname, nfs.PATH, kit.Path("")+nfs.PS, mdb.TIME, m.Time(),
|
||||||
GIT, GitVersion(m), GO, GoVersion(m), nfs.MODULE, _autogen_mod(m, ice.GO_MOD),
|
GIT, GitVersion(m), GO, GoVersion(m), nfs.MODULE, _autogen_mod(m, ice.GO_MOD),
|
||||||
msg.AppendSimple("remote,branch,version,forword,author,email,hash,when,message"),
|
msg.AppendSimple("remote,branch,version,forword,author,email,hash,when,message"),
|
||||||
web.DOMAIN, strings.ReplaceAll(tcp.PublishLocalhost(m, m.Option(ice.MSG_USERWEB)), "%2F", nfs.PS),
|
web.DOMAIN, strings.ReplaceAll(tcp.PublishLocalhost(m, m.Option(ice.MSG_USERWEB)), "%2F", nfs.PS),
|
||||||
|
@ -33,10 +33,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]) })
|
||||||
m.Push(mdb.NAME, kit.Keys(m.CommandKey(), AMOUNT)).Push(mdb.VALUE, amount)
|
web.PushStats(m, kit.Keys(m.CommandKey(), AMOUNT), amount, "元")
|
||||||
m.Push("units", "元")
|
web.PushStats(m, kit.Keys(m.CommandKey(), mdb.COUNT), msg.Length(), "")
|
||||||
m.Push(mdb.NAME, kit.Keys(m.CommandKey(), mdb.COUNT)).Push(mdb.VALUE, msg.Length())
|
|
||||||
m.Push("units", "")
|
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
}, 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,10 +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]) })
|
||||||
m.Push(mdb.NAME, kit.Keys(m.CommandKey(), AMOUNT)).Push(mdb.VALUE, amount)
|
web.PushStats(m, kit.Keys(m.CommandKey(), AMOUNT), amount, "元")
|
||||||
m.Push("units", "元")
|
web.PushStats(m, kit.Keys(m.CommandKey(), mdb.COUNT), msg.Length(), "")
|
||||||
m.Push(mdb.NAME, kit.Keys(m.CommandKey(), mdb.COUNT)).Push(mdb.VALUE, msg.Length())
|
|
||||||
m.Push("units", "")
|
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
}, 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,8 +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]) })
|
||||||
m.Push(mdb.NAME, kit.Keys(m.CommandKey(), mdb.TOTAL)).Push(mdb.VALUE, count)
|
web.PushStats(m, kit.Keys(m.CommandKey(), mdb.TOTAL), count, "")
|
||||||
m.Push("units", "")
|
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
}, 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) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user