Skip to content

Commit f52fd9c

Browse files
committed
spoolfiles can contain special keys which will be transformed to tags and fields
1 parent 7a82547 commit f52fd9c

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

collector/spoolfile/nagiosSpoolfileWorker.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ type NagiosSpoolfileWorker struct {
2828
}
2929

3030
const (
31+
nagfluxTags string = "NAGFLUX:TAG"
32+
nagfluxField string = "NAGFLUX:FIELD"
33+
3134
hostPerfdata string = "HOSTPERFDATA"
3235

3336
servicePerfdata string = "SERVICEPERFDATA"
@@ -147,6 +150,16 @@ func (w *NagiosSpoolfileWorker) PerformanceDataIterator(input map[string]string)
147150
currentService = input[servicedesc]
148151
}
149152

153+
// Allows to add tags and fields to spoolfileentries
154+
tag := map[string]string{}
155+
if tagString, ok := input[nagfluxTags]; ok {
156+
tag = helper.StringToMap(tagString, " ", "=")
157+
}
158+
field := map[string]string{}
159+
if tagString, ok := input[nagfluxField]; ok {
160+
field = helper.StringToMap(tagString, " ", "=")
161+
}
162+
150163
go func() {
151164
perfSlice := regexPerformancelable.FindAllStringSubmatch(input[typ+"PERFDATA"], -1)
152165
currentCheckMultiLabel := ""
@@ -164,8 +177,8 @@ func (w *NagiosSpoolfileWorker) PerformanceDataIterator(input map[string]string)
164177
time: currentTime,
165178
performanceLabel: value[1],
166179
unit: value[3],
167-
tags: map[string]string{},
168-
fields: map[string]string{},
180+
tags: tag,
181+
fields: field,
169182
}
170183

171184
if currentCheckMultiLabel != "" {

0 commit comments

Comments
 (0)