fix bugs rrd importer -> clients are no nodes :)
This commit is contained in:
parent
dfae737da3
commit
8c09687e86
|
@ -13,12 +13,14 @@ import (
|
|||
|
||||
var linePattern = regexp.MustCompile("^<!-- ....-..-.. ..:..:.. [A-Z]+ / (\\d+) --> <row><v>([^<]+)</v><v>([^<]+)</v></row>")
|
||||
|
||||
// Dataset a timestemp with values (node and clients)
|
||||
type Dataset struct {
|
||||
Time time.Time
|
||||
Nodes float64
|
||||
Clients float64
|
||||
}
|
||||
|
||||
// Read a rrdfile and return a chanel of datasets
|
||||
func Read(rrdFile string) chan Dataset {
|
||||
out := make(chan Dataset)
|
||||
cmd := exec.Command("rrdtool", "dump", rrdFile)
|
||||
|
@ -48,10 +50,10 @@ func Read(rrdFile string) chan Dataset {
|
|||
found = strings.Contains(str, "<!-- 86400 seconds -->")
|
||||
continue
|
||||
}
|
||||
if matches := linePattern.FindStringSubmatch(str); matches != nil && matches[2] != "NaN" {
|
||||
if matches := linePattern.FindStringSubmatch(str); matches != nil && matches[2] != "NaN" && matches[3] != "NaN" {
|
||||
seconds, _ := strconv.Atoi(matches[1])
|
||||
nodes, _ := strconv.ParseFloat(matches[2], 64)
|
||||
clients, _ := strconv.ParseFloat(matches[2], 64)
|
||||
clients, _ := strconv.ParseFloat(matches[3], 64)
|
||||
|
||||
out <- Dataset{
|
||||
Time: time.Unix(int64(seconds), 0),
|
||||
|
|
Loading…
Reference in New Issue