Skip to content
This repository was archived by the owner on Nov 18, 2024. It is now read-only.

Commit a2991e9

Browse files
committed
added feature #56
1 parent 9baaac4 commit a2991e9

File tree

4 files changed

+37
-10
lines changed

4 files changed

+37
-10
lines changed

hmc/hmc.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,13 @@ func (hmc *HMC) AddPoint(name string, metric string, values []float64) {
156156
}
157157
}
158158
}
159+
if _, ok := hmc.TagParsers["_ALL"][key]; ok {
160+
for _, tagParser := range hmc.TagParsers["_ALL"][key] {
161+
if tagParser.Regexp.MatchString(value) {
162+
tags[tagParser.Name] = tagParser.Value
163+
}
164+
}
165+
}
159166
}
160167
hmc.InfluxDB.AddPoint(point.Name, hmc.GlobalPoint.Timestamp, field, tags)
161168
}

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func main() {
7373
app := cli.NewApp()
7474
app.Name = "nmon2influxdb"
7575
app.Usage = "upload NMON stats to InfluxDB database"
76-
app.Version = "2.1.4"
76+
app.Version = "2.1.5"
7777
app.Commands = []cli.Command{
7878
{
7979
Name: "import",

nmon/import.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,15 @@ func Import(c *cli.Context) {
194194
}
195195
}
196196
}
197+
198+
if _, ok := nmon.TagParsers["_ALL"][key]; ok {
199+
for _, tagParser := range nmon.TagParsers["_ALL"][key] {
200+
if tagParser.Regexp.MatchString(value) {
201+
tags[tagParser.Name] = tagParser.Value
202+
}
203+
}
204+
}
205+
197206
}
198207
influxdb.AddPoint(measurement, timestamp, field, tags)
199208

nmon2influxdblib/parser.go

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package nmon2influxdblib
66
import (
77
"fmt"
88
"regexp"
9+
"strings"
910
)
1011

1112
//Tags array
@@ -31,20 +32,30 @@ func ParseInputs(inputs Inputs) TagParsers {
3132
fmt.Printf("could not compile Config Input match parameter %s\n", input.Match)
3233
}
3334

34-
// Intialize if empty struct
35-
if _, ok := tagParsers[input.Measurement]; !ok {
36-
tagParsers[input.Measurement] = make(map[string]Tags)
35+
var measurements []string
36+
37+
if len(input.Measurement) == 0 {
38+
measurements = []string{"_ALL"}
39+
} else {
40+
measurements = strings.Split(input.Measurement, ",")
3741
}
3842

39-
tagger := tagParsers[input.Measurement][input.Name]
43+
for _, measurement := range measurements {
44+
// Intialize if empty struct
45+
if _, ok := tagParsers[measurement]; !ok {
46+
tagParsers[measurement] = make(map[string]Tags)
47+
}
4048

41-
for _, tag := range input.Tags {
42-
tag.Regexp = tagRegexp
43-
tagger = append(tagger, tag)
44-
}
49+
tagger := tagParsers[measurement][input.Name]
4550

46-
tagParsers[input.Measurement][input.Name] = tagger
51+
for _, tag := range input.Tags {
52+
tag.Regexp = tagRegexp
53+
tagger = append(tagger, tag)
54+
}
4755

56+
tagParsers[measurement][input.Name] = tagger
57+
}
4858
}
59+
4960
return tagParsers
5061
}

0 commit comments

Comments
 (0)