Optimize nodata alert value & fix plugin collect cycle not work
This commit is contained in:
parent
e196dcae79
commit
f004543ce0
|
@ -2,7 +2,6 @@ package plugins
|
|||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
@ -32,15 +31,9 @@ func ListPluginsFromMonapi() map[string]*Plugin {
|
|||
|
||||
for _, p := range plugins {
|
||||
fpath := p.FilePath
|
||||
fileInfo, err := os.Stat(fpath)
|
||||
if err != nil {
|
||||
logger.Warningf("plugin:%s get info err:%v", p.FilePath, err)
|
||||
continue
|
||||
}
|
||||
|
||||
plugin := &Plugin{
|
||||
FilePath: fpath,
|
||||
MTime: fileInfo.ModTime().Unix(),
|
||||
MTime: p.LastUpdated.Unix(),
|
||||
Cycle: p.Step,
|
||||
Params: p.Params,
|
||||
}
|
||||
|
|
|
@ -117,5 +117,9 @@ func PluginRun(plugin *Plugin) {
|
|||
return
|
||||
}
|
||||
|
||||
for i := 0; i < len(items); i++ {
|
||||
items[i].Step = int64(plugin.Cycle)
|
||||
}
|
||||
|
||||
funcs.Push(items)
|
||||
}
|
||||
|
|
|
@ -217,7 +217,7 @@ func (f NodataFunction) Compute(vs []*dataobj.HistoryData) (leftValue dataobj.Js
|
|||
return value.Value, false
|
||||
}
|
||||
}
|
||||
return 0, true
|
||||
return dataobj.JsonFloat(math.NaN()), true
|
||||
}
|
||||
|
||||
type CAvgAbsFunction struct {
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"container/list"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"math"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
@ -111,10 +112,14 @@ func Judge(stra *model.Stra, exps []model.Exp, historyData []*dataobj.HistoryDat
|
|||
}()
|
||||
|
||||
leftValue, isTriggered = judgeItemWithStrategy(stra, historyData, exps[0], firstItem, now)
|
||||
lastValue := "null"
|
||||
if !math.IsNaN(float64(leftValue)) {
|
||||
lastValue = strconv.FormatFloat(float64(leftValue), 'f', -1, 64)
|
||||
}
|
||||
if value == "" {
|
||||
value = fmt.Sprintf("%s: %v", exp.Metric, leftValue)
|
||||
value = fmt.Sprintf("%s: %s", exp.Metric, lastValue)
|
||||
} else {
|
||||
value += fmt.Sprintf("; %s: %v", exp.Metric, leftValue)
|
||||
value += fmt.Sprintf("; %s: %s", exp.Metric, lastValue)
|
||||
}
|
||||
status = append(status, isTriggered)
|
||||
|
||||
|
|
Loading…
Reference in New Issue