diff --git a/src/models/mon_collect.go b/src/models/mon_collect.go index 530a0a0f..c18fecca 100644 --- a/src/models/mon_collect.go +++ b/src/models/mon_collect.go @@ -132,6 +132,11 @@ type ProcCollect struct { Target string `json:"target"` CollectMethod string `json:"collect_method"` + + ProcJiffy map[int]uint64 `xorm:"-" json:"-"` + Jiffy uint64 `xorm:"-" json:"-"` + RBytes map[int]uint64 `xorm:"-" json:"-"` + WBytes map[int]uint64 `xorm:"-" json:"-"` } type PluginCollect struct { diff --git a/src/modules/agent/log/worker/worker.go b/src/modules/agent/log/worker/worker.go index 70a10519..a6ca6e2c 100644 --- a/src/modules/agent/log/worker/worker.go +++ b/src/modules/agent/log/worker/worker.go @@ -185,9 +185,7 @@ func (w *Worker) analysis(line string) { analyspoint, err := w.producer(line, strategy) if err != nil { - log := fmt.Sprintf("%s[producer error][sid:%d] : %v", w.Mark, strategy.ID, err) - //sample_log.Error(log) - logger.Error(log) + logger.Debugf("%s[producer error][sid:%d] : %v", w.Mark, strategy.ID, err) continue } else { if analyspoint != nil { diff --git a/src/modules/agent/sys/procs/scheduler.go b/src/modules/agent/sys/procs/scheduler.go index 182f9d48..ff1a4e42 100644 --- a/src/modules/agent/sys/procs/scheduler.go +++ b/src/modules/agent/sys/procs/scheduler.go @@ -44,13 +44,6 @@ func (p *ProcScheduler) Stop() { close(p.Quit) } -var ( - rBytes map[int]uint64 - wBytes map[int]uint64 - procJiffy map[int]uint64 - jiffy uint64 -) - func ProcCollect(p *models.ProcCollect) { ps, err := AllProcs() if err != nil { @@ -84,24 +77,24 @@ func ProcCollect(p *models.ProcCollect) { cnt++ memory += proc.Mem fdNum += proc.FdCount - rOld := rBytes[proc.Pid] + rOld := p.RBytes[proc.Pid] if rOld != 0 && rOld <= proc.RBytes { ioRead += proc.RBytes - rOld } - wOld := wBytes[proc.Pid] + wOld := p.WBytes[proc.Pid] if wOld != 0 && wOld <= proc.WBytes { ioWrite += proc.WBytes - wOld } uptime = readUptime(proc.Pid) - // jiffy 为零,表示第一次采集信息,不做cpu计算 - if jiffy == 0 { + // p.Jiffy 为零,表示第一次采集信息,不做cpu计算 + if p.Jiffy == 0 { continue } - cpu += float64(newProcJiffy[proc.Pid] - procJiffy[proc.Pid]) + cpu += float64(newProcJiffy[proc.Pid] - p.ProcJiffy[proc.Pid]) } } @@ -114,8 +107,8 @@ func ProcCollect(p *models.ProcCollect) { ioWriteItem := core.GaugeValue("proc.io.write.bytes", ioWrite, p.Tags) items = []*dataobj.MetricValue{procNumItem, memUsedItem, procFdItem, procUptimeItem, ioReadItem, ioWriteItem} - if jiffy != 0 { - cpuUtil := cpu / float64(newJiffy-jiffy) * 100 + if p.Jiffy != 0 { + cpuUtil := cpu / float64(newJiffy-p.Jiffy) * 100 if cpuUtil > 100 { cpuUtil = 100 } @@ -144,10 +137,10 @@ func ProcCollect(p *models.ProcCollect) { core.Push(items) - rBytes = newRBytes - wBytes = newWBytes - procJiffy = newProcJiffy - jiffy = readJiffy() + p.RBytes = newRBytes + p.WBytes = newWBytes + p.ProcJiffy = newProcJiffy + p.Jiffy = readJiffy() } func isProc(p *Proc, method, target string) bool { diff --git a/src/modules/judge/backend/query/query.go b/src/modules/judge/backend/query/query.go index b789e8af..9dbe7253 100644 --- a/src/modules/judge/backend/query/query.go +++ b/src/modules/judge/backend/query/query.go @@ -45,6 +45,7 @@ func Query(reqs []*dataobj.QueryData, stra *models.Stra, expFunc string) []*data if err != nil { stats.Counter.Set("query.data.transfer.err", 1) logger.Warningf("get data err:%v", err) + return respData } else { for i := 0; i < len(resp.Data); i++ { var values dataobj.RRDValues diff --git a/src/modules/judge/judge/judge.go b/src/modules/judge/judge/judge.go index 60f2e442..182f75d6 100644 --- a/src/modules/judge/judge/judge.go +++ b/src/modules/judge/judge/judge.go @@ -287,6 +287,7 @@ func GetReqs(stra *models.Stra, metric string, nids, endpoints []string, now int if err != nil { stats.Counter.Set("query.index.err", 1) logger.Warning("query index err:", err) + return reqs } lostSeries := []cache.Series{} diff --git a/src/modules/rdb/http/router_user.go b/src/modules/rdb/http/router_user.go index 267d032d..69a858c2 100644 --- a/src/modules/rdb/http/router_user.go +++ b/src/modules/rdb/http/router_user.go @@ -66,7 +66,7 @@ func userAddPost(c *gin.Context) { root := loginRoot(c) var f userProfileForm - bind(c, &f) + dangerous(c.ShouldBind(&f)) dangerous(auth.CheckPassword(f.Password)) pass, err := models.CryptoPass(f.Password)