Merge branch 'master' of github.com:didi/nightingale

This commit is contained in:
Ulric Qin 2021-01-21 20:49:39 +08:00
commit 1f88b72dba
3 changed files with 32 additions and 2 deletions

View File

@ -107,8 +107,8 @@ func ProcCollect(p *models.ProcCollect) {
}
procNumItem := core.GaugeValue("proc.num", cnt, p.Tags)
procFdItem := core.GaugeValue("proc.uptime", uptime, p.Tags)
procUptimeItem := core.GaugeValue("proc.fdnum", fdNum, p.Tags)
procUptimeItem := core.GaugeValue("proc.uptime", uptime, p.Tags)
procFdItem := core.GaugeValue("proc.fdnum", fdNum, p.Tags)
memUsedItem := core.GaugeValue("proc.mem.used", memory*1024, p.Tags)
ioReadItem := core.GaugeValue("proc.io.read.bytes", ioRead, p.Tags)
ioWriteItem := core.GaugeValue("proc.io.write.bytes", ioWrite, p.Tags)

View File

@ -172,6 +172,7 @@ func Config(r *gin.Engine) {
v1.GET("/node/:id", nodeGet)
v1.GET("/node/:id/projs", v1treeUntilProjectGetsByNid)
v1.GET("/tree/projs", v1TreeUntilProjectGets)
v1.GET("/tree", v1TreeUntilTypGets)
// 外部系统推送一些操作日志过来RDB统一存储实际用MQ会更好一些
v1.POST("/resoplogs", v1OperationLogResPost)

View File

@ -160,6 +160,35 @@ func v1TreeUntilProjectGets(c *gin.Context) {
renderData(c, oks, err)
}
func v1TreeUntilTypGets(c *gin.Context) {
username := queryStr(c, "username")
cate := queryStr(c, "cate")
onlyCate := queryInt(c, "onlyCate", 0)
pid := queryInt64(c, "pid", -1)
user, err := models.UserGet("username=?", username)
dangerous(err)
oks, err := models.TreeUntilTypGetByUser(user, cate)
dangerous(err)
var ret []models.Node
for _, node := range oks {
//指定了父节点,不是想要的父节点
if pid != -1 && node.Pid != pid {
continue
}
//指定了节点类型,不是想要的节点类型
if onlyCate != 0 && node.Cate != cate {
continue
}
ret = append(ret, node)
}
renderData(c, ret, err)
}
// 这个方法展示的树只到organization
func treeUntilOrganizationGets(c *gin.Context) {
me := loginUser(c)