From 560622b3e133c2c8e4c15746c9d74c4ab163dff2 Mon Sep 17 00:00:00 2001 From: Ahmet Oeztuerk Date: Fri, 6 Mar 2026 17:17:29 +0100 Subject: [PATCH 01/11] WIP: improve perfdata parsing, add warnings - add explanations to the regexes used in the parser - use '\' when specifying all literal characters in the regex, not all of them were using it when building regex lists - convert some German names to English - add example value of perfdata string regex match - use enum to browse perdata fields after regex match, clearer to read - revise the perdata reading logic, use guards and skip early where possible instead of nesting - add max length filters to each field of the perfdata: value, uom, warn, crit, min, max , accessible by the config file - move config parsing of nagios from main function to nagiosCollectorFactory. main function only parses to check if its enabled --- .../collector/modgearman/gearmanWorker.go | 3 +- .../spoolfile/nagiosSpoolfileCollector.go | 92 ++++- .../spoolfile/nagiosSpoolfileWorker.go | 369 +++++++++++++----- pkg/nagflux/config/Config.go | 6 +- pkg/nagflux/helper/config_helper.go | 11 +- pkg/nagflux/nagflux.go | 46 +-- 6 files changed, 377 insertions(+), 150 deletions(-) diff --git a/pkg/nagflux/collector/modgearman/gearmanWorker.go b/pkg/nagflux/collector/modgearman/gearmanWorker.go index 01cf8a0..2632b55 100644 --- a/pkg/nagflux/collector/modgearman/gearmanWorker.go +++ b/pkg/nagflux/collector/modgearman/gearmanWorker.go @@ -53,8 +53,7 @@ func NewGearmanWorker(address, queue, key string, results collector.ResultQueues pauseQuit: make(chan bool, 1), results: results, nagiosSpoolfileWorker: spoolfile.NewNagiosSpoolfileWorker( - -1, make(chan string), make(collector.ResultQueues), livestatusCacheBuilder, 4096, collector.AllFilterable, - ), + -1, make(chan string), make(collector.ResultQueues), livestatusCacheBuilder, 4096, collector.AllFilterable, spoolfile.PerfdataLabelMaxLengthDefault, spoolfile.PerfdataUOMMaxLengthDefault, spoolfile.PerfdataNumericValuesMaxLengthDefault, spoolfile.PerfdataThresholdsMaxLengthDefault), aesECBDecrypter: decrypter, worker: nil, address: address, diff --git a/pkg/nagflux/collector/spoolfile/nagiosSpoolfileCollector.go b/pkg/nagflux/collector/spoolfile/nagiosSpoolfileCollector.go index a16dd5d..0d04f94 100644 --- a/pkg/nagflux/collector/spoolfile/nagiosSpoolfileCollector.go +++ b/pkg/nagflux/collector/spoolfile/nagiosSpoolfileCollector.go @@ -1,6 +1,8 @@ package spoolfile import ( + "fmt" + "nagflux/helper" "os" "path" "time" @@ -18,6 +20,20 @@ const ( // IntervalToCheckDirectory the interval to check if there are new files IntervalToCheckDirectory = 1500 * time.Millisecond + + // If a perfdata label is longer than this, it will be logged as an anomaly and skipped + PerfdataLabelMaxLengthDefault = int(32) + + // If a perfdata UOM is longer than this, it will be logged as an anomaly and skipped + PerfdataUOMMaxLengthDefault = int(16) + + // If a perfdata numeric value, e.g current value, min, and max is longer than this, it will be logged as an anomaly and skipped + // Reasoning: Largest uint64 is 20 characters wide, floats are not printed with too much precision either + PerfdataNumericValuesMaxLengthDefault = int(32) + + // If a perfdata numeric value, e.g current value, min, and max is longer than this, it will be logged as an anomaly and skipped + // Reasoning: Twice the numeric value max length, since there are seperators as well + PerfdataThresholdsMaxLengthDefault = int(64) ) // NagiosSpoolfileCollector scans the nagios spoolfile folder and delegates the files to its workers. @@ -29,9 +45,77 @@ type NagiosSpoolfileCollector struct { } // NagiosSpoolfileCollectorFactory creates the give amount of Woker and starts them. -func NagiosSpoolfileCollectorFactory(spoolDirectory string, workerAmount int, results collector.ResultQueues, +func NagiosSpoolfileCollectorFactory(cfg config.Config, results collector.ResultQueues, livestatusCacheBuilder *livestatus.CacheBuilder, fileBufferSize int, defaultTarget collector.Filterable, -) *NagiosSpoolfileCollector { +) (*NagiosSpoolfileCollector, error) { + spoolDirectory := "" + search, found := helper.GetPreferredConfigValue(cfg, "NagiosSpoolfile.Folder", []string{"Main.NagiosSpoolfileFolder"}) + if !found { + return nil, fmt.Errorf("Could not find a config value for Nagios Spoolfile Folder") + } + spoolDirectoryPtr, ok := search.(*string) + if ok { + spoolDirectory = *(spoolDirectoryPtr) + } else { + return nil, fmt.Errorf("Expected a *string value out of the config value for Nagios Spoolfile Folder") + } + + workerAmount := 0 + search, found = helper.GetPreferredConfigValue(cfg, "NagiosSpoolfile.WorkerCount", []string{"Main.NagiosSpoolfileWorker"}) + if !found { + return nil, fmt.Errorf("Could not find a config value for Nagios Spoolfile Worker Count") + } + workerAmountPtr, ok := search.(*int) + if ok { + workerAmount = *(workerAmountPtr) + } else { + return nil, fmt.Errorf("Expected a *int value out of the config value for Nagios Spoolfile Worker Count") + } + + perfdataLabelMaxLength := PerfdataLabelMaxLengthDefault + search, found = helper.GetPreferredConfigValue(cfg, "NagiosSpoolfile.PerfdataLabelMaxLength", []string{}) + if found { + perfdataLabelMaxLengthPtr, ok := search.(*int) + if ok { + perfdataLabelMaxLength = *(perfdataLabelMaxLengthPtr) + } else { + return nil, fmt.Errorf("Expected a *int value out of the config value for Nagios Spoolfile Perfdata Label Max Length") + } + } + + perfdataUOMMaxLength := PerfdataUOMMaxLengthDefault + search, found = helper.GetPreferredConfigValue(cfg, "NagiosSpoolfile.PerfdataUOMMaxLength", []string{}) + if found { + perfdataUOMMaxLengthPtr, ok := search.(*int) + if ok { + perfdataUOMMaxLength = *(perfdataUOMMaxLengthPtr) + } else { + return nil, fmt.Errorf("Expected a *int value out of the config value for Nagios Spoolfile Perfdata UOM Max Length") + } + } + + perfdataNumericValuesMaxLength := PerfdataNumericValuesMaxLengthDefault + search, found = helper.GetPreferredConfigValue(cfg, "NagiosSpoolfile.PerfdataNumericValuesMaxLength", []string{}) + if found { + perfdataNumericValuesMaxLengthPtr, ok := search.(*int) + if ok { + perfdataNumericValuesMaxLength = *(perfdataNumericValuesMaxLengthPtr) + } else { + return nil, fmt.Errorf("Expected a *int value out of the config value for Nagios Spoolfile Perfdata UOM Max Length") + } + } + + perfdataThresholdsMaxLength := PerfdataThresholdsMaxLengthDefault + search, found = helper.GetPreferredConfigValue(cfg, "NagiosSpoolfile.PerfdataThresholdsMaxLength", []string{}) + if found { + perfdataThresholdsMaxLengthPtr, ok := search.(*int) + if ok { + perfdataThresholdsMaxLength = *(perfdataThresholdsMaxLengthPtr) + } else { + return nil, fmt.Errorf("Expected a *int value out of the config value for Nagios Spoolfile Perfdata Thresholds Max Length") + } + } + s := &NagiosSpoolfileCollector{ quit: make(chan bool), jobs: make(chan string, 100), @@ -39,14 +123,14 @@ func NagiosSpoolfileCollectorFactory(spoolDirectory string, workerAmount int, re workers: make([]*NagiosSpoolfileWorker, workerAmount), } - gen := NagiosSpoolfileWorkerGenerator(s.jobs, results, livestatusCacheBuilder, fileBufferSize, defaultTarget) + gen := NagiosSpoolfileWorkerGenerator(s.jobs, results, livestatusCacheBuilder, fileBufferSize, defaultTarget, perfdataLabelMaxLength, perfdataUOMMaxLength, perfdataNumericValuesMaxLength, perfdataThresholdsMaxLength) for w := range workerAmount { s.workers[w] = gen() } go s.run() - return s + return s, nil } // Stop stops his workers and itself. diff --git a/pkg/nagflux/collector/spoolfile/nagiosSpoolfileWorker.go b/pkg/nagflux/collector/spoolfile/nagiosSpoolfileWorker.go index 4f3c8f0..a52169e 100644 --- a/pkg/nagflux/collector/spoolfile/nagiosSpoolfileWorker.go +++ b/pkg/nagflux/collector/spoolfile/nagiosSpoolfileWorker.go @@ -18,6 +18,8 @@ import ( "pkg/nagflux/helper" "pkg/nagflux/logging" "pkg/nagflux/statistics" + + "github.com/kdar/factorlog" ) const ( @@ -39,49 +41,115 @@ const ( ) var ( - checkMulitRegex = regexp.MustCompile(`^(.*::)(.*)`) - rangeRegex = regexp.MustCompile(`[\d\.\-]+`) - regexPerformancelable = regexp.MustCompile(`([^=]+)=(U|[\d\.,\-]+)([\pL\/%]*);?([\d\.,\-:~@]*)?;?([\d\.,\-:~@]*)?;?([\d\.,\-]*)?;?([\d\.,\-]*)?;?\s*`) - regexAltCommand = regexp.MustCompile(`.*\[([a-zA-Z_\-. ]+)\]\s?$`) - regexStripErrors = regexp.MustCompile(`\[[^\]]*=[^\]]*\]`) + // Start at the line, match anything that has two consecutive columns. + // First capture group is before the colon and the second is after the column. + checkMulitRegex = regexp.MustCompile(`^(.*::)(.*)`) + + // Digit, point or dash in a group, repeat this once or more + // This idea is to get how many numbers, possibly negative, are in a string + rangeRegex = regexp.MustCompile(`[\d\.\-]+`) + + // https://regex101.com/r/wNeesp/1 + // Read this as well if you are new to monitoring plugins output. + // https://www.monitoring-plugins.org/doc/guidelines.html#AEN197 + // https://www.monitoring-plugins.org/doc/guidelines.html#THRESHOLDFORMAT + // 1st Capture Group: ([^=]+) + // Anything without an '=' sign , at least one repeating + // Idea: It captures the name of the perfdata + // A literal '=' + // Required in a perfdata string, helps to capture anything before it as the name + // 2nd Capture Group: (U|[\d\.\,\-]+) + // There are two options here + // 1. Either a literal 'U'. + // Means "Unknown". This is used by plugins to indicate that it could not get performance data for some reason. + // Writing 'U' is better than not including it, which would mean its unavailable. + // 2. [\d\.,\-]+ + // '\d' is for digits, '\.' is a literal point, '\,' is a literal comma, '\-' is a literal dash i.e negative sign. Repat any of these one or more times. + // Idea: This captures the current value of the perfdata, which should be some kind of number, possibly negative as well. Examples: '123' '24.5' '-54,2' + // 3rd Capture Group: ([\pL\/\%]*) + // '\pL' matches any kind of letter in any language. '\/' matches a literal forward slash, '\%' matches a literal percentage sign. Repeat any of it zero or more times. + // Idea: This captures the Unit of Measurement for the current value. + // Might be empty since the raw value might be enough. Forward slash is used for rate. Examples: '' 's' 'ms' 'B' 'KB' '%' 'B/s' '/s' + // A literal ';'. Zero or Once. Semicolons are used as seperators between different fields in a perfdata. + // Idea: Perfdata might only have the current value, and does not report, warning, critical, min, max and other values. + // 4rd Capture Group: ([\d\.\,\-\:\~\@]*) + // Literal digits, point, comma, dash, colon, tilde, at sign. Colon and at sign is used in range definitions. Tilde is used when specifying ranges for negative infinity + // Repeat this capture group zero or one time. + // Idea: These are the threshold definitions for warning threshold. It does not have to be set + // A literal ';'. Zero or Once. Semicolons are used as seperators between different fields in a perfdata. + // 5th Capture Group: ([\d\.\,\-\:\~\@]*) + // Same as 4th capture group, but it is for critical threshold this time + // A literal ';'. Zero or Once. Semicolons are used as seperators between different fields in a perfdata. + // 6th Capture Group: ([\d\.\,\-]*) + // Similar to the 2nd capture group, but it might be repeated zero or more times instead, as this field may be empty + // Idea: Used for the min value so far. It does not need an Unit of Measurement or might be specified as a range like a threshold. Therefore it is simpler + // A literal ';'. Zero or Once. Semicolons are used as seperators between different fields in a perfdata. + // 7th Capture Group: ([\d\.\,\-]*) + // Same as 6th capture group, but it is for the maximum value this time. + // '\s' matches any whitespace character, infinite times. + // Idea: It seperates different perf data values as this must be matched new capture group can be captured + regexPerformancelable = regexp.MustCompile(`([^=]+)=(U|[\d\.\,\-]+)([\pL\/\%]*);?([\d\.\,\-\:\~\@]*)?;?([\d\.\,\-\:\~\@]*)?;?([\d\.\,\-]*)?;?([\d\.\,\-]*)?;?\s*`) + + // The perfdata part might have some alternative check at the end, recognize it by it being at the end and only containing letters, '_', '-' + // The check name will be in the capture group. + // This convention is not found in monitoring-plugins development guidelines + regexAlternativeCommand = regexp.MustCompile(`.*\[([a-zA-Z\_\-\.\ ]+)\]\s?$`) + + // The perfdata part might report errors for different data + // it has to put them in square brackets first, and use an equal sign for the error + // This is to differenciate it from alternative command, which does not have an equal sign. + // This convention is not found in monitoring-plugins development guidelines + regexStripErrors = regexp.MustCompile(`\[[^\]]*=[^\]]*\]`) +) + +var ( + log *factorlog.FactorLog = logging.GetLogger() ) // NagiosSpoolfileWorker parses the given spoolfiles and adds the extraced perfdata to the queue. type NagiosSpoolfileWorker struct { - workerID int - quit chan bool - jobs chan string - results collector.ResultQueues - livestatusCacheBuilder *livestatus.CacheBuilder - fileBufferSize int - defaultTarget collector.Filterable - filterProcessor filter.Processor + workerID int + quit chan bool + jobs chan string + results collector.ResultQueues + livestatusCacheBuilder *livestatus.CacheBuilder + fileBufferSize int + defaultTarget collector.Filterable + filterProcessor filter.Processor + perfdataLabelMaxSize int + perfdataUOMMaxLength int + perfdataNumericValuesMaxLength int + perfdataThresholdsMaxLength int } // NewNagiosSpoolfileWorker returns a new NagiosSpoolfileWorker. func NewNagiosSpoolfileWorker(workerID int, jobs chan string, results collector.ResultQueues, - livestatusCacheBuilder *livestatus.CacheBuilder, fileBufferSize int, defaultTarget collector.Filterable, + livestatusCacheBuilder *livestatus.CacheBuilder, fileBufferSize int, defaultTarget collector.Filterable, perfdataLabelMaxLength int, perfdataUOMMaxLength int, perfdataNumericValuesMaxLength int, perfdataThresholdsMaxLength int, ) *NagiosSpoolfileWorker { cfg := config.GetConfig() return &NagiosSpoolfileWorker{ - workerID: workerID, - quit: make(chan bool), - jobs: jobs, - results: results, - livestatusCacheBuilder: livestatusCacheBuilder, - fileBufferSize: fileBufferSize, - defaultTarget: defaultTarget, - filterProcessor: filter.NewFilter(cfg.Filter.SpoolFileLineTerms), + workerID: workerID, + quit: make(chan bool), + jobs: jobs, + results: results, + livestatusCacheBuilder: livestatusCacheBuilder, + fileBufferSize: fileBufferSize, + defaultTarget: defaultTarget, + filterProcessor: filter.NewFilter(cfg.Filter.SpoolFileLineTerms), + perfdataLabelMaxSize: perfdataLabelMaxLength, + perfdataUOMMaxLength: perfdataUOMMaxLength, + perfdataNumericValuesMaxLength: perfdataNumericValuesMaxLength, + perfdataThresholdsMaxLength: perfdataThresholdsMaxLength, } } // NagiosSpoolfileWorkerGenerator generates a worker and starts it. func NagiosSpoolfileWorkerGenerator(jobs chan string, results collector.ResultQueues, - livestatusCacheBuilder *livestatus.CacheBuilder, fileBufferSize int, defaultTarget collector.Filterable, + livestatusCacheBuilder *livestatus.CacheBuilder, fileBufferSize int, defaultTarget collector.Filterable, perfdataLabelMaxLength int, perfdataUOMMaxLength int, perfdataNumericValuesMaxLength int, perfdataThresholdsMaxLength int, ) func() *NagiosSpoolfileWorker { workerID := 0 return func() *NagiosSpoolfileWorker { - s := NewNagiosSpoolfileWorker(workerID, jobs, results, livestatusCacheBuilder, fileBufferSize, defaultTarget) + s := NewNagiosSpoolfileWorker(workerID, jobs, results, livestatusCacheBuilder, fileBufferSize, defaultTarget, perfdataLabelMaxLength, perfdataUOMMaxLength, perfdataNumericValuesMaxLength, perfdataThresholdsMaxLength) workerID++ go s.run() return s @@ -92,7 +160,7 @@ func NagiosSpoolfileWorkerGenerator(jobs chan string, results collector.ResultQu func (w *NagiosSpoolfileWorker) Stop() { w.quit <- true <-w.quit - logging.GetLogger().Debug("SpoolfileWorker stopped") + log.Debug("SpoolfileWorker stopped") } // Waits for files to parse and sends the data to the main queue. @@ -107,11 +175,11 @@ func (w *NagiosSpoolfileWorker) run() { case file = <-w.jobs: promServer.SpoolFilesInQueue.Set(float64(len(w.jobs))) startTime := time.Now() - logging.GetLogger().Debug("Reading file: ", file) + log.Debug("Reading file: ", file) filehandle, err := os.OpenFile(file, os.O_RDONLY, os.ModePerm) if err != nil { - logging.GetLogger().Warn("NagiosSpoolfileWorker: Opening file error: ", err) + log.Warn("NagiosSpoolfileWorker: Opening file error: ", err) break } reader := bufio.NewReaderSize(filehandle, w.fileBufferSize) @@ -120,7 +188,7 @@ func (w *NagiosSpoolfileWorker) run() { for err == nil && !isPrefix { splittedPerformanceData := helper.StringToMap(string(line), "\t", "::") if skipLine := w.filterProcessor.TestLine(line); !skipLine { - logging.GetLogger().Debugf("skipping line %s", string(line)) + log.Debugf("skipping line %s", string(line)) line, isPrefix, err = reader.ReadLine() continue @@ -134,22 +202,22 @@ func (w *NagiosSpoolfileWorker) run() { case r <- singlePerfdata: queries++ case <-time.After(time.Duration(10) * time.Second): - logging.GetLogger().Warn("NagiosSpoolfileWorker: Could not write to buffer") + log.Warn("NagiosSpoolfileWorker: Could not write to buffer") } } } line, isPrefix, err = reader.ReadLine() } if err != nil && err != io.EOF { - logging.GetLogger().Warn(err) + log.Warn(err) } if isPrefix { - logging.GetLogger().Warn("NagiosSpoolfileWorker: filebuffer is too small") + log.Warn("NagiosSpoolfileWorker: filebuffer is too small") } filehandle.Close() err = os.Remove(file) if err != nil { - logging.GetLogger().Warn(err) + log.Warn(err) } timeDiff := float64(time.Since(startTime).Nanoseconds() / 1000000) if timeDiff >= 0 { @@ -159,7 +227,7 @@ func (w *NagiosSpoolfileWorker) run() { promServer.SpoolFilesLines.Add(float64(queries)) } case <-time.After(time.Duration(5) * time.Minute): - logging.GetLogger().Debug("NagiosSpoolfileWorker: Got nothing to do") + log.Debug("NagiosSpoolfileWorker: Got nothing to do") } } } @@ -167,38 +235,54 @@ func (w *NagiosSpoolfileWorker) run() { // PerformanceDataIterator returns an iterator to loop over generated perf data. func (w *NagiosSpoolfileWorker) PerformanceDataIterator(input map[string]string) <-chan *PerformanceData { ch := make(chan *PerformanceData) - typ := findType(input) - if typ == "" { + dataType := findDataType(input) + if dataType == "" { if len(input) > 1 { - logging.GetLogger().Info("Line does not match the scheme: ", input) + log.Info("Line does not match the scheme: ", input) } close(ch) return ch } - currentCommand := w.searchAltCommand(input[typ+"PERFDATA"], input[typ+checkcommand]) + currentCommand := w.searchAlternativeCommand(input[dataType+"PERFDATA"], input[dataType+checkcommand]) currentTime := helper.CastStringTimeFromSToMs(input[timet]) currentService := "" - if typ != hostType { + + if dataType != hostType { currentService = input[servicedesc] } + // anonymous closure, starts immediately after definition in another goroutine without blocking go func() { - raw := input[typ+"PERFDATA"] - cleaned := regexStripErrors.ReplaceAllString(raw, "") - perfSlice := regexPerformancelable.FindAllStringSubmatch(cleaned, -1) + perdataString := input[dataType+"PERFDATA"] + cleaned := regexStripErrors.ReplaceAllString(perdataString, "") + + // Slices up the string into a form like this + // Each match is put into an array with their capture groups + // These arrays are put into another array + // Here is an example: + /* + [][]string len: 4, cap: 10, [ + ["rta=0.024ms;3000.000;5000.000;0; ","rta","0.024","ms","3000.000","5000.000","0",""], + ["rtmax=0.085ms;;;; ","rtmax","0.085","ms","","","",""], + ["rtmin=0.000ms;;;; ","rtmin","0.000","ms","","","",""], + ["pl=0%;80;100;0;100","pl","0","%","80","100","0","100"] + ] + */ + perfdataStringMatches := regexPerformancelable.FindAllStringSubmatch(cleaned, -1) currentCheckMultiLabel := "" + // try to find a check_multi prefix - if len(perfSlice) > 0 && len(perfSlice[0]) > 1 { - currentCheckMultiLabel = getCheckMultiRegexMatch(perfSlice[0][1]) + if len(perfdataStringMatches) > 0 && len(perfdataStringMatches[0]) > 1 { + currentCheckMultiLabel = getCheckMultiRegexMatch(perfdataStringMatches[0][1]) } - item: - for _, value := range perfSlice { + perfdataStringMatchLoop: + for _, perfdataStringMatch := range perfdataStringMatches { // Allows to add tags and fields to spoolfileentries - tag := map[string]string{} + tags := map[string]string{} if tagString, ok := input[nagfluxTags]; ok { - tag = helper.StringToMap(tagString, " ", "=") + tags = helper.StringToMap(tagString, " ", "=") } field := map[string]string{} if fieldString, ok := input[nagfluxField]; ok { @@ -216,9 +300,9 @@ func (w *NagiosSpoolfileWorker) PerformanceDataIterator(input map[string]string) Service: currentService, Command: currentCommand, Time: currentTime, - PerformanceLabel: value[1], - Unit: value[3], - Tags: tag, + PerformanceLabel: perfdataStringMatch[PerformanceDataSliceFields(Label)], + Unit: perfdataStringMatch[PerformanceDataSliceFields(UOM)], + Tags: tags, Fields: field, Filterable: target, } @@ -235,70 +319,110 @@ func (w *NagiosSpoolfileWorker) PerformanceDataIterator(input map[string]string) } } - for i, data := range value { - data = strings.ReplaceAll(data, ",", ".") - if i > 1 && i != 3 && data != "" { - performanceType, err := indexToperformanceType(i) - if err != nil { - logging.GetLogger().Warn(err, value) - continue - } + // perfdataStringMatch might not have all fields like perfdataStringMatch[Crit] available, + // iterate each field until the end + for i, data := range perfdataStringMatch { + fieldType, err := indexToPerformanceDataSliceField(i) + if err != nil { + log.Warnf("Error when converting the index to a known field in performance data : %s", err.Error()) + continue + } - // Add downtime tag if needed - if performanceType == "value" && w.livestatusCacheBuilder != nil && w.livestatusCacheBuilder.IsServiceInDowntime(perf.Hostname, perf.Service, input[timet]) { - perf.Tags["downtime"] = "true" + switch fieldType { + case RawMatch: + continue + case Label: + if len(data) > w.perfdataLabelMaxSize { + log.Warnf("Perfdata Label: '%s' is too long with length: %s and longer than the limit: %s. Probably an anomally. Skipping this perfdata item, Host: %v , Service: %v, Perfdata fields: %v", data, len(data), w.perfdataLabelMaxSize, perf.Hostname, perf.Service, perfdataStringMatch) + goto perfdataStringMatchLoop + } + continue + case UOM: + if len(data) > w.perfdataUOMMaxLength { + log.Warnf("Perfdata UOM: '%s' is too long with length: %s and longer than the limit: %s. Probably an anomally. Host: %v , Service: %v, Perfdata fields: %v", data, len(data), w.perfdataUOMMaxLength, perf.Hostname, perf.Service, perfdataStringMatch) + goto perfdataStringMatchLoop } + continue + case Value, Min, Max: + if len(data) > w.perfdataNumericValuesMaxLength { + log.Warnf("Perfdata field %s: '%s' is too long with length: %s and longer than the limit: %s. Probably an anomally. Host: %v , Service: %v, Perfdata fields: %v", fieldType.String(), data, len(data), w.perfdataNumericValuesMaxLength, perf.Hostname, perf.Service, perfdataStringMatch) + goto perfdataStringMatchLoop + } + continue + case Warn, Crit: + if len(data) > w.perfdataThresholdsMaxLength { + log.Warnf("Perfdata field %s: '%s' is too long with length: %s and longer than the limit: %s. Probably an anomally. Host: %v , Service: %v, Perfdata fields: %v", fieldType.String(), data, len(data), w.perfdataThresholdsMaxLength, perf.Hostname, perf.Service, perfdataStringMatch) + goto perfdataStringMatchLoop + } + continue + } - if performanceType == "warn" || performanceType == "crit" { - // Range handling - fillLabel := performanceType + "-fill" - rangeHits := rangeRegex.FindAllStringSubmatch(data, -1) - if len(rangeHits) == 1 { - perf.Tags[fillLabel] = "none" - perf.Fields[performanceType] = helper.StringIntToStringFloat(rangeHits[0][0]) - } else if len(rangeHits) == 2 { - // If there is a range with no infinity as border, create two points - if strings.Contains(data, "@") { - perf.Tags[fillLabel] = "inner" - } else { - perf.Tags[fillLabel] = "outer" - } - - for i, tag := range []string{"min", "max"} { - tagKey := fmt.Sprintf("%s-%s", performanceType, tag) - perf.Fields[tagKey] = helper.StringIntToStringFloat(rangeHits[i][0]) - } + if data == "" { + continue + } + + // Anything after here is a number or a range + // Convert all commas to points, to help in the integer/float parsing + data = strings.ReplaceAll(data, ",", ".") + + // Add downtime tag if needed + if fieldType == PerformanceDataSliceFields(Value) && w.livestatusCacheBuilder != nil && w.livestatusCacheBuilder.IsServiceInDowntime(perf.Hostname, perf.Service, input[timet]) { + perf.Tags["downtime"] = "true" + } + + switch fieldType { + case Warn, Crit: + // Range handling + fillLabel := fieldType.String() + "-fill" + // find how many numbers are there in the string, if there are two it is a range + rangeHits := rangeRegex.FindAllStringSubmatch(data, -1) + if len(rangeHits) == 1 { + perf.Tags[fillLabel] = "none" + perf.Fields[fieldType.String()] = helper.StringIntToStringFloat(rangeHits[0][0]) + } else if len(rangeHits) == 2 { + // If there is a range with no infinity as border, create two points + if strings.Contains(data, "@") { + perf.Tags[fillLabel] = "inner" } else { - logging.GetLogger().Warnf("Could not parse warn/crit value. Host: %v, Service: %v, Element: %v, Wholedata: %v", perf.Hostname, perf.Service, data, value) + perf.Tags[fillLabel] = "outer" } - } else { - if data == "U" { - perf.Fields["unknown"] = "true" - continue - } - if !helper.IsStringANumber(data) { - continue item + + for i, tag := range []string{"min", "max"} { + tagKey := fmt.Sprintf("%s-%s", rangeRegex.String, tag) + perf.Fields[tagKey] = helper.StringIntToStringFloat(rangeHits[i][0]) } - perf.Fields[performanceType] = helper.StringIntToStringFloat(data) + } else { + log.Warnf("String: '%s' in field '%s' could not be parsed. Host: %v, Service: %v, Perf Data Fields: %v", data, fieldType.String(), perf.Hostname, perf.Service, perfdataStringMatch) + } + case Value, Min, Max: + if data == "U" { + perf.Fields["unknown"] = "true" + continue } + if !helper.IsStringANumber(data) { + log.Warnf("String: '%s' in field '%s' is not a number, should be one. Host: %v, Service: %v, Perf Data Fields: %v", data, fieldType.String(), perf.Hostname, perf.Service, perfdataStringMatch) + continue perfdataStringMatchLoop + } + perf.Fields[fieldType.String()] = helper.StringIntToStringFloat(data) } } ch <- perf } close(ch) }() + return ch } -func getCheckMultiRegexMatch(perfData string) string { - regexResult := checkMulitRegex.FindAllStringSubmatch(perfData, -1) +func getCheckMultiRegexMatch(perfDataValueName string) string { + regexResult := checkMulitRegex.FindAllStringSubmatch(perfDataValueName, -1) if len(regexResult) == 1 && len(regexResult[0]) == 3 { return regexResult[0][1] } return "" } -func findType(input map[string]string) string { +func findDataType(input map[string]string) string { var typ string if isHostPerformanceData(input) { typ = hostType @@ -308,10 +432,10 @@ func findType(input map[string]string) string { return typ } -// searchAltCommand looks for alternative command name in perfdata -func (w *NagiosSpoolfileWorker) searchAltCommand(perfData, command string) string { +// searchAlternativeCommand looks for alternative command name in perfdata +func (w *NagiosSpoolfileWorker) searchAlternativeCommand(perfData, command string) string { result := command - search := regexAltCommand.FindAllStringSubmatch(perfData, 1) + search := regexAlternativeCommand.FindAllStringSubmatch(perfData, 1) if len(search) == 1 && len(search[0]) == 2 { result = search[0][1] } @@ -333,20 +457,59 @@ func isServicePerformanceData(input map[string]string) bool { return input["DATATYPE"] == servicePerfdata } -// Converts the index of the perftype to an string. -func indexToperformanceType(index int) (string, error) { +type PerformanceDataSliceFields int + +const ( + RawMatch PerformanceDataSliceFields = iota + Label + Value + UOM + Warn + Crit + Min + Max +) + +// Converts the index of the sliced perftype to an string. +func indexToPerformanceDataSliceField(index int) (PerformanceDataSliceFields, error) { switch index { + case 0: + return RawMatch, nil + case 1: + return Label, nil case 2: - return "value", nil + return Value, nil case 4: - return "warn", nil + return Warn, nil case 5: - return "crit", nil + return Crit, nil case 6: - return "min", nil + return Min, nil case 7: - return "max", nil + return Max, nil + default: + return 0, errors.New("Illegal index: " + strconv.Itoa(index)) + } +} + +// String returns the string representation of a PerformanceType +func (pt PerformanceDataSliceFields) String() string { + switch pt { + case RawMatch: + return "rawMatch" + case Label: + return "name" + case Value: + return "value" + case Warn: + return "warn" + case Crit: + return "crit" + case Min: + return "min" + case Max: + return "max" default: - return "", errors.New("Illegale index: " + strconv.Itoa(index)) + return "" } } diff --git a/pkg/nagflux/config/Config.go b/pkg/nagflux/config/Config.go index f623371..3c74054 100644 --- a/pkg/nagflux/config/Config.go +++ b/pkg/nagflux/config/Config.go @@ -70,7 +70,11 @@ type Config struct { // This option takes predence over Main.NagiosSpoolfileFolder if set Folder *string // This option takes predence over Main.NagiosSpoolfileWorker if set - WorkerCount *int + WorkerCount *int + PerfdataLabelMaxLength *int // Log errors and skip perfdata if perfdata label length is longer than this length + PerfdataUOMMaxLength *int // Log errors and skip perfdata if perfdata Unit of Measurement length is longer than this length + PerfdataNumericValuesMaxLength *int // Log errors and skip perfdata if perfdata current value, min or max strings are longer than this length + PerfdataThresholdsMaxLength *int // Log errors and skip perfdata if perfdata warn/crit threshold strings are longer than this length } NagfluxSpoolfile struct { Enabled *bool diff --git a/pkg/nagflux/helper/config_helper.go b/pkg/nagflux/helper/config_helper.go index 7eed945..9e937a9 100644 --- a/pkg/nagflux/helper/config_helper.go +++ b/pkg/nagflux/helper/config_helper.go @@ -7,13 +7,14 @@ import ( "pkg/nagflux/logging" ) -// Config parser tries to populate the Config structy type with values from config file -// If the Config has a field, but config file does not specify it, it will be default initialized -// If the Config has a field that is a pointer to a type +// Config parser tries to populate the Config struct with values from config file +// If the Config struct has a field, but config file does not specify it, it will be default initialized +// If the Config struct has a field that is a pointer to a type, there are two options // Option 1: Config file has it -> the pointer will point to an instance of that type // Option 2: Config file does not have it -> the pointer will be set to nil -// This way we can determine if something is explicitly set in the config -// But the type of that value has to be a pointer, like *bool or *string +// This way we can determine if something is explicitly set in the config or unspecified +// But the type of that value has to be a pointer, like *bool or *string. +// It cant be a primitive non-pointer type like int. Those will be default initialized // GetPreferredConfigValue retrieves a value from a struct using a dot-separated path. // It takes a primaryPath and other deprecatedPaths. If a value is found on the mainPath, it notifies the user about deprecatedPaths diff --git a/pkg/nagflux/nagflux.go b/pkg/nagflux/nagflux.go index 0a54ed4..ed1ed94 100644 --- a/pkg/nagflux/nagflux.go +++ b/pkg/nagflux/nagflux.go @@ -192,6 +192,7 @@ For further informations / bugs reports: https://github.com/ConSol-Monitoring/na } var nagiosCollector *spoolfile.NagiosSpoolfileCollector + var err error // nagios spoolfile collection is enabled by default nagiosSpoolFileCollectorEnabled := true if search, found := helper.GetPreferredConfigValue(cfg, "NagiosSpoolfile.Enabled", []string{}); found { @@ -202,45 +203,20 @@ For further informations / bugs reports: https://github.com/ConSol-Monitoring/na log.Warnf("Expected a *bool value out of the config value for Nagios Spoolfile Collection Enablement") } } + if nagiosSpoolFileCollectorEnabled { - spoolDirectoryString := "" - spoolDirectorySearch, spoolDirectoryFound := helper.GetPreferredConfigValue(cfg, "NagiosSpoolfile.Folder", []string{"Main.NagiosSpoolfileFolder"}) - if !spoolDirectoryFound { - log.Criticalf("Could not find a config value for Nagios Spoolfile Folder") - <-quit - } - spoolDirectoryPtr, ok := spoolDirectorySearch.(*string) - if ok { - spoolDirectoryString = *(spoolDirectoryPtr) - } else { - log.Warnf("Expected a *string value out of the config value for Nagios Spoolfile Folder") - } + nagiosCollector, err = spoolfile.NagiosSpoolfileCollectorFactory( + cfg, + resultQueues, + livestatusCache, + cfg.Main.FileBufferSize, + collector.Filterable{Filter: cfg.Main.DefaultTarget}, + ) - workerCountInt := 0 - workerCountSearch, workerCountFound := helper.GetPreferredConfigValue(cfg, "NagiosSpoolfile.WorkerCount", []string{"Main.NagiosSpoolfileWorker"}) - if !workerCountFound { - log.Criticalf("Could not find a config value for Nagios Spoolfile Worker Count") + if err != nil { + log.Criticalf("Error when setting up NagiosSpoolfileCollectorFactory: %s", err.Error()) <-quit } - workerCountPtr, ok := workerCountSearch.(*int) - if ok { - workerCountInt = *(workerCountPtr) - } else { - log.Warnf("Expected a *int value out of the config value for Nagios Spoolfile Worker Count") - } - - if spoolDirectoryFound && workerCountFound { - log.Info("Nagios Spoolfile Directory: ", spoolDirectoryString) - log.Info("Nagios Spoolfile Worker Count: ", workerCountInt) - nagiosCollector = spoolfile.NagiosSpoolfileCollectorFactory( - spoolDirectoryString, - workerCountInt, - resultQueues, - livestatusCache, - cfg.Main.FileBufferSize, - collector.Filterable{Filter: cfg.Main.DefaultTarget}, - ) - } } // nagflux spoolfile collection is enabled by default From 4b9a39c5145f3f46d4cc392efe2ff67e16b3a2bf Mon Sep 17 00:00:00 2001 From: Ahmet Oeztuerk Date: Fri, 6 Mar 2026 17:58:05 +0100 Subject: [PATCH 02/11] fix package structure root go.mod file was replacing pkg/nagflux with the local path, and /pkg/nagflux was then defining its own go.mod. this caused problems with vendoring. had to use go mod vendor everytime after making changes. simplify package structure by just having one go.mod at the project root: github.com/ConSol-Monitoring/nagflux --- cmd/nagflux/main.go | 4 +- go.mod | 20 ++-- go.sum | 46 +++++++- pkg/nagflux/collector/ResultQueues.go | 2 +- pkg/nagflux/collector/SimplePrintable.go | 2 +- .../collector/livestatus/CacheBuilder.go | 4 +- .../collector/livestatus/CacheBuilder_test.go | 2 +- pkg/nagflux/collector/livestatus/Collector.go | 12 +- .../collector/livestatus/Collector_test.go | 4 +- .../collector/livestatus/CommentData.go | 6 +- .../collector/livestatus/CommentData_test.go | 4 +- .../collector/livestatus/Connector_test.go | 4 +- pkg/nagflux/collector/livestatus/Data.go | 4 +- pkg/nagflux/collector/livestatus/Data_test.go | 2 +- .../collector/livestatus/DowntimeData.go | 6 +- .../collector/livestatus/DowntimeData_test.go | 4 +- .../collector/livestatus/NotificationData.go | 6 +- .../livestatus/NotificationData_test.go | 4 +- .../collector/modgearman/gearmanWorker.go | 16 +-- .../collector/nagflux/NagfluxPrintable.go | 4 +- .../collector/nagflux/dumpfileCollector.go | 6 +- .../collector/nagflux/nagfluxFileCollector.go | 10 +- .../spoolfile/nagiosSpoolfileCollector.go | 12 +- .../spoolfile/nagiosSpoolfileWorker.go | 14 +-- .../spoolfile/nagiosSpoolfileWorker_test.go | 6 +- .../collector/spoolfile/performanceData.go | 6 +- pkg/nagflux/config/GlobalObjects.go | 2 +- pkg/nagflux/config/GlobalObjects_test.go | 2 +- pkg/nagflux/filter/Filter.go | 2 +- pkg/nagflux/filter/Filter_test.go | 4 +- pkg/nagflux/go.mod | 36 ------ pkg/nagflux/go.sum | 110 ------------------ pkg/nagflux/helper/config_helper.go | 2 +- pkg/nagflux/helper/elastic.go | 2 +- pkg/nagflux/helper/elastic_test.go | 2 +- pkg/nagflux/helper/influx.go | 2 +- pkg/nagflux/helper/influx_test.go | 2 +- pkg/nagflux/helper/string.go | 2 +- pkg/nagflux/nagflux.go | 26 ++--- pkg/nagflux/nagflux_test.go | 2 +- pkg/nagflux/statistics/prometheus.go | 4 +- pkg/nagflux/target/elasticsearch/Connector.go | 8 +- pkg/nagflux/target/elasticsearch/Worker.go | 8 +- pkg/nagflux/target/file/jsontarget/Worker.go | 4 +- pkg/nagflux/target/influx/Connector.go | 10 +- pkg/nagflux/target/influx/Worker.go | 12 +- 46 files changed, 175 insertions(+), 277 deletions(-) delete mode 100644 pkg/nagflux/go.mod delete mode 100644 pkg/nagflux/go.sum diff --git a/cmd/nagflux/main.go b/cmd/nagflux/main.go index 66d9b9b..34b3551 100644 --- a/cmd/nagflux/main.go +++ b/cmd/nagflux/main.go @@ -1,8 +1,6 @@ package main -import ( - "pkg/nagflux" -) +import "github.com/ConSol-Monitoring/nagflux/pkg/nagflux" // Build contains the current git commit id // compile passing -ldflags "-X main.Build " to set the id. diff --git a/go.mod b/go.mod index e61737c..2e345cb 100644 --- a/go.mod +++ b/go.mod @@ -2,28 +2,32 @@ module github.com/ConSol-Monitoring/nagflux go 1.25.7 -replace pkg/nagflux => ./pkg/nagflux - -require pkg/nagflux v0.0.0-00010101000000-000000000000 +require ( + github.com/appscode/g2 v0.0.0-20190123131438-388ba74fd273 + github.com/kdar/factorlog v0.0.0-20211012144011-6ea75a169038 + github.com/prometheus/client_golang v1.23.2 + github.com/stretchr/testify v1.11.1 + gopkg.in/gcfg.v1 v1.2.3 +) require ( - github.com/appscode/g2 v0.0.0-20190123131438-388ba74fd273 // indirect + github.com/appscode/go v0.0.0-20201105063637-5613f3b8169f // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect - github.com/golang/glog v1.2.1 // indirect - github.com/kdar/factorlog v0.0.0-20211012144011-6ea75a169038 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/kr/text v0.2.0 // indirect github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect - github.com/prometheus/client_golang v1.23.2 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_model v0.6.2 // indirect github.com/prometheus/common v0.67.4 // indirect github.com/prometheus/procfs v0.19.2 // indirect go.yaml.in/yaml/v2 v2.4.3 // indirect golang.org/x/sys v0.38.0 // indirect google.golang.org/protobuf v1.36.10 // indirect - gopkg.in/gcfg.v1 v1.2.3 // indirect gopkg.in/robfig/cron.v2 v2.0.0-20150107220207-be2e0b0deed5 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 2204d5d..7a691fb 100644 --- a/go.sum +++ b/go.sum @@ -2,18 +2,34 @@ github.com/appscode/g2 v0.0.0-20190123131438-388ba74fd273 h1:Jweb6qie+w0ybSXG9jr github.com/appscode/g2 v0.0.0-20190123131438-388ba74fd273/go.mod h1:FseN9KxcgJsFW92Y7JhTk5qWF0KBfwy2t8WfKL6t+hQ= github.com/appscode/go v0.0.0-20201105063637-5613f3b8169f h1:heDuWjdnY2rJIgLwIQjWPgOc0BUWWX6OGOeB+0t8v/s= github.com/appscode/go v0.0.0-20201105063637-5613f3b8169f/go.mod h1:piHRpQ9+NTTuV3V98INxjU7o2KlAJMznaxvB6wHKkfU= +github.com/beevik/ntp v0.3.0/go.mod h1:hIHWr+l3+/clUnF44zdK+CWW7fO8dR5cIylAQ76NRpg= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/cenkalti/backoff v2.1.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcjuz89kmFXt9morQgcfYZAYZ5n8WHjt81YYWIwtTM= +github.com/codeskyblue/go-sh v0.0.0-20200712050446-30169cf553fe/go.mod h1:VQx0hjo2oUeQkQUET7wRwradO6f+fN5jzXgB/zROxxE= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/golang/glog v1.2.1 h1:OptwRhECazUx5ix5TTWC3EZhsZEHWcYWY4FQHTIubm4= -github.com/golang/glog v1.2.1/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= +github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= +github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= +github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/howeyc/gopass v0.0.0-20170109162249-bf9dde6d0d2c/go.mod h1:lADxMC39cJJqL93Duh1xhAs4I2Zs8mKS89XWXFGp9cs= +github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/kdar/factorlog v0.0.0-20211012144011-6ea75a169038 h1:ah2n2FwhELUb5o+KV0zAw8izxYC6UdK6dzjOKr3hfA8= github.com/kdar/factorlog v0.0.0-20211012144011-6ea75a169038/go.mod h1:vLeQHWaOMUQZ1ytnCskhwI5fCcXA7xxK0QjCngYPqbo= github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo= @@ -24,14 +40,20 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= +github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQE9x6ikvDFZS2mDVS3drnohI= github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/moul/http2curl v1.0.0/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h0RJWRi/o0o= @@ -44,15 +66,33 @@ github.com/prometheus/procfs v0.19.2 h1:zUMhqEW66Ex7OXIiDkll3tl9a1ZdilUOd/F6ZXw4 github.com/prometheus/procfs v0.19.2/go.mod h1:M0aotyiemPhBCM0z5w87kL22CxfcH05ZpYlu+b4J7mw= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= +github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= +github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.yaml.in/yaml/v2 v2.4.3 h1:6gvOSjQoTB3vt1l+CU+tSyi/HOjfOjRLJ4YwYZGwRO0= go.yaml.in/yaml/v2 v2.4.3/go.mod h1:zSxWcmIDjOzPXpjlTTbAsKokqkDNAVtZO0WOMiT90s8= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190422183909-d864b10871cd/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc= golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +gomodules.xyz/password-generator v0.2.4/go.mod h1:TvwYYTx9+P1pPwKQKfZgB/wr2Id9MqAQ3B5auY7reNg= +gomodules.xyz/version v0.1.0/go.mod h1:Y8xuV02mL/45psyPKG3NCVOwvAOy6T5Kx0l3rCjKSjU= google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -64,5 +104,7 @@ gopkg.in/robfig/cron.v2 v2.0.0-20150107220207-be2e0b0deed5 h1:E846t8CnR+lv5nE+Vu gopkg.in/robfig/cron.v2 v2.0.0-20150107220207-be2e0b0deed5/go.mod h1:hiOFpYm0ZJbusNj2ywpbrXowU3G8U6GIQzqn2mw1UIE= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/pkg/nagflux/collector/ResultQueues.go b/pkg/nagflux/collector/ResultQueues.go index b878413..c2ebd1d 100644 --- a/pkg/nagflux/collector/ResultQueues.go +++ b/pkg/nagflux/collector/ResultQueues.go @@ -1,5 +1,5 @@ package collector -import "pkg/nagflux/data" +import "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/data" type ResultQueues map[data.Target]chan Printable diff --git a/pkg/nagflux/collector/SimplePrintable.go b/pkg/nagflux/collector/SimplePrintable.go index 62fefb1..10ac556 100644 --- a/pkg/nagflux/collector/SimplePrintable.go +++ b/pkg/nagflux/collector/SimplePrintable.go @@ -1,6 +1,6 @@ package collector -import "pkg/nagflux/data" +import "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/data" // SimplePrintable can be used to send strings as printable type SimplePrintable struct { diff --git a/pkg/nagflux/collector/livestatus/CacheBuilder.go b/pkg/nagflux/collector/livestatus/CacheBuilder.go index cc412f5..df2cba0 100644 --- a/pkg/nagflux/collector/livestatus/CacheBuilder.go +++ b/pkg/nagflux/collector/livestatus/CacheBuilder.go @@ -6,8 +6,8 @@ import ( "sync" "time" - "pkg/nagflux/config" - "pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" "github.com/kdar/factorlog" ) diff --git a/pkg/nagflux/collector/livestatus/CacheBuilder_test.go b/pkg/nagflux/collector/livestatus/CacheBuilder_test.go index 320ef6a..eb1c5fe 100644 --- a/pkg/nagflux/collector/livestatus/CacheBuilder_test.go +++ b/pkg/nagflux/collector/livestatus/CacheBuilder_test.go @@ -4,7 +4,7 @@ import ( "testing" "time" - "pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/pkg/nagflux/collector/livestatus/Collector.go b/pkg/nagflux/collector/livestatus/Collector.go index 0411e60..24e48f1 100644 --- a/pkg/nagflux/collector/livestatus/Collector.go +++ b/pkg/nagflux/collector/livestatus/Collector.go @@ -6,12 +6,12 @@ import ( "strings" "time" - "pkg/nagflux/collector" - "pkg/nagflux/config" - "pkg/nagflux/data" - "pkg/nagflux/filter" - "pkg/nagflux/helper" - "pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/data" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/filter" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" "github.com/kdar/factorlog" ) diff --git a/pkg/nagflux/collector/livestatus/Collector_test.go b/pkg/nagflux/collector/livestatus/Collector_test.go index b57ea11..606d318 100644 --- a/pkg/nagflux/collector/livestatus/Collector_test.go +++ b/pkg/nagflux/collector/livestatus/Collector_test.go @@ -5,8 +5,8 @@ import ( "testing" "time" - "pkg/nagflux/collector" - "pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" ) func TestNewLivestatusCollector(t *testing.T) { diff --git a/pkg/nagflux/collector/livestatus/CommentData.go b/pkg/nagflux/collector/livestatus/CommentData.go index cfd03a5..9b288dd 100644 --- a/pkg/nagflux/collector/livestatus/CommentData.go +++ b/pkg/nagflux/collector/livestatus/CommentData.go @@ -1,9 +1,9 @@ package livestatus import ( - "pkg/nagflux/collector" - "pkg/nagflux/helper" - "pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" ) // CommentData adds Comments types to the livestatus data diff --git a/pkg/nagflux/collector/livestatus/CommentData_test.go b/pkg/nagflux/collector/livestatus/CommentData_test.go index 153c849..69e1814 100644 --- a/pkg/nagflux/collector/livestatus/CommentData_test.go +++ b/pkg/nagflux/collector/livestatus/CommentData_test.go @@ -3,8 +3,8 @@ package livestatus import ( "testing" - "pkg/nagflux/config" - "pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" ) var PrintCommentData = []struct { diff --git a/pkg/nagflux/collector/livestatus/Connector_test.go b/pkg/nagflux/collector/livestatus/Connector_test.go index ec2c931..991fb9e 100644 --- a/pkg/nagflux/collector/livestatus/Connector_test.go +++ b/pkg/nagflux/collector/livestatus/Connector_test.go @@ -9,8 +9,8 @@ import ( "testing" "time" - "pkg/nagflux/helper" - "pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" "github.com/stretchr/testify/assert" ) diff --git a/pkg/nagflux/collector/livestatus/Data.go b/pkg/nagflux/collector/livestatus/Data.go index 5e02869..edc2b36 100644 --- a/pkg/nagflux/collector/livestatus/Data.go +++ b/pkg/nagflux/collector/livestatus/Data.go @@ -4,8 +4,8 @@ import ( "fmt" "strings" - "pkg/nagflux/config" - "pkg/nagflux/helper" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" ) // Data contains basic data extracted from livestatusqueries. diff --git a/pkg/nagflux/collector/livestatus/Data_test.go b/pkg/nagflux/collector/livestatus/Data_test.go index f67e400..142bb48 100644 --- a/pkg/nagflux/collector/livestatus/Data_test.go +++ b/pkg/nagflux/collector/livestatus/Data_test.go @@ -5,7 +5,7 @@ import ( "reflect" "testing" - "pkg/nagflux/helper" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" ) func TestDataSanitizeValues(t *testing.T) { diff --git a/pkg/nagflux/collector/livestatus/DowntimeData.go b/pkg/nagflux/collector/livestatus/DowntimeData.go index 7bebc90..8c8d783 100644 --- a/pkg/nagflux/collector/livestatus/DowntimeData.go +++ b/pkg/nagflux/collector/livestatus/DowntimeData.go @@ -4,9 +4,9 @@ import ( "fmt" "strings" - "pkg/nagflux/collector" - "pkg/nagflux/helper" - "pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" ) // DowntimeData adds Comments types to the livestatus data diff --git a/pkg/nagflux/collector/livestatus/DowntimeData_test.go b/pkg/nagflux/collector/livestatus/DowntimeData_test.go index 48e907f..04738c1 100644 --- a/pkg/nagflux/collector/livestatus/DowntimeData_test.go +++ b/pkg/nagflux/collector/livestatus/DowntimeData_test.go @@ -3,8 +3,8 @@ package livestatus import ( "testing" - "pkg/nagflux/config" - "pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" "github.com/stretchr/testify/assert" ) diff --git a/pkg/nagflux/collector/livestatus/NotificationData.go b/pkg/nagflux/collector/livestatus/NotificationData.go index 53a9ba0..16e1279 100644 --- a/pkg/nagflux/collector/livestatus/NotificationData.go +++ b/pkg/nagflux/collector/livestatus/NotificationData.go @@ -4,9 +4,9 @@ import ( "fmt" "strings" - "pkg/nagflux/collector" - "pkg/nagflux/helper" - "pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" ) // NotificationData adds notification types to the livestatus data diff --git a/pkg/nagflux/collector/livestatus/NotificationData_test.go b/pkg/nagflux/collector/livestatus/NotificationData_test.go index 3b82434..444ff6b 100644 --- a/pkg/nagflux/collector/livestatus/NotificationData_test.go +++ b/pkg/nagflux/collector/livestatus/NotificationData_test.go @@ -3,8 +3,8 @@ package livestatus import ( "testing" - "pkg/nagflux/config" - "pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" ) func TestSanitizeValuesNotification(t *testing.T) { diff --git a/pkg/nagflux/collector/modgearman/gearmanWorker.go b/pkg/nagflux/collector/modgearman/gearmanWorker.go index 2632b55..24b01e0 100644 --- a/pkg/nagflux/collector/modgearman/gearmanWorker.go +++ b/pkg/nagflux/collector/modgearman/gearmanWorker.go @@ -4,14 +4,14 @@ import ( "fmt" "time" - "pkg/nagflux/collector" - "pkg/nagflux/collector/livestatus" - "pkg/nagflux/collector/spoolfile" - "pkg/nagflux/config" - "pkg/nagflux/filter" - "pkg/nagflux/helper" - "pkg/nagflux/helper/cryptohelper" - "pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector/livestatus" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector/spoolfile" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/filter" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper/cryptohelper" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" libworker "github.com/appscode/g2/worker" "github.com/kdar/factorlog" diff --git a/pkg/nagflux/collector/nagflux/NagfluxPrintable.go b/pkg/nagflux/collector/nagflux/NagfluxPrintable.go index 5e0ca66..cf76ba6 100644 --- a/pkg/nagflux/collector/nagflux/NagfluxPrintable.go +++ b/pkg/nagflux/collector/nagflux/NagfluxPrintable.go @@ -3,8 +3,8 @@ package nagflux import ( "fmt" - "pkg/nagflux/collector" - "pkg/nagflux/helper" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" ) // Printable converts from nagfluxfile format to X diff --git a/pkg/nagflux/collector/nagflux/dumpfileCollector.go b/pkg/nagflux/collector/nagflux/dumpfileCollector.go index f0960aa..81474d6 100644 --- a/pkg/nagflux/collector/nagflux/dumpfileCollector.go +++ b/pkg/nagflux/collector/nagflux/dumpfileCollector.go @@ -8,9 +8,9 @@ import ( "os" "time" - "pkg/nagflux/collector" - "pkg/nagflux/data" - "pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/data" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" "github.com/kdar/factorlog" ) diff --git a/pkg/nagflux/collector/nagflux/nagfluxFileCollector.go b/pkg/nagflux/collector/nagflux/nagfluxFileCollector.go index 64c2924..096de1c 100644 --- a/pkg/nagflux/collector/nagflux/nagfluxFileCollector.go +++ b/pkg/nagflux/collector/nagflux/nagfluxFileCollector.go @@ -5,11 +5,11 @@ import ( "os" "time" - "pkg/nagflux/collector" - "pkg/nagflux/collector/spoolfile" - "pkg/nagflux/config" - "pkg/nagflux/helper" - "pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector/spoolfile" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" "github.com/kdar/factorlog" ) diff --git a/pkg/nagflux/collector/spoolfile/nagiosSpoolfileCollector.go b/pkg/nagflux/collector/spoolfile/nagiosSpoolfileCollector.go index 0d04f94..e7d10a8 100644 --- a/pkg/nagflux/collector/spoolfile/nagiosSpoolfileCollector.go +++ b/pkg/nagflux/collector/spoolfile/nagiosSpoolfileCollector.go @@ -2,16 +2,16 @@ package spoolfile import ( "fmt" - "nagflux/helper" "os" "path" "time" - "pkg/nagflux/collector" - "pkg/nagflux/collector/livestatus" - "pkg/nagflux/config" - "pkg/nagflux/logging" - "pkg/nagflux/statistics" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector/livestatus" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/statistics" ) const ( diff --git a/pkg/nagflux/collector/spoolfile/nagiosSpoolfileWorker.go b/pkg/nagflux/collector/spoolfile/nagiosSpoolfileWorker.go index a52169e..18046aa 100644 --- a/pkg/nagflux/collector/spoolfile/nagiosSpoolfileWorker.go +++ b/pkg/nagflux/collector/spoolfile/nagiosSpoolfileWorker.go @@ -11,13 +11,13 @@ import ( "strings" "time" - "pkg/nagflux/collector" - "pkg/nagflux/collector/livestatus" - "pkg/nagflux/config" - "pkg/nagflux/filter" - "pkg/nagflux/helper" - "pkg/nagflux/logging" - "pkg/nagflux/statistics" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector/livestatus" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/filter" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/statistics" "github.com/kdar/factorlog" ) diff --git a/pkg/nagflux/collector/spoolfile/nagiosSpoolfileWorker_test.go b/pkg/nagflux/collector/spoolfile/nagiosSpoolfileWorker_test.go index 0a736d5..cb1b486 100644 --- a/pkg/nagflux/collector/spoolfile/nagiosSpoolfileWorker_test.go +++ b/pkg/nagflux/collector/spoolfile/nagiosSpoolfileWorker_test.go @@ -3,9 +3,9 @@ package spoolfile import ( "testing" - "pkg/nagflux/collector" - "pkg/nagflux/config" - "pkg/nagflux/helper" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" "github.com/stretchr/testify/assert" ) diff --git a/pkg/nagflux/collector/spoolfile/performanceData.go b/pkg/nagflux/collector/spoolfile/performanceData.go index 7478dff..64954cb 100644 --- a/pkg/nagflux/collector/spoolfile/performanceData.go +++ b/pkg/nagflux/collector/spoolfile/performanceData.go @@ -3,9 +3,9 @@ package spoolfile import ( "fmt" - "pkg/nagflux/collector" - "pkg/nagflux/config" - "pkg/nagflux/helper" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" ) // PerformanceData represents the nagios perfdata diff --git a/pkg/nagflux/config/GlobalObjects.go b/pkg/nagflux/config/GlobalObjects.go index c704dc8..6d6b4ae 100644 --- a/pkg/nagflux/config/GlobalObjects.go +++ b/pkg/nagflux/config/GlobalObjects.go @@ -3,7 +3,7 @@ package config import ( "sync" - "pkg/nagflux/data" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/data" ) // PauseMap is a map to store if an target requested pause or not diff --git a/pkg/nagflux/config/GlobalObjects_test.go b/pkg/nagflux/config/GlobalObjects_test.go index d13447f..7dd4298 100644 --- a/pkg/nagflux/config/GlobalObjects_test.go +++ b/pkg/nagflux/config/GlobalObjects_test.go @@ -3,7 +3,7 @@ package config import ( "testing" - "pkg/nagflux/data" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/data" ) func TestStoreValue(t *testing.T) { diff --git a/pkg/nagflux/filter/Filter.go b/pkg/nagflux/filter/Filter.go index cf54f30..b88e856 100644 --- a/pkg/nagflux/filter/Filter.go +++ b/pkg/nagflux/filter/Filter.go @@ -5,7 +5,7 @@ import ( "strings" "sync" - "pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" ) type Processor struct { diff --git a/pkg/nagflux/filter/Filter_test.go b/pkg/nagflux/filter/Filter_test.go index 6634ed1..40cde08 100644 --- a/pkg/nagflux/filter/Filter_test.go +++ b/pkg/nagflux/filter/Filter_test.go @@ -3,8 +3,8 @@ package filter import ( "testing" - "pkg/nagflux/config" - "pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" "github.com/stretchr/testify/assert" ) diff --git a/pkg/nagflux/go.mod b/pkg/nagflux/go.mod deleted file mode 100644 index 40f2400..0000000 --- a/pkg/nagflux/go.mod +++ /dev/null @@ -1,36 +0,0 @@ -module nagflux - -go 1.25.7 - -replace pkg/nagflux => . - -require ( - github.com/appscode/g2 v0.0.0-20190123131438-388ba74fd273 - github.com/kdar/factorlog v0.0.0-20211012144011-6ea75a169038 - github.com/prometheus/client_golang v1.23.2 - github.com/stretchr/testify v1.11.1 - gopkg.in/gcfg.v1 v1.2.3 - pkg/nagflux v0.0.0-00010101000000-000000000000 -) - -require ( - github.com/appscode/go v0.0.0-20201105063637-5613f3b8169f // indirect - github.com/beorn7/perks v1.0.1 // indirect - github.com/cespare/xxhash/v2 v2.3.0 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/kr/text v0.2.0 // indirect - github.com/mattn/go-colorable v0.1.14 // indirect - github.com/mattn/go-isatty v0.0.20 // indirect - github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect - github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/prometheus/client_model v0.6.2 // indirect - github.com/prometheus/common v0.67.4 // indirect - github.com/prometheus/procfs v0.19.2 // indirect - go.yaml.in/yaml/v2 v2.4.3 // indirect - golang.org/x/sys v0.38.0 // indirect - google.golang.org/protobuf v1.36.10 // indirect - gopkg.in/robfig/cron.v2 v2.0.0-20150107220207-be2e0b0deed5 // indirect - gopkg.in/warnings.v0 v0.1.2 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect -) diff --git a/pkg/nagflux/go.sum b/pkg/nagflux/go.sum deleted file mode 100644 index 492b0a4..0000000 --- a/pkg/nagflux/go.sum +++ /dev/null @@ -1,110 +0,0 @@ -github.com/appscode/g2 v0.0.0-20190123131438-388ba74fd273 h1:Jweb6qie+w0ybSXG9jrfQHCIoXSEHeoU/Sa1opJj22s= -github.com/appscode/g2 v0.0.0-20190123131438-388ba74fd273/go.mod h1:FseN9KxcgJsFW92Y7JhTk5qWF0KBfwy2t8WfKL6t+hQ= -github.com/appscode/go v0.0.0-20201105063637-5613f3b8169f h1:heDuWjdnY2rJIgLwIQjWPgOc0BUWWX6OGOeB+0t8v/s= -github.com/appscode/go v0.0.0-20201105063637-5613f3b8169f/go.mod h1:piHRpQ9+NTTuV3V98INxjU7o2KlAJMznaxvB6wHKkfU= -github.com/beevik/ntp v0.3.0/go.mod h1:hIHWr+l3+/clUnF44zdK+CWW7fO8dR5cIylAQ76NRpg= -github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= -github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/cenkalti/backoff v2.1.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= -github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= -github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcjuz89kmFXt9morQgcfYZAYZ5n8WHjt81YYWIwtTM= -github.com/codeskyblue/go-sh v0.0.0-20200712050446-30169cf553fe/go.mod h1:VQx0hjo2oUeQkQUET7wRwradO6f+fN5jzXgB/zROxxE= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= -github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= -github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/howeyc/gopass v0.0.0-20170109162249-bf9dde6d0d2c/go.mod h1:lADxMC39cJJqL93Duh1xhAs4I2Zs8mKS89XWXFGp9cs= -github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= -github.com/kdar/factorlog v0.0.0-20211012144011-6ea75a169038 h1:ah2n2FwhELUb5o+KV0zAw8izxYC6UdK6dzjOKr3hfA8= -github.com/kdar/factorlog v0.0.0-20211012144011-6ea75a169038/go.mod h1:vLeQHWaOMUQZ1ytnCskhwI5fCcXA7xxK0QjCngYPqbo= -github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co= -github.com/klauspost/compress v1.18.1/go.mod h1:ZQFFVG+MdnR0P+l6wpXgIL4NTtwiKIdBnrBd8Nrxr+0= -github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= -github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= -github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= -github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= -github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= -github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQE9x6ikvDFZS2mDVS3drnohI= -github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/moul/http2curl v1.0.0/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ= -github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= -github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h0RJWRi/o0o= -github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg= -github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk= -github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE= -github.com/prometheus/common v0.67.4 h1:yR3NqWO1/UyO1w2PhUvXlGQs/PtFmoveVO0KZ4+Lvsc= -github.com/prometheus/common v0.67.4/go.mod h1:gP0fq6YjjNCLssJCQp0yk4M8W6ikLURwkdd/YKtTbyI= -github.com/prometheus/procfs v0.19.2 h1:zUMhqEW66Ex7OXIiDkll3tl9a1ZdilUOd/F6ZXw4Vws= -github.com/prometheus/procfs v0.19.2/go.mod h1:M0aotyiemPhBCM0z5w87kL22CxfcH05ZpYlu+b4J7mw= -github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= -github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= -github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= -github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= -github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= -github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= -github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= -go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= -go.yaml.in/yaml/v2 v2.4.3 h1:6gvOSjQoTB3vt1l+CU+tSyi/HOjfOjRLJ4YwYZGwRO0= -go.yaml.in/yaml/v2 v2.4.3/go.mod h1:zSxWcmIDjOzPXpjlTTbAsKokqkDNAVtZO0WOMiT90s8= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190422183909-d864b10871cd/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc= -golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -gomodules.xyz/password-generator v0.2.4/go.mod h1:TvwYYTx9+P1pPwKQKfZgB/wr2Id9MqAQ3B5auY7reNg= -gomodules.xyz/version v0.1.0/go.mod h1:Y8xuV02mL/45psyPKG3NCVOwvAOy6T5Kx0l3rCjKSjU= -google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= -google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/gcfg.v1 v1.2.3 h1:m8OOJ4ccYHnx2f4gQwpno8nAX5OGOh7RLaaz0pj3Ogs= -gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= -gopkg.in/robfig/cron.v2 v2.0.0-20150107220207-be2e0b0deed5 h1:E846t8CnR+lv5nE+VuiKTDG/v1U2stad0QzddfJC7kY= -gopkg.in/robfig/cron.v2 v2.0.0-20150107220207-be2e0b0deed5/go.mod h1:hiOFpYm0ZJbusNj2ywpbrXowU3G8U6GIQzqn2mw1UIE= -gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= -gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/pkg/nagflux/helper/config_helper.go b/pkg/nagflux/helper/config_helper.go index 9e937a9..38dd180 100644 --- a/pkg/nagflux/helper/config_helper.go +++ b/pkg/nagflux/helper/config_helper.go @@ -4,7 +4,7 @@ import ( "reflect" "strings" - "pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" ) // Config parser tries to populate the Config struct with values from config file diff --git a/pkg/nagflux/helper/elastic.go b/pkg/nagflux/helper/elastic.go index 45a0b3a..9669ec0 100644 --- a/pkg/nagflux/helper/elastic.go +++ b/pkg/nagflux/helper/elastic.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "pkg/nagflux/config" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" ) // CreateJSONFromStringMap creates a part of a JSON object diff --git a/pkg/nagflux/helper/elastic_test.go b/pkg/nagflux/helper/elastic_test.go index 887b5d0..de4c37b 100644 --- a/pkg/nagflux/helper/elastic_test.go +++ b/pkg/nagflux/helper/elastic_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "pkg/nagflux/config" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" ) var CreateJSONFromStringMapData = []struct { diff --git a/pkg/nagflux/helper/influx.go b/pkg/nagflux/helper/influx.go index 2bd4c91..3225dfe 100644 --- a/pkg/nagflux/helper/influx.go +++ b/pkg/nagflux/helper/influx.go @@ -3,7 +3,7 @@ package helper import ( "strings" - "pkg/nagflux/config" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" ) // SanitizeInfluxInput adds backslashes to special chars. diff --git a/pkg/nagflux/helper/influx_test.go b/pkg/nagflux/helper/influx_test.go index 80ffb84..6c847f9 100644 --- a/pkg/nagflux/helper/influx_test.go +++ b/pkg/nagflux/helper/influx_test.go @@ -4,7 +4,7 @@ import ( "reflect" "testing" - "pkg/nagflux/config" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" ) var SanitizeInfluxData = []struct { diff --git a/pkg/nagflux/helper/string.go b/pkg/nagflux/helper/string.go index a8e0987..37c1059 100644 --- a/pkg/nagflux/helper/string.go +++ b/pkg/nagflux/helper/string.go @@ -6,7 +6,7 @@ import ( "strings" "time" - "pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" ) // IsStringANumber returns true if the given string can be casted to int or float. diff --git a/pkg/nagflux/nagflux.go b/pkg/nagflux/nagflux.go index ed1ed94..e55c1da 100644 --- a/pkg/nagflux/nagflux.go +++ b/pkg/nagflux/nagflux.go @@ -9,19 +9,19 @@ import ( "syscall" "time" - "pkg/nagflux/collector" - "pkg/nagflux/collector/livestatus" - "pkg/nagflux/collector/modgearman" - "pkg/nagflux/collector/nagflux" - "pkg/nagflux/collector/spoolfile" - "pkg/nagflux/config" - "pkg/nagflux/data" - "pkg/nagflux/helper" - "pkg/nagflux/logging" - "pkg/nagflux/statistics" - "pkg/nagflux/target/elasticsearch" - "pkg/nagflux/target/file/jsontarget" - "pkg/nagflux/target/influx" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector/livestatus" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector/modgearman" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector/nagflux" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector/spoolfile" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/data" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/statistics" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/target/elasticsearch" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/target/file/jsontarget" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/target/influx" "github.com/kdar/factorlog" ) diff --git a/pkg/nagflux/nagflux_test.go b/pkg/nagflux/nagflux_test.go index b8bc7d8..22a5d05 100644 --- a/pkg/nagflux/nagflux_test.go +++ b/pkg/nagflux/nagflux_test.go @@ -12,7 +12,7 @@ import ( "testing" "time" - "pkg/nagflux/target/influx" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/target/influx" ) const ( diff --git a/pkg/nagflux/statistics/prometheus.go b/pkg/nagflux/statistics/prometheus.go index 9a3f62e..5a412ab 100644 --- a/pkg/nagflux/statistics/prometheus.go +++ b/pkg/nagflux/statistics/prometheus.go @@ -7,8 +7,8 @@ import ( "sync" "time" - "pkg/nagflux/collector" - "pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" diff --git a/pkg/nagflux/target/elasticsearch/Connector.go b/pkg/nagflux/target/elasticsearch/Connector.go index a67a4a0..9e596bc 100644 --- a/pkg/nagflux/target/elasticsearch/Connector.go +++ b/pkg/nagflux/target/elasticsearch/Connector.go @@ -6,10 +6,10 @@ import ( "strings" "time" - "pkg/nagflux/collector" - "pkg/nagflux/config" - "pkg/nagflux/helper" - "pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" "github.com/kdar/factorlog" ) diff --git a/pkg/nagflux/target/elasticsearch/Worker.go b/pkg/nagflux/target/elasticsearch/Worker.go index 6d95916..53d2454 100644 --- a/pkg/nagflux/target/elasticsearch/Worker.go +++ b/pkg/nagflux/target/elasticsearch/Worker.go @@ -12,10 +12,10 @@ import ( "sync" "time" - "pkg/nagflux/collector" - "pkg/nagflux/helper" - "pkg/nagflux/logging" - "pkg/nagflux/statistics" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/statistics" "github.com/kdar/factorlog" ) diff --git a/pkg/nagflux/target/file/jsontarget/Worker.go b/pkg/nagflux/target/file/jsontarget/Worker.go index 9c84eba..8afbb21 100644 --- a/pkg/nagflux/target/file/jsontarget/Worker.go +++ b/pkg/nagflux/target/file/jsontarget/Worker.go @@ -7,8 +7,8 @@ import ( "path" "time" - "pkg/nagflux/collector" - "pkg/nagflux/data" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/data" "github.com/kdar/factorlog" ) diff --git a/pkg/nagflux/target/influx/Connector.go b/pkg/nagflux/target/influx/Connector.go index 766e026..9f539b3 100644 --- a/pkg/nagflux/target/influx/Connector.go +++ b/pkg/nagflux/target/influx/Connector.go @@ -9,11 +9,11 @@ import ( "regexp" "time" - "pkg/nagflux/collector" - "pkg/nagflux/config" - "pkg/nagflux/data" - "pkg/nagflux/helper" - "pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/data" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" "github.com/kdar/factorlog" ) diff --git a/pkg/nagflux/target/influx/Worker.go b/pkg/nagflux/target/influx/Worker.go index 62daf8f..7203672 100644 --- a/pkg/nagflux/target/influx/Worker.go +++ b/pkg/nagflux/target/influx/Worker.go @@ -11,12 +11,12 @@ import ( "sync" "time" - "pkg/nagflux/collector" - "pkg/nagflux/collector/nagflux" - "pkg/nagflux/data" - "pkg/nagflux/helper" - "pkg/nagflux/logging" - "pkg/nagflux/statistics" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector/nagflux" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/data" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/statistics" "github.com/kdar/factorlog" ) From b6c78aa051190cf3ed56f06a092f6f46f54d4e80 Mon Sep 17 00:00:00 2001 From: Ahmet Oeztuerk Date: Mon, 9 Mar 2026 17:36:53 +0100 Subject: [PATCH 03/11] fix the loop label, prevent infinite loops --- .../spoolfile/nagiosSpoolfileWorker.go | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/pkg/nagflux/collector/spoolfile/nagiosSpoolfileWorker.go b/pkg/nagflux/collector/spoolfile/nagiosSpoolfileWorker.go index 18046aa..6fe10d8 100644 --- a/pkg/nagflux/collector/spoolfile/nagiosSpoolfileWorker.go +++ b/pkg/nagflux/collector/spoolfile/nagiosSpoolfileWorker.go @@ -277,7 +277,6 @@ func (w *NagiosSpoolfileWorker) PerformanceDataIterator(input map[string]string) currentCheckMultiLabel = getCheckMultiRegexMatch(perfdataStringMatches[0][1]) } - perfdataStringMatchLoop: for _, perfdataStringMatch := range perfdataStringMatches { // Allows to add tags and fields to spoolfileentries tags := map[string]string{} @@ -325,36 +324,31 @@ func (w *NagiosSpoolfileWorker) PerformanceDataIterator(input map[string]string) fieldType, err := indexToPerformanceDataSliceField(i) if err != nil { log.Warnf("Error when converting the index to a known field in performance data : %s", err.Error()) - continue + goto perfdataStringMatchLoopEnd } switch fieldType { case RawMatch: - continue case Label: if len(data) > w.perfdataLabelMaxSize { log.Warnf("Perfdata Label: '%s' is too long with length: %s and longer than the limit: %s. Probably an anomally. Skipping this perfdata item, Host: %v , Service: %v, Perfdata fields: %v", data, len(data), w.perfdataLabelMaxSize, perf.Hostname, perf.Service, perfdataStringMatch) - goto perfdataStringMatchLoop + goto perfdataStringMatchLoopEnd } - continue case UOM: if len(data) > w.perfdataUOMMaxLength { log.Warnf("Perfdata UOM: '%s' is too long with length: %s and longer than the limit: %s. Probably an anomally. Host: %v , Service: %v, Perfdata fields: %v", data, len(data), w.perfdataUOMMaxLength, perf.Hostname, perf.Service, perfdataStringMatch) - goto perfdataStringMatchLoop + goto perfdataStringMatchLoopEnd } - continue case Value, Min, Max: if len(data) > w.perfdataNumericValuesMaxLength { log.Warnf("Perfdata field %s: '%s' is too long with length: %s and longer than the limit: %s. Probably an anomally. Host: %v , Service: %v, Perfdata fields: %v", fieldType.String(), data, len(data), w.perfdataNumericValuesMaxLength, perf.Hostname, perf.Service, perfdataStringMatch) - goto perfdataStringMatchLoop + goto perfdataStringMatchLoopEnd } - continue case Warn, Crit: if len(data) > w.perfdataThresholdsMaxLength { log.Warnf("Perfdata field %s: '%s' is too long with length: %s and longer than the limit: %s. Probably an anomally. Host: %v , Service: %v, Perfdata fields: %v", fieldType.String(), data, len(data), w.perfdataThresholdsMaxLength, perf.Hostname, perf.Service, perfdataStringMatch) - goto perfdataStringMatchLoop + goto perfdataStringMatchLoopEnd } - continue } if data == "" { @@ -386,13 +380,13 @@ func (w *NagiosSpoolfileWorker) PerformanceDataIterator(input map[string]string) } else { perf.Tags[fillLabel] = "outer" } - for i, tag := range []string{"min", "max"} { - tagKey := fmt.Sprintf("%s-%s", rangeRegex.String, tag) + tagKey := fmt.Sprintf("%s-%s", fieldType.String(), tag) perf.Fields[tagKey] = helper.StringIntToStringFloat(rangeHits[i][0]) } } else { log.Warnf("String: '%s' in field '%s' could not be parsed. Host: %v, Service: %v, Perf Data Fields: %v", data, fieldType.String(), perf.Hostname, perf.Service, perfdataStringMatch) + goto perfdataStringMatchLoopEnd } case Value, Min, Max: if data == "U" { @@ -401,12 +395,16 @@ func (w *NagiosSpoolfileWorker) PerformanceDataIterator(input map[string]string) } if !helper.IsStringANumber(data) { log.Warnf("String: '%s' in field '%s' is not a number, should be one. Host: %v, Service: %v, Perf Data Fields: %v", data, fieldType.String(), perf.Hostname, perf.Service, perfdataStringMatch) - continue perfdataStringMatchLoop + goto perfdataStringMatchLoopEnd } perf.Fields[fieldType.String()] = helper.StringIntToStringFloat(data) } } + ch <- perf + + // Skip item without sending it to the channel + perfdataStringMatchLoopEnd: } close(ch) }() @@ -479,6 +477,8 @@ func indexToPerformanceDataSliceField(index int) (PerformanceDataSliceFields, er return Label, nil case 2: return Value, nil + case 3: + return UOM, nil case 4: return Warn, nil case 5: From c2fa45203ee41bf65439e1e31aa6e02e6105995f Mon Sep 17 00:00:00 2001 From: Ahmet Oeztuerk Date: Mon, 9 Mar 2026 17:37:28 +0100 Subject: [PATCH 04/11] add perfdata field length rejection tests --- .../spoolfile/nagiosSpoolfileWorker_test.go | 158 +++++++++++++++++- 1 file changed, 157 insertions(+), 1 deletion(-) diff --git a/pkg/nagflux/collector/spoolfile/nagiosSpoolfileWorker_test.go b/pkg/nagflux/collector/spoolfile/nagiosSpoolfileWorker_test.go index cb1b486..291cfe3 100644 --- a/pkg/nagflux/collector/spoolfile/nagiosSpoolfileWorker_test.go +++ b/pkg/nagflux/collector/spoolfile/nagiosSpoolfileWorker_test.go @@ -14,6 +14,12 @@ const configFileContent = ` [Filter] SpoolFileLineTerms = check-host-alive + +[NagiosSpoolfile] + PerfdataLabelMaxLength = 32 + PerfdataUOMMaxLength = 16 + PerfdataNumericValuesMaxLength = 32 + PerfdataThresholdsMaxLength = 64 ` func TestPerformanceDataParser_01(t *testing.T) { @@ -427,12 +433,162 @@ func TestPerformanceDataParser_20(t *testing.T) { ) } +func TestPerformanceDataParser_LongPerformanceLabel(t *testing.T) { + t.Helper() + + config.InitConfigFromString(configFileContent) + + w := NewNagiosSpoolfileWorker(0, nil, nil, nil, 4096, collector.AllFilterable, PerfdataLabelMaxLengthDefault, PerfdataUOMMaxLengthDefault, PerfdataNumericValuesMaxLengthDefault, PerfdataThresholdsMaxLengthDefault) + + splittedPerformanceData := helper.StringToMap( + "DATATYPE::SERVICEPERFDATA TIMET::1441791000 HOSTNAME::xxx SERVICEDESC::range SERVICEPERFDATA::'i_am_a_very_long_performance_label_exceeding_the_default_limit_for_performance_labels_yeah'=35512320B;;;; SERVICECHECKCOMMAND::check_dummy SERVICESTATE::0 SERVICESTATETYPE::1", + "\t", "::") + + //nolint:prealloc // do not know the size of the iterable + collectedPerfData := []PerformanceData{} + for singlePerfdata := range w.PerformanceDataIterator(splittedPerformanceData) { + collectedPerfData = append(collectedPerfData, *singlePerfdata) + } + + assert.Emptyf(t, collectedPerfData, "Item should not be taken into the performance data due to long label, splittedPerformanceData: %v", splittedPerformanceData) +} + +func TestPerformanceDataParser_LongValue(t *testing.T) { + t.Helper() + + config.InitConfigFromString(configFileContent) + + w := NewNagiosSpoolfileWorker(0, nil, nil, nil, 4096, collector.AllFilterable, PerfdataLabelMaxLengthDefault, PerfdataUOMMaxLengthDefault, PerfdataNumericValuesMaxLengthDefault, PerfdataThresholdsMaxLengthDefault) + + splittedPerformanceData := helper.StringToMap( + "DATATYPE::SERVICEPERFDATA TIMET::1441791000 HOSTNAME::xxx SERVICEDESC::range SERVICEPERFDATA::'label'=123456789123456789123456789123456789;;;; SERVICECHECKCOMMAND::check_dummy SERVICESTATE::0 SERVICESTATETYPE::1", + "\t", "::") + + //nolint:prealloc // do not know the size of the iterable + collectedPerfData := []PerformanceData{} + for singlePerfdata := range w.PerformanceDataIterator(splittedPerformanceData) { + collectedPerfData = append(collectedPerfData, *singlePerfdata) + } + + assert.Emptyf(t, collectedPerfData, "Item should not be taken into the performance data due to long length value, splittedPerformanceData: %v", splittedPerformanceData) +} + +func TestPerformanceDataParser_LongUOM(t *testing.T) { + t.Helper() + + config.InitConfigFromString(configFileContent) + + w := NewNagiosSpoolfileWorker(0, nil, nil, nil, 4096, collector.AllFilterable, PerfdataLabelMaxLengthDefault, PerfdataUOMMaxLengthDefault, PerfdataNumericValuesMaxLengthDefault, PerfdataThresholdsMaxLengthDefault) + + // If you use underscores in the uom, it gets split out and only the first part is taken. + // UOM is deliberately written without underscores here + splittedPerformanceData := helper.StringToMap( + "DATATYPE::SERVICEPERFDATA TIMET::1441791000 HOSTNAME::xxx SERVICEDESC::range SERVICEPERFDATA::'label'=1iamaverylonguomthatshouldberejected;;;; SERVICECHECKCOMMAND::check_dummy SERVICESTATE::0 SERVICESTATETYPE::1", + "\t", "::") + + //nolint:prealloc // do not know the size of the iterable + collectedPerfData := []PerformanceData{} + for singlePerfdata := range w.PerformanceDataIterator(splittedPerformanceData) { + collectedPerfData = append(collectedPerfData, *singlePerfdata) + } + + assert.Emptyf(t, collectedPerfData, "Item should not be taken into the performance data due to long length unit of measurement, splittedPerformanceData: %v", splittedPerformanceData) +} + +func TestPerformanceDataParser_LongWarnTrehsold(t *testing.T) { + t.Helper() + + config.InitConfigFromString(configFileContent) + + w := NewNagiosSpoolfileWorker(0, nil, nil, nil, 4096, collector.AllFilterable, PerfdataLabelMaxLengthDefault, PerfdataUOMMaxLengthDefault, PerfdataNumericValuesMaxLengthDefault, PerfdataThresholdsMaxLengthDefault) + + // If you use underscores in the uom, it gets split out and only the first part is taken. + // UOM is deliberately written without underscores here + splittedPerformanceData := helper.StringToMap( + "DATATYPE::SERVICEPERFDATA TIMET::1441791000 HOSTNAME::xxx SERVICEDESC::range SERVICEPERFDATA::'label'=1;123456789123456789123456789123456789:123456789123456789123456789123456789;;; SERVICECHECKCOMMAND::check_dummy SERVICESTATE::0 SERVICESTATETYPE::1", + "\t", "::") + + //nolint:prealloc // do not know the size of the iterable + collectedPerfData := []PerformanceData{} + for singlePerfdata := range w.PerformanceDataIterator(splittedPerformanceData) { + collectedPerfData = append(collectedPerfData, *singlePerfdata) + } + + assert.Emptyf(t, collectedPerfData, "Item should not be taken into the performance data due to long length of warning threshold, splittedPerformanceData: %v", splittedPerformanceData) +} + +func TestPerformanceDataParser_LongCritTrehsold(t *testing.T) { + t.Helper() + + config.InitConfigFromString(configFileContent) + + w := NewNagiosSpoolfileWorker(0, nil, nil, nil, 4096, collector.AllFilterable, PerfdataLabelMaxLengthDefault, PerfdataUOMMaxLengthDefault, PerfdataNumericValuesMaxLengthDefault, PerfdataThresholdsMaxLengthDefault) + + // If you use underscores in the uom, it gets split out and only the first part is taken. + // UOM is deliberately written without underscores here + splittedPerformanceData := helper.StringToMap( + "DATATYPE::SERVICEPERFDATA TIMET::1441791000 HOSTNAME::xxx SERVICEDESC::range SERVICEPERFDATA::'label'=1;;123456789123456789123456789123456789:123456789123456789123456789123456789;; SERVICECHECKCOMMAND::check_dummy SERVICESTATE::0 SERVICESTATETYPE::1", + "\t", "::") + + //nolint:prealloc // do not know the size of the iterable + collectedPerfData := []PerformanceData{} + for singlePerfdata := range w.PerformanceDataIterator(splittedPerformanceData) { + collectedPerfData = append(collectedPerfData, *singlePerfdata) + } + + assert.Emptyf(t, collectedPerfData, "Item should not be taken into the performance data due to long length of critical threshold, splittedPerformanceData: %v", splittedPerformanceData) +} + +func TestPerformanceDataParser_LongMinValue(t *testing.T) { + t.Helper() + + config.InitConfigFromString(configFileContent) + + w := NewNagiosSpoolfileWorker(0, nil, nil, nil, 4096, collector.AllFilterable, PerfdataLabelMaxLengthDefault, PerfdataUOMMaxLengthDefault, PerfdataNumericValuesMaxLengthDefault, PerfdataThresholdsMaxLengthDefault) + + // If you use underscores in the uom, it gets split out and only the first part is taken. + // UOM is deliberately written without underscores here + splittedPerformanceData := helper.StringToMap( + "DATATYPE::SERVICEPERFDATA TIMET::1441791000 HOSTNAME::xxx SERVICEDESC::range SERVICEPERFDATA::'label'=1;;;123456789123456789123456789123456789; SERVICECHECKCOMMAND::check_dummy SERVICESTATE::0 SERVICESTATETYPE::1", + "\t", "::") + + //nolint:prealloc // do not know the size of the iterable + collectedPerfData := []PerformanceData{} + for singlePerfdata := range w.PerformanceDataIterator(splittedPerformanceData) { + collectedPerfData = append(collectedPerfData, *singlePerfdata) + } + + assert.Emptyf(t, collectedPerfData, "Item should not be taken into the performance data due to long length of minimum value, splittedPerformanceData: %v", splittedPerformanceData) +} + +func TestPerformanceDataParser_LongMaxValue(t *testing.T) { + t.Helper() + + config.InitConfigFromString(configFileContent) + + w := NewNagiosSpoolfileWorker(0, nil, nil, nil, 4096, collector.AllFilterable, PerfdataLabelMaxLengthDefault, PerfdataUOMMaxLengthDefault, PerfdataNumericValuesMaxLengthDefault, PerfdataThresholdsMaxLengthDefault) + + // If you use underscores in the uom, it gets split out and only the first part is taken. + // UOM is deliberately written without underscores here + splittedPerformanceData := helper.StringToMap( + "DATATYPE::SERVICEPERFDATA TIMET::1441791000 HOSTNAME::xxx SERVICEDESC::range SERVICEPERFDATA::'label'=1;;;;123456789123456789123456789123456789 SERVICECHECKCOMMAND::check_dummy SERVICESTATE::0 SERVICESTATETYPE::1", + "\t", "::") + + //nolint:prealloc // do not know the size of the iterable + collectedPerfData := []PerformanceData{} + for singlePerfdata := range w.PerformanceDataIterator(splittedPerformanceData) { + collectedPerfData = append(collectedPerfData, *singlePerfdata) + } + + assert.Emptyf(t, collectedPerfData, "Item should not be taken into the performance data due to long length of maximum value, splittedPerformanceData: %v", splittedPerformanceData) +} + func testPerformanceDataParser(t *testing.T, input string, expect []PerformanceData) { t.Helper() config.InitConfigFromString(configFileContent) - w := NewNagiosSpoolfileWorker(0, nil, nil, nil, 4096, collector.AllFilterable) + w := NewNagiosSpoolfileWorker(0, nil, nil, nil, 4096, collector.AllFilterable, PerfdataLabelMaxLengthDefault, PerfdataUOMMaxLengthDefault, PerfdataNumericValuesMaxLengthDefault, PerfdataThresholdsMaxLengthDefault) splittedPerformanceData := helper.StringToMap(input, "\t", "::") //nolint:prealloc // do not know the size of the iterable From cfc0eb35d5dbe4e73bba064f734f1e2010cb39f8 Mon Sep 17 00:00:00 2001 From: Ahmet Oeztuerk Date: Mon, 9 Mar 2026 18:22:14 +0100 Subject: [PATCH 05/11] add new perfdata max length configuration items to example config --- config.gcfg.example | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config.gcfg.example b/config.gcfg.example index 03d7783..3883530 100644 --- a/config.gcfg.example +++ b/config.gcfg.example @@ -68,6 +68,10 @@ Folder = "/var/spool/nagios" # This option takes predence over Main.NagiosSpoolfileWorker if set WorkerCount = 1 + PerfdataLabelMaxLength = 32 + PerfdataUOMMaxLength = 16 + PerfdataNumericValuesMaxLength = 32 + PerfdataThresholdsMaxLength = 64 [NagfluxSpoolfile] Enabled = true From 0fa569b862294b000657528e802178201d29bd29 Mon Sep 17 00:00:00 2001 From: Ahmet Oeztuerk Date: Mon, 9 Mar 2026 18:23:54 +0100 Subject: [PATCH 06/11] concatanete regex matches of individual perfdata values, and then check if they match the original strings this detects if there are letters after the last perfdata value --- .../spoolfile/nagiosSpoolfileWorker.go | 20 ++- .../spoolfile/nagiosSpoolfileWorker_test.go | 154 ++++++++++++++++-- 2 files changed, 153 insertions(+), 21 deletions(-) diff --git a/pkg/nagflux/collector/spoolfile/nagiosSpoolfileWorker.go b/pkg/nagflux/collector/spoolfile/nagiosSpoolfileWorker.go index 6fe10d8..e06594e 100644 --- a/pkg/nagflux/collector/spoolfile/nagiosSpoolfileWorker.go +++ b/pkg/nagflux/collector/spoolfile/nagiosSpoolfileWorker.go @@ -88,6 +88,7 @@ var ( // Same as 6th capture group, but it is for the maximum value this time. // '\s' matches any whitespace character, infinite times. // Idea: It seperates different perf data values as this must be matched new capture group can be captured + // Overall this script will detect a perfdata in Nagios syntax regexPerformancelable = regexp.MustCompile(`([^=]+)=(U|[\d\.\,\-]+)([\pL\/\%]*);?([\d\.\,\-\:\~\@]*)?;?([\d\.\,\-\:\~\@]*)?;?([\d\.\,\-]*)?;?([\d\.\,\-]*)?;?\s*`) // The perfdata part might have some alternative check at the end, recognize it by it being at the end and only containing letters, '_', '-' @@ -254,8 +255,8 @@ func (w *NagiosSpoolfileWorker) PerformanceDataIterator(input map[string]string) // anonymous closure, starts immediately after definition in another goroutine without blocking go func() { - perdataString := input[dataType+"PERFDATA"] - cleaned := regexStripErrors.ReplaceAllString(perdataString, "") + perfdataString := input[dataType+"PERFDATA"] + perfdataStringErrorsRemoved := regexStripErrors.ReplaceAllString(perfdataString, "") // Slices up the string into a form like this // Each match is put into an array with their capture groups @@ -269,7 +270,7 @@ func (w *NagiosSpoolfileWorker) PerformanceDataIterator(input map[string]string) ["pl=0%;80;100;0;100","pl","0","%","80","100","0","100"] ] */ - perfdataStringMatches := regexPerformancelable.FindAllStringSubmatch(cleaned, -1) + perfdataStringMatches := regexPerformancelable.FindAllStringSubmatch(perfdataStringErrorsRemoved, -1) currentCheckMultiLabel := "" // try to find a check_multi prefix @@ -277,6 +278,19 @@ func (w *NagiosSpoolfileWorker) PerformanceDataIterator(input map[string]string) currentCheckMultiLabel = getCheckMultiRegexMatch(perfdataStringMatches[0][1]) } + // check if concataneting matches makes up the original string + matchesConcatenated := "" + for _, matchAndCaptureGroups := range perfdataStringMatches { + match := matchAndCaptureGroups[0] + matchesConcatenated += match + } + + if len(matchesConcatenated) > 0 && strings.TrimSpace(matchesConcatenated) != strings.TrimSpace(perfdataString) { + log.Warnf("Perfdata matches: '%v' when concatanted come up to be: '%s', and original perfdata string is: '%s' . They are not equal after stripping whitespace from both", perfdataStringMatches, matchesConcatenated, perfdataString) + close(ch) + return + } + for _, perfdataStringMatch := range perfdataStringMatches { // Allows to add tags and fields to spoolfileentries tags := map[string]string{} diff --git a/pkg/nagflux/collector/spoolfile/nagiosSpoolfileWorker_test.go b/pkg/nagflux/collector/spoolfile/nagiosSpoolfileWorker_test.go index 291cfe3..1410c2c 100644 --- a/pkg/nagflux/collector/spoolfile/nagiosSpoolfileWorker_test.go +++ b/pkg/nagflux/collector/spoolfile/nagiosSpoolfileWorker_test.go @@ -6,7 +6,6 @@ import ( "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" - "github.com/stretchr/testify/assert" ) @@ -433,6 +432,21 @@ func TestPerformanceDataParser_20(t *testing.T) { ) } +func testPerformanceDataParser(t *testing.T, input string, expect []PerformanceData) { + t.Helper() + + config.InitConfigFromString(configFileContent) + + w := NewNagiosSpoolfileWorker(0, nil, nil, nil, 4096, collector.AllFilterable, PerfdataLabelMaxLengthDefault, PerfdataUOMMaxLengthDefault, PerfdataNumericValuesMaxLengthDefault, PerfdataThresholdsMaxLengthDefault) + + splittedPerformanceData := helper.StringToMap(input, "\t", "::") + collectedPerfData := []PerformanceData{} + for singlePerfdata := range w.PerformanceDataIterator(splittedPerformanceData) { + collectedPerfData = append(collectedPerfData, *singlePerfdata) + } + assert.Equalf(t, expect, collectedPerfData, "performance data matches") +} + func TestPerformanceDataParser_LongPerformanceLabel(t *testing.T) { t.Helper() @@ -444,7 +458,6 @@ func TestPerformanceDataParser_LongPerformanceLabel(t *testing.T) { "DATATYPE::SERVICEPERFDATA TIMET::1441791000 HOSTNAME::xxx SERVICEDESC::range SERVICEPERFDATA::'i_am_a_very_long_performance_label_exceeding_the_default_limit_for_performance_labels_yeah'=35512320B;;;; SERVICECHECKCOMMAND::check_dummy SERVICESTATE::0 SERVICESTATETYPE::1", "\t", "::") - //nolint:prealloc // do not know the size of the iterable collectedPerfData := []PerformanceData{} for singlePerfdata := range w.PerformanceDataIterator(splittedPerformanceData) { collectedPerfData = append(collectedPerfData, *singlePerfdata) @@ -464,7 +477,6 @@ func TestPerformanceDataParser_LongValue(t *testing.T) { "DATATYPE::SERVICEPERFDATA TIMET::1441791000 HOSTNAME::xxx SERVICEDESC::range SERVICEPERFDATA::'label'=123456789123456789123456789123456789;;;; SERVICECHECKCOMMAND::check_dummy SERVICESTATE::0 SERVICESTATETYPE::1", "\t", "::") - //nolint:prealloc // do not know the size of the iterable collectedPerfData := []PerformanceData{} for singlePerfdata := range w.PerformanceDataIterator(splittedPerformanceData) { collectedPerfData = append(collectedPerfData, *singlePerfdata) @@ -486,7 +498,6 @@ func TestPerformanceDataParser_LongUOM(t *testing.T) { "DATATYPE::SERVICEPERFDATA TIMET::1441791000 HOSTNAME::xxx SERVICEDESC::range SERVICEPERFDATA::'label'=1iamaverylonguomthatshouldberejected;;;; SERVICECHECKCOMMAND::check_dummy SERVICESTATE::0 SERVICESTATETYPE::1", "\t", "::") - //nolint:prealloc // do not know the size of the iterable collectedPerfData := []PerformanceData{} for singlePerfdata := range w.PerformanceDataIterator(splittedPerformanceData) { collectedPerfData = append(collectedPerfData, *singlePerfdata) @@ -502,13 +513,10 @@ func TestPerformanceDataParser_LongWarnTrehsold(t *testing.T) { w := NewNagiosSpoolfileWorker(0, nil, nil, nil, 4096, collector.AllFilterable, PerfdataLabelMaxLengthDefault, PerfdataUOMMaxLengthDefault, PerfdataNumericValuesMaxLengthDefault, PerfdataThresholdsMaxLengthDefault) - // If you use underscores in the uom, it gets split out and only the first part is taken. - // UOM is deliberately written without underscores here splittedPerformanceData := helper.StringToMap( "DATATYPE::SERVICEPERFDATA TIMET::1441791000 HOSTNAME::xxx SERVICEDESC::range SERVICEPERFDATA::'label'=1;123456789123456789123456789123456789:123456789123456789123456789123456789;;; SERVICECHECKCOMMAND::check_dummy SERVICESTATE::0 SERVICESTATETYPE::1", "\t", "::") - //nolint:prealloc // do not know the size of the iterable collectedPerfData := []PerformanceData{} for singlePerfdata := range w.PerformanceDataIterator(splittedPerformanceData) { collectedPerfData = append(collectedPerfData, *singlePerfdata) @@ -530,7 +538,6 @@ func TestPerformanceDataParser_LongCritTrehsold(t *testing.T) { "DATATYPE::SERVICEPERFDATA TIMET::1441791000 HOSTNAME::xxx SERVICEDESC::range SERVICEPERFDATA::'label'=1;;123456789123456789123456789123456789:123456789123456789123456789123456789;; SERVICECHECKCOMMAND::check_dummy SERVICESTATE::0 SERVICESTATETYPE::1", "\t", "::") - //nolint:prealloc // do not know the size of the iterable collectedPerfData := []PerformanceData{} for singlePerfdata := range w.PerformanceDataIterator(splittedPerformanceData) { collectedPerfData = append(collectedPerfData, *singlePerfdata) @@ -546,13 +553,10 @@ func TestPerformanceDataParser_LongMinValue(t *testing.T) { w := NewNagiosSpoolfileWorker(0, nil, nil, nil, 4096, collector.AllFilterable, PerfdataLabelMaxLengthDefault, PerfdataUOMMaxLengthDefault, PerfdataNumericValuesMaxLengthDefault, PerfdataThresholdsMaxLengthDefault) - // If you use underscores in the uom, it gets split out and only the first part is taken. - // UOM is deliberately written without underscores here splittedPerformanceData := helper.StringToMap( "DATATYPE::SERVICEPERFDATA TIMET::1441791000 HOSTNAME::xxx SERVICEDESC::range SERVICEPERFDATA::'label'=1;;;123456789123456789123456789123456789; SERVICECHECKCOMMAND::check_dummy SERVICESTATE::0 SERVICESTATETYPE::1", "\t", "::") - //nolint:prealloc // do not know the size of the iterable collectedPerfData := []PerformanceData{} for singlePerfdata := range w.PerformanceDataIterator(splittedPerformanceData) { collectedPerfData = append(collectedPerfData, *singlePerfdata) @@ -568,13 +572,10 @@ func TestPerformanceDataParser_LongMaxValue(t *testing.T) { w := NewNagiosSpoolfileWorker(0, nil, nil, nil, 4096, collector.AllFilterable, PerfdataLabelMaxLengthDefault, PerfdataUOMMaxLengthDefault, PerfdataNumericValuesMaxLengthDefault, PerfdataThresholdsMaxLengthDefault) - // If you use underscores in the uom, it gets split out and only the first part is taken. - // UOM is deliberately written without underscores here splittedPerformanceData := helper.StringToMap( "DATATYPE::SERVICEPERFDATA TIMET::1441791000 HOSTNAME::xxx SERVICEDESC::range SERVICEPERFDATA::'label'=1;;;;123456789123456789123456789123456789 SERVICECHECKCOMMAND::check_dummy SERVICESTATE::0 SERVICESTATETYPE::1", "\t", "::") - //nolint:prealloc // do not know the size of the iterable collectedPerfData := []PerformanceData{} for singlePerfdata := range w.PerformanceDataIterator(splittedPerformanceData) { collectedPerfData = append(collectedPerfData, *singlePerfdata) @@ -583,18 +584,135 @@ func TestPerformanceDataParser_LongMaxValue(t *testing.T) { assert.Emptyf(t, collectedPerfData, "Item should not be taken into the performance data due to long length of maximum value, splittedPerformanceData: %v", splittedPerformanceData) } -func testPerformanceDataParser(t *testing.T, input string, expect []PerformanceData) { +func TestPerformanceDataParser_GarbageStringAfterPerfdata1(t *testing.T) { t.Helper() config.InitConfigFromString(configFileContent) w := NewNagiosSpoolfileWorker(0, nil, nil, nil, 4096, collector.AllFilterable, PerfdataLabelMaxLengthDefault, PerfdataUOMMaxLengthDefault, PerfdataNumericValuesMaxLengthDefault, PerfdataThresholdsMaxLengthDefault) - splittedPerformanceData := helper.StringToMap(input, "\t", "::") - //nolint:prealloc // do not know the size of the iterable + splittedPerformanceData := helper.StringToMap( + "DATATYPE::SERVICEPERFDATA TIMET::1441791000 HOSTNAME::xxx SERVICEDESC::range SERVICEPERFDATA::passme=1 failme=1;1:2;3:4;5;6-hello-i-am-garbage-string-that-should-be-detected-as-i-am-not-whitespace SERVICECHECKCOMMAND::check_dummy SERVICESTATE::0 SERVICESTATETYPE::1", + "\t", "::") + collectedPerfData := []PerformanceData{} for singlePerfdata := range w.PerformanceDataIterator(splittedPerformanceData) { collectedPerfData = append(collectedPerfData, *singlePerfdata) } - assert.Equalf(t, expect, collectedPerfData, "performance data matches") + + assert.Emptyf(t, collectedPerfData, "Item should not be taken into the performance data due to long length of maximum value, splittedPerformanceData: %v", splittedPerformanceData) +} + +func TestPerformanceDataParser_GarbageStringAfterPerfdata2(t *testing.T) { + t.Helper() + + config.InitConfigFromString(configFileContent) + + w := NewNagiosSpoolfileWorker(0, nil, nil, nil, 4096, collector.AllFilterable, PerfdataLabelMaxLengthDefault, PerfdataUOMMaxLengthDefault, PerfdataNumericValuesMaxLengthDefault, PerfdataThresholdsMaxLengthDefault) + + splittedPerformanceData := helper.StringToMap( + "DATATYPE::SERVICEPERFDATA TIMET::1441791000 HOSTNAME::xxx SERVICEDESC::range SERVICEPERFDATA::passme=1 failme=1;1:2;3:4;5;6-garbage foo bar xyz=3;4afvdv23 SERVICECHECKCOMMAND::check_dummy SERVICESTATE::0 SERVICESTATETYPE::1", + "\t", "::") + + collectedPerfData := []PerformanceData{} + for singlePerfdata := range w.PerformanceDataIterator(splittedPerformanceData) { + collectedPerfData = append(collectedPerfData, *singlePerfdata) + } + + assert.Emptyf(t, collectedPerfData, "Item should not be taken into the performance data due to long length of maximum value, splittedPerformanceData: %v", splittedPerformanceData) +} + +func TestPerformanceDataParser_GarbageStringAfterPerfdata3(t *testing.T) { + t.Helper() + + config.InitConfigFromString(configFileContent) + + w := NewNagiosSpoolfileWorker(0, nil, nil, nil, 4096, collector.AllFilterable, PerfdataLabelMaxLengthDefault, PerfdataUOMMaxLengthDefault, PerfdataNumericValuesMaxLengthDefault, PerfdataThresholdsMaxLengthDefault) + + splittedPerformanceData := helper.StringToMap( + "DATATYPE::SERVICEPERFDATA TIMET::1441791000 HOSTNAME::xxx SERVICEDESC::range SERVICEPERFDATA::xyz=3;45afv SERVICECHECKCOMMAND::check_dummy SERVICESTATE::0 SERVICESTATETYPE::1", + "\t", "::") + + collectedPerfData := []PerformanceData{} + for singlePerfdata := range w.PerformanceDataIterator(splittedPerformanceData) { + collectedPerfData = append(collectedPerfData, *singlePerfdata) + } + + assert.Emptyf(t, collectedPerfData, "Item should not be taken into the performance data due to long length of maximum value, splittedPerformanceData: %v", splittedPerformanceData) +} + +func TestPerformanceDataParser_GarbageStringAfterPerfdata4(t *testing.T) { + t.Helper() + + config.InitConfigFromString(configFileContent) + + w := NewNagiosSpoolfileWorker(0, nil, nil, nil, 4096, collector.AllFilterable, PerfdataLabelMaxLengthDefault, PerfdataUOMMaxLengthDefault, PerfdataNumericValuesMaxLengthDefault, PerfdataThresholdsMaxLengthDefault) + + splittedPerformanceData := helper.StringToMap( + "DATATYPE::SERVICEPERFDATA TIMET::1441791000 HOSTNAME::xxx SERVICEDESC::range SERVICEPERFDATA::label=1;2;label2 SERVICECHECKCOMMAND::check_dummy SERVICESTATE::0 SERVICESTATETYPE::1", + "\t", "::") + + collectedPerfData := []PerformanceData{} + for singlePerfdata := range w.PerformanceDataIterator(splittedPerformanceData) { + collectedPerfData = append(collectedPerfData, *singlePerfdata) + } + + assert.Emptyf(t, collectedPerfData, "Item should not be taken it contains garbage data, splittedPerformanceData: %v", splittedPerformanceData) +} + +func TestPerformanceDataParser_GarbageStringAfterPerfdata5(t *testing.T) { + t.Helper() + + config.InitConfigFromString(configFileContent) + + w := NewNagiosSpoolfileWorker(0, nil, nil, nil, 4096, collector.AllFilterable, PerfdataLabelMaxLengthDefault, PerfdataUOMMaxLengthDefault, PerfdataNumericValuesMaxLengthDefault, PerfdataThresholdsMaxLengthDefault) + + splittedPerformanceData := helper.StringToMap( + "DATATYPE::SERVICEPERFDATA TIMET::1441791000 HOSTNAME::xxx SERVICEDESC::range SERVICEPERFDATA::asd label=1;2; other=1;3;4asdasdasd SERVICECHECKCOMMAND::check_dummy SERVICESTATE::0 SERVICESTATETYPE::1", + "\t", "::") + + collectedPerfData := []PerformanceData{} + for singlePerfdata := range w.PerformanceDataIterator(splittedPerformanceData) { + collectedPerfData = append(collectedPerfData, *singlePerfdata) + } + + assert.Emptyf(t, collectedPerfData, "Item should not be taken it contains garbage data, splittedPerformanceData: %v", splittedPerformanceData) +} + +func TestPerformanceDataParser_GarbageStringAfterPerfdata6(t *testing.T) { + t.Helper() + + config.InitConfigFromString(configFileContent) + + w := NewNagiosSpoolfileWorker(0, nil, nil, nil, 4096, collector.AllFilterable, PerfdataLabelMaxLengthDefault, PerfdataUOMMaxLengthDefault, PerfdataNumericValuesMaxLengthDefault, PerfdataThresholdsMaxLengthDefault) + + splittedPerformanceData := helper.StringToMap( + "DATATYPE::SERVICEPERFDATA TIMET::1441791000 HOSTNAME::xxx SERVICEDESC::range SERVICEPERFDATA::asd label=1;2; other=1;3;4asdasdasd [anza=ffgg] [si signo=11] 'valid[1]'=5 [si_errno=0] [si_code=1] SERVICECHECKCOMMAND::check_dummy SERVICESTATE::0 SERVICESTATETYPE::1", + "\t", "::") + + collectedPerfData := []PerformanceData{} + for singlePerfdata := range w.PerformanceDataIterator(splittedPerformanceData) { + collectedPerfData = append(collectedPerfData, *singlePerfdata) + } + + assert.Emptyf(t, collectedPerfData, "Item should not be taken it contains garbage data, splittedPerformanceData: %v", splittedPerformanceData) +} + +func TestPerformanceDataParser_GarbageStringAfterPerfdata7(t *testing.T) { + t.Helper() + + config.InitConfigFromString(configFileContent) + + w := NewNagiosSpoolfileWorker(0, nil, nil, nil, 4096, collector.AllFilterable, PerfdataLabelMaxLengthDefault, PerfdataUOMMaxLengthDefault, PerfdataNumericValuesMaxLengthDefault, PerfdataThresholdsMaxLengthDefault) + + splittedPerformanceData := helper.StringToMap( + "DATATYPE::SERVICEPERFDATA TIMET::1441791000 HOSTNAME::xxx SERVICEDESC::range SERVICEPERFDATA::asd label=1;2; other=1;3;4asdasdasd [anza=ffgg] [si signo=11] 'valid[1]'=5 [si_errno=0] [si_code=1]fasdgew SERVICECHECKCOMMAND::check_dummy SERVICESTATE::0 SERVICESTATETYPE::1", + "\t", "::") + + collectedPerfData := []PerformanceData{} + for singlePerfdata := range w.PerformanceDataIterator(splittedPerformanceData) { + collectedPerfData = append(collectedPerfData, *singlePerfdata) + } + + assert.Emptyf(t, collectedPerfData, "Item should not be taken it contains garbage data, splittedPerformanceData: %v", splittedPerformanceData) } From c60575fbcb35a4f1b7d6a90998776d12699af0a6 Mon Sep 17 00:00:00 2001 From: Ahmet Oeztuerk Date: Tue, 10 Mar 2026 17:44:55 +0100 Subject: [PATCH 07/11] fixes for the updated golangci-lint version 2.11.3 --- Makefile | 2 + .../collector/livestatus/CacheBuilder.go | 1 - .../collector/livestatus/CacheBuilder_test.go | 1 - pkg/nagflux/collector/livestatus/Collector.go | 1 - .../collector/livestatus/Connector_test.go | 1 - .../collector/livestatus/DowntimeData_test.go | 1 - .../collector/modgearman/gearmanWorker.go | 1 - .../collector/nagflux/dumpfileCollector.go | 1 - .../collector/nagflux/nagfluxFileCollector.go | 1 - .../spoolfile/nagiosSpoolfileCollector.go | 40 ++++++------ .../spoolfile/nagiosSpoolfileWorker.go | 64 +++++++++---------- pkg/nagflux/filter/Filter_test.go | 1 - pkg/nagflux/helper/elastic.go | 1 + pkg/nagflux/nagflux.go | 2 - pkg/nagflux/nagflux_test.go | 1 - pkg/nagflux/statistics/prometheus.go | 1 - pkg/nagflux/target/elasticsearch/Connector.go | 1 - pkg/nagflux/target/elasticsearch/Worker.go | 1 - pkg/nagflux/target/file/jsontarget/Worker.go | 1 - pkg/nagflux/target/influx/Connector.go | 1 - pkg/nagflux/target/influx/Worker.go | 1 - 21 files changed, 53 insertions(+), 72 deletions(-) diff --git a/Makefile b/Makefile index 9765960..3305d3d 100644 --- a/Makefile +++ b/Makefile @@ -192,6 +192,8 @@ golangci: tools # golangci combines a few static code analyzer # See https://github.com/golangci/golangci-lint # + @which golangci-lint + @golangci-lint version @set -e; for dir in $$(ls -1d pkg/* cmd); do \ echo $$dir; \ echo " - GOOS=linux"; \ diff --git a/pkg/nagflux/collector/livestatus/CacheBuilder.go b/pkg/nagflux/collector/livestatus/CacheBuilder.go index df2cba0..a2e3ca0 100644 --- a/pkg/nagflux/collector/livestatus/CacheBuilder.go +++ b/pkg/nagflux/collector/livestatus/CacheBuilder.go @@ -8,7 +8,6 @@ import ( "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" - "github.com/kdar/factorlog" ) diff --git a/pkg/nagflux/collector/livestatus/CacheBuilder_test.go b/pkg/nagflux/collector/livestatus/CacheBuilder_test.go index eb1c5fe..d5d0311 100644 --- a/pkg/nagflux/collector/livestatus/CacheBuilder_test.go +++ b/pkg/nagflux/collector/livestatus/CacheBuilder_test.go @@ -5,7 +5,6 @@ import ( "time" "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/pkg/nagflux/collector/livestatus/Collector.go b/pkg/nagflux/collector/livestatus/Collector.go index 24e48f1..9cb4a26 100644 --- a/pkg/nagflux/collector/livestatus/Collector.go +++ b/pkg/nagflux/collector/livestatus/Collector.go @@ -12,7 +12,6 @@ import ( "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/filter" "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" - "github.com/kdar/factorlog" ) diff --git a/pkg/nagflux/collector/livestatus/Connector_test.go b/pkg/nagflux/collector/livestatus/Connector_test.go index 991fb9e..8257721 100644 --- a/pkg/nagflux/collector/livestatus/Connector_test.go +++ b/pkg/nagflux/collector/livestatus/Connector_test.go @@ -11,7 +11,6 @@ import ( "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" - "github.com/stretchr/testify/assert" ) diff --git a/pkg/nagflux/collector/livestatus/DowntimeData_test.go b/pkg/nagflux/collector/livestatus/DowntimeData_test.go index 04738c1..1cc67be 100644 --- a/pkg/nagflux/collector/livestatus/DowntimeData_test.go +++ b/pkg/nagflux/collector/livestatus/DowntimeData_test.go @@ -5,7 +5,6 @@ import ( "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" - "github.com/stretchr/testify/assert" ) diff --git a/pkg/nagflux/collector/modgearman/gearmanWorker.go b/pkg/nagflux/collector/modgearman/gearmanWorker.go index 24b01e0..e18a904 100644 --- a/pkg/nagflux/collector/modgearman/gearmanWorker.go +++ b/pkg/nagflux/collector/modgearman/gearmanWorker.go @@ -12,7 +12,6 @@ import ( "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper/cryptohelper" "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" - libworker "github.com/appscode/g2/worker" "github.com/kdar/factorlog" ) diff --git a/pkg/nagflux/collector/nagflux/dumpfileCollector.go b/pkg/nagflux/collector/nagflux/dumpfileCollector.go index 81474d6..0926c50 100644 --- a/pkg/nagflux/collector/nagflux/dumpfileCollector.go +++ b/pkg/nagflux/collector/nagflux/dumpfileCollector.go @@ -11,7 +11,6 @@ import ( "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/data" "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" - "github.com/kdar/factorlog" ) diff --git a/pkg/nagflux/collector/nagflux/nagfluxFileCollector.go b/pkg/nagflux/collector/nagflux/nagfluxFileCollector.go index 096de1c..3b1246b 100644 --- a/pkg/nagflux/collector/nagflux/nagfluxFileCollector.go +++ b/pkg/nagflux/collector/nagflux/nagfluxFileCollector.go @@ -10,7 +10,6 @@ import ( "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" - "github.com/kdar/factorlog" ) diff --git a/pkg/nagflux/collector/spoolfile/nagiosSpoolfileCollector.go b/pkg/nagflux/collector/spoolfile/nagiosSpoolfileCollector.go index e7d10a8..a85f76c 100644 --- a/pkg/nagflux/collector/spoolfile/nagiosSpoolfileCollector.go +++ b/pkg/nagflux/collector/spoolfile/nagiosSpoolfileCollector.go @@ -1,7 +1,7 @@ package spoolfile import ( - "fmt" + "errors" "os" "path" "time" @@ -21,17 +21,17 @@ const ( // IntervalToCheckDirectory the interval to check if there are new files IntervalToCheckDirectory = 1500 * time.Millisecond - // If a perfdata label is longer than this, it will be logged as an anomaly and skipped + // PerfdataLabelMaxLengthDefault: If a perfdata label is longer than this, it will be logged as an anomaly and skipped PerfdataLabelMaxLengthDefault = int(32) - // If a perfdata UOM is longer than this, it will be logged as an anomaly and skipped + // PerfdataUOMMaxLengthDefault: If a perfdata UOM is longer than this, it will be logged as an anomaly and skipped PerfdataUOMMaxLengthDefault = int(16) - // If a perfdata numeric value, e.g current value, min, and max is longer than this, it will be logged as an anomaly and skipped + // PerfdataNumericValuesMaxLengthDefault: If a perfdata numeric value, e.g current value, min, and max is longer than this, it will be logged as an anomaly and skipped // Reasoning: Largest uint64 is 20 characters wide, floats are not printed with too much precision either PerfdataNumericValuesMaxLengthDefault = int(32) - // If a perfdata numeric value, e.g current value, min, and max is longer than this, it will be logged as an anomaly and skipped + // PerfdataThresholdsMaxLengthDefault: If a perfdata numeric value, e.g current value, min, and max is longer than this, it will be logged as an anomaly and skipped // Reasoning: Twice the numeric value max length, since there are seperators as well PerfdataThresholdsMaxLengthDefault = int(64) ) @@ -48,29 +48,27 @@ type NagiosSpoolfileCollector struct { func NagiosSpoolfileCollectorFactory(cfg config.Config, results collector.ResultQueues, livestatusCacheBuilder *livestatus.CacheBuilder, fileBufferSize int, defaultTarget collector.Filterable, ) (*NagiosSpoolfileCollector, error) { - spoolDirectory := "" search, found := helper.GetPreferredConfigValue(cfg, "NagiosSpoolfile.Folder", []string{"Main.NagiosSpoolfileFolder"}) if !found { - return nil, fmt.Errorf("Could not find a config value for Nagios Spoolfile Folder") + return nil, errors.New("could not find a config value for Nagios Spoolfile Folder") } + spoolDirectoryPtr, ok := search.(*string) - if ok { - spoolDirectory = *(spoolDirectoryPtr) - } else { - return nil, fmt.Errorf("Expected a *string value out of the config value for Nagios Spoolfile Folder") + if !ok { + return nil, errors.New("expected a *string value out of the config value for Nagios Spoolfile Folder") } + spoolDirectory := *(spoolDirectoryPtr) - workerAmount := 0 search, found = helper.GetPreferredConfigValue(cfg, "NagiosSpoolfile.WorkerCount", []string{"Main.NagiosSpoolfileWorker"}) if !found { - return nil, fmt.Errorf("Could not find a config value for Nagios Spoolfile Worker Count") + return nil, errors.New("could not find a config value for Nagios Spoolfile Worker Count") } + workerAmountPtr, ok := search.(*int) - if ok { - workerAmount = *(workerAmountPtr) - } else { - return nil, fmt.Errorf("Expected a *int value out of the config value for Nagios Spoolfile Worker Count") + if !ok { + return nil, errors.New("expected a *int value out of the config value for Nagios Spoolfile Worker Count") } + workerAmount := *(workerAmountPtr) perfdataLabelMaxLength := PerfdataLabelMaxLengthDefault search, found = helper.GetPreferredConfigValue(cfg, "NagiosSpoolfile.PerfdataLabelMaxLength", []string{}) @@ -79,7 +77,7 @@ func NagiosSpoolfileCollectorFactory(cfg config.Config, results collector.Result if ok { perfdataLabelMaxLength = *(perfdataLabelMaxLengthPtr) } else { - return nil, fmt.Errorf("Expected a *int value out of the config value for Nagios Spoolfile Perfdata Label Max Length") + return nil, errors.New("expected a *int value out of the config value for Nagios Spoolfile Perfdata Label Max Length") } } @@ -90,7 +88,7 @@ func NagiosSpoolfileCollectorFactory(cfg config.Config, results collector.Result if ok { perfdataUOMMaxLength = *(perfdataUOMMaxLengthPtr) } else { - return nil, fmt.Errorf("Expected a *int value out of the config value for Nagios Spoolfile Perfdata UOM Max Length") + return nil, errors.New("expected a *int value out of the config value for Nagios Spoolfile Perfdata UOM Max Length") } } @@ -101,7 +99,7 @@ func NagiosSpoolfileCollectorFactory(cfg config.Config, results collector.Result if ok { perfdataNumericValuesMaxLength = *(perfdataNumericValuesMaxLengthPtr) } else { - return nil, fmt.Errorf("Expected a *int value out of the config value for Nagios Spoolfile Perfdata UOM Max Length") + return nil, errors.New("expected a *int value out of the config value for Nagios Spoolfile Perfdata UOM Max Length") } } @@ -112,7 +110,7 @@ func NagiosSpoolfileCollectorFactory(cfg config.Config, results collector.Result if ok { perfdataThresholdsMaxLength = *(perfdataThresholdsMaxLengthPtr) } else { - return nil, fmt.Errorf("Expected a *int value out of the config value for Nagios Spoolfile Perfdata Thresholds Max Length") + return nil, errors.New("expected a *int value out of the config value for Nagios Spoolfile Perfdata Thresholds Max Length") } } diff --git a/pkg/nagflux/collector/spoolfile/nagiosSpoolfileWorker.go b/pkg/nagflux/collector/spoolfile/nagiosSpoolfileWorker.go index e06594e..6ff8d0f 100644 --- a/pkg/nagflux/collector/spoolfile/nagiosSpoolfileWorker.go +++ b/pkg/nagflux/collector/spoolfile/nagiosSpoolfileWorker.go @@ -18,7 +18,6 @@ import ( "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/statistics" - "github.com/kdar/factorlog" ) @@ -87,7 +86,7 @@ var ( // 7th Capture Group: ([\d\.\,\-]*) // Same as 6th capture group, but it is for the maximum value this time. // '\s' matches any whitespace character, infinite times. - // Idea: It seperates different perf data values as this must be matched new capture group can be captured + // Idea: It separates different perf data values as this must be matched new capture group can be captured // Overall this script will detect a perfdata in Nagios syntax regexPerformancelable = regexp.MustCompile(`([^=]+)=(U|[\d\.\,\-]+)([\pL\/\%]*);?([\d\.\,\-\:\~\@]*)?;?([\d\.\,\-\:\~\@]*)?;?([\d\.\,\-]*)?;?([\d\.\,\-]*)?;?\s*`) @@ -98,14 +97,12 @@ var ( // The perfdata part might report errors for different data // it has to put them in square brackets first, and use an equal sign for the error - // This is to differenciate it from alternative command, which does not have an equal sign. + // This is to differentiate it from alternative command, which does not have an equal sign. // This convention is not found in monitoring-plugins development guidelines regexStripErrors = regexp.MustCompile(`\[[^\]]*=[^\]]*\]`) ) -var ( - log *factorlog.FactorLog = logging.GetLogger() -) +var log *factorlog.FactorLog = logging.GetLogger() // NagiosSpoolfileWorker parses the given spoolfiles and adds the extraced perfdata to the queue. type NagiosSpoolfileWorker struct { @@ -234,6 +231,8 @@ func (w *NagiosSpoolfileWorker) run() { } // PerformanceDataIterator returns an iterator to loop over generated perf data. +// +//nolint:maintidx // the lambda inside has to check all fields of the performance data, adds a lot of branching code func (w *NagiosSpoolfileWorker) PerformanceDataIterator(input map[string]string) <-chan *PerformanceData { ch := make(chan *PerformanceData) dataType := findDataType(input) @@ -261,15 +260,12 @@ func (w *NagiosSpoolfileWorker) PerformanceDataIterator(input map[string]string) // Slices up the string into a form like this // Each match is put into an array with their capture groups // These arrays are put into another array - // Here is an example: - /* - [][]string len: 4, cap: 10, [ - ["rta=0.024ms;3000.000;5000.000;0; ","rta","0.024","ms","3000.000","5000.000","0",""], - ["rtmax=0.085ms;;;; ","rtmax","0.085","ms","","","",""], - ["rtmin=0.000ms;;;; ","rtmin","0.000","ms","","","",""], - ["pl=0%;80;100;0;100","pl","0","%","80","100","0","100"] - ] - */ + // Example: [][]string len: 4, cap: 10, [ + // ["rta=0.024ms;3000.000;5000.000;0; ","rta","0.024","ms","3000.000","5000.000","0",""], + // ["rtmax=0.085ms;;;; ","rtmax","0.085","ms","","","",""], + // ["rtmin=0.000ms;;;; ","rtmin","0.000","ms","","","",""], + // ["pl=0%;80;100;0;100","pl","0","%","80","100","0","100"] + // ] perfdataStringMatches := regexPerformancelable.FindAllStringSubmatch(perfdataStringErrorsRemoved, -1) currentCheckMultiLabel := "" @@ -279,11 +275,17 @@ func (w *NagiosSpoolfileWorker) PerformanceDataIterator(input map[string]string) } // check if concataneting matches makes up the original string - matchesConcatenated := "" + matchesConcatenatedBuilder := strings.Builder{} for _, matchAndCaptureGroups := range perfdataStringMatches { match := matchAndCaptureGroups[0] - matchesConcatenated += match + _, err := matchesConcatenatedBuilder.WriteString(match) + if err != nil { + log.Warnf("Error when building the matchesConcaatenated string: %s", err.Error()) + close(ch) + return + } } + matchesConcatenated := matchesConcatenatedBuilder.String() if len(matchesConcatenated) > 0 && strings.TrimSpace(matchesConcatenated) != strings.TrimSpace(perfdataString) { log.Warnf("Perfdata matches: '%v' when concatanted come up to be: '%s', and original perfdata string is: '%s' . They are not equal after stripping whitespace from both", perfdataStringMatches, matchesConcatenated, perfdataString) @@ -313,16 +315,15 @@ func (w *NagiosSpoolfileWorker) PerformanceDataIterator(input map[string]string) Service: currentService, Command: currentCommand, Time: currentTime, - PerformanceLabel: perfdataStringMatch[PerformanceDataSliceFields(Label)], - Unit: perfdataStringMatch[PerformanceDataSliceFields(UOM)], + PerformanceLabel: perfdataStringMatch[Label], + Unit: perfdataStringMatch[UOM], Tags: tags, Fields: field, Filterable: target, } if currentCheckMultiLabel != "" { - // if an check_multi prefix was found last time - // test if the current one has also one + // if an check_multi prefix was found last time, test if the current one has also one if potentialNextOne := getCheckMultiRegexMatch(perf.PerformanceLabel); potentialNextOne == "" { // if not put the last one in front the current perf.PerformanceLabel = currentCheckMultiLabel + perf.PerformanceLabel @@ -332,8 +333,7 @@ func (w *NagiosSpoolfileWorker) PerformanceDataIterator(input map[string]string) } } - // perfdataStringMatch might not have all fields like perfdataStringMatch[Crit] available, - // iterate each field until the end + // perfdataStringMatch might not have all fields like perfdataStringMatch[Crit] available, iterate each field until the end for i, data := range perfdataStringMatch { fieldType, err := indexToPerformanceDataSliceField(i) if err != nil { @@ -345,22 +345,22 @@ func (w *NagiosSpoolfileWorker) PerformanceDataIterator(input map[string]string) case RawMatch: case Label: if len(data) > w.perfdataLabelMaxSize { - log.Warnf("Perfdata Label: '%s' is too long with length: %s and longer than the limit: %s. Probably an anomally. Skipping this perfdata item, Host: %v , Service: %v, Perfdata fields: %v", data, len(data), w.perfdataLabelMaxSize, perf.Hostname, perf.Service, perfdataStringMatch) + log.Warnf("Perfdata Label: '%s' is too long with length: %d and longer than the limit: %d. Probably an anomally. Skipping this perfdata item, Host: %v , Service: %v, Perfdata fields: %v", data, len(data), w.perfdataLabelMaxSize, perf.Hostname, perf.Service, perfdataStringMatch) goto perfdataStringMatchLoopEnd } case UOM: if len(data) > w.perfdataUOMMaxLength { - log.Warnf("Perfdata UOM: '%s' is too long with length: %s and longer than the limit: %s. Probably an anomally. Host: %v , Service: %v, Perfdata fields: %v", data, len(data), w.perfdataUOMMaxLength, perf.Hostname, perf.Service, perfdataStringMatch) + log.Warnf("Perfdata UOM: '%s' is too long with length: %d and longer than the limit: %d. Probably an anomally. Host: %v , Service: %v, Perfdata fields: %v", data, len(data), w.perfdataUOMMaxLength, perf.Hostname, perf.Service, perfdataStringMatch) goto perfdataStringMatchLoopEnd } case Value, Min, Max: if len(data) > w.perfdataNumericValuesMaxLength { - log.Warnf("Perfdata field %s: '%s' is too long with length: %s and longer than the limit: %s. Probably an anomally. Host: %v , Service: %v, Perfdata fields: %v", fieldType.String(), data, len(data), w.perfdataNumericValuesMaxLength, perf.Hostname, perf.Service, perfdataStringMatch) + log.Warnf("Perfdata field %s: '%s' is too long with length: %d and longer than the limit: %d. Probably an anomally. Host: %v , Service: %v, Perfdata fields: %v", fieldType.String(), data, len(data), w.perfdataNumericValuesMaxLength, perf.Hostname, perf.Service, perfdataStringMatch) goto perfdataStringMatchLoopEnd } case Warn, Crit: if len(data) > w.perfdataThresholdsMaxLength { - log.Warnf("Perfdata field %s: '%s' is too long with length: %s and longer than the limit: %s. Probably an anomally. Host: %v , Service: %v, Perfdata fields: %v", fieldType.String(), data, len(data), w.perfdataThresholdsMaxLength, perf.Hostname, perf.Service, perfdataStringMatch) + log.Warnf("Perfdata field %s: '%s' is too long with length: %d and longer than the limit: %d. Probably an anomally. Host: %v , Service: %v, Perfdata fields: %v", fieldType.String(), data, len(data), w.perfdataThresholdsMaxLength, perf.Hostname, perf.Service, perfdataStringMatch) goto perfdataStringMatchLoopEnd } } @@ -368,13 +368,11 @@ func (w *NagiosSpoolfileWorker) PerformanceDataIterator(input map[string]string) if data == "" { continue } - - // Anything after here is a number or a range - // Convert all commas to points, to help in the integer/float parsing + // Anything after here is a number or a range, so convert all commas to points to help in the integer/float parsing data = strings.ReplaceAll(data, ",", ".") // Add downtime tag if needed - if fieldType == PerformanceDataSliceFields(Value) && w.livestatusCacheBuilder != nil && w.livestatusCacheBuilder.IsServiceInDowntime(perf.Hostname, perf.Service, input[timet]) { + if fieldType == Value && w.livestatusCacheBuilder != nil && w.livestatusCacheBuilder.IsServiceInDowntime(perf.Hostname, perf.Service, input[timet]) { perf.Tags["downtime"] = "true" } @@ -412,13 +410,13 @@ func (w *NagiosSpoolfileWorker) PerformanceDataIterator(input map[string]string) goto perfdataStringMatchLoopEnd } perf.Fields[fieldType.String()] = helper.StringIntToStringFloat(data) + case RawMatch, Label, UOM: } } ch <- perf - // Skip item without sending it to the channel - perfdataStringMatchLoopEnd: + perfdataStringMatchLoopEnd: // To skip item without sending it to the channel } close(ch) }() diff --git a/pkg/nagflux/filter/Filter_test.go b/pkg/nagflux/filter/Filter_test.go index 40cde08..d0587d0 100644 --- a/pkg/nagflux/filter/Filter_test.go +++ b/pkg/nagflux/filter/Filter_test.go @@ -5,7 +5,6 @@ import ( "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" - "github.com/stretchr/testify/assert" ) diff --git a/pkg/nagflux/helper/elastic.go b/pkg/nagflux/helper/elastic.go index 9669ec0..9d545e0 100644 --- a/pkg/nagflux/helper/elastic.go +++ b/pkg/nagflux/helper/elastic.go @@ -11,6 +11,7 @@ import ( func CreateJSONFromStringMap(input map[string]string) string { str := strings.Builder{} for k, v := range input { + //nolint:staticcheck // cant use fmt.Fprintf() on a strings.Builder str.WriteString(fmt.Sprintf(`,%s:%s`, GenJSONValueString(k), GenJSONValueString(v))) } return str.String() diff --git a/pkg/nagflux/nagflux.go b/pkg/nagflux/nagflux.go index e55c1da..27c9a70 100644 --- a/pkg/nagflux/nagflux.go +++ b/pkg/nagflux/nagflux.go @@ -22,7 +22,6 @@ import ( "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/target/elasticsearch" "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/target/file/jsontarget" "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/target/influx" - "github.com/kdar/factorlog" ) @@ -212,7 +211,6 @@ For further informations / bugs reports: https://github.com/ConSol-Monitoring/na cfg.Main.FileBufferSize, collector.Filterable{Filter: cfg.Main.DefaultTarget}, ) - if err != nil { log.Criticalf("Error when setting up NagiosSpoolfileCollectorFactory: %s", err.Error()) <-quit diff --git a/pkg/nagflux/nagflux_test.go b/pkg/nagflux/nagflux_test.go index 22a5d05..f37ebaa 100644 --- a/pkg/nagflux/nagflux_test.go +++ b/pkg/nagflux/nagflux_test.go @@ -219,7 +219,6 @@ func createTestData(folder, file string, data []testData) { if err := os.MkdirAll(folder, 0o700); err != nil { panic(err) } - //nolint: prealloc // data.input string are connected to bytes, need to precalculate their size. not too trivial fileData := []byte{} for _, data := range data { fileData = append(fileData, []byte(data.input)...) diff --git a/pkg/nagflux/statistics/prometheus.go b/pkg/nagflux/statistics/prometheus.go index 5a412ab..635202f 100644 --- a/pkg/nagflux/statistics/prometheus.go +++ b/pkg/nagflux/statistics/prometheus.go @@ -9,7 +9,6 @@ import ( "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" - "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" ) diff --git a/pkg/nagflux/target/elasticsearch/Connector.go b/pkg/nagflux/target/elasticsearch/Connector.go index 9e596bc..9dc305a 100644 --- a/pkg/nagflux/target/elasticsearch/Connector.go +++ b/pkg/nagflux/target/elasticsearch/Connector.go @@ -10,7 +10,6 @@ import ( "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" - "github.com/kdar/factorlog" ) diff --git a/pkg/nagflux/target/elasticsearch/Worker.go b/pkg/nagflux/target/elasticsearch/Worker.go index 53d2454..4cf5fd3 100644 --- a/pkg/nagflux/target/elasticsearch/Worker.go +++ b/pkg/nagflux/target/elasticsearch/Worker.go @@ -16,7 +16,6 @@ import ( "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/statistics" - "github.com/kdar/factorlog" ) diff --git a/pkg/nagflux/target/file/jsontarget/Worker.go b/pkg/nagflux/target/file/jsontarget/Worker.go index 8afbb21..db5649d 100644 --- a/pkg/nagflux/target/file/jsontarget/Worker.go +++ b/pkg/nagflux/target/file/jsontarget/Worker.go @@ -9,7 +9,6 @@ import ( "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/data" - "github.com/kdar/factorlog" ) diff --git a/pkg/nagflux/target/influx/Connector.go b/pkg/nagflux/target/influx/Connector.go index 9f539b3..86b4c95 100644 --- a/pkg/nagflux/target/influx/Connector.go +++ b/pkg/nagflux/target/influx/Connector.go @@ -14,7 +14,6 @@ import ( "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/data" "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" - "github.com/kdar/factorlog" ) diff --git a/pkg/nagflux/target/influx/Worker.go b/pkg/nagflux/target/influx/Worker.go index 7203672..20a9e24 100644 --- a/pkg/nagflux/target/influx/Worker.go +++ b/pkg/nagflux/target/influx/Worker.go @@ -17,7 +17,6 @@ import ( "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/statistics" - "github.com/kdar/factorlog" ) From 05f457377b60a4fb5e5ddf9580ecdc8427d8939b Mon Sep 17 00:00:00 2001 From: Ahmet Oeztuerk Date: Tue, 10 Mar 2026 18:07:58 +0100 Subject: [PATCH 08/11] update dependencies and go version to 1.26.1 --- Makefile | 4 ++-- go.mod | 12 ++++++------ go.sum | 20 ++++++++++---------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index 3305d3d..2b5c5db 100644 --- a/Makefile +++ b/Makefile @@ -9,8 +9,8 @@ GOVERSION:=$(shell \ ) # also update go.mod files when changing minumum version # find . -name go.mod -MINGOVERSION:=00010025 -MINGOVERSIONSTR:=1.25 +MINGOVERSION:=00010026 +MINGOVERSIONSTR:=1.26 BUILD:=$(shell git rev-parse --short HEAD) # see https://github.com/go-modules-by-example/index/blob/master/010_tools/README.md # and https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module diff --git a/go.mod b/go.mod index 2e345cb..f8c3aa8 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/ConSol-Monitoring/nagflux -go 1.25.7 +go 1.26.1 require ( github.com/appscode/g2 v0.0.0-20190123131438-388ba74fd273 @@ -22,11 +22,11 @@ require ( github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_model v0.6.2 // indirect - github.com/prometheus/common v0.67.4 // indirect - github.com/prometheus/procfs v0.19.2 // indirect - go.yaml.in/yaml/v2 v2.4.3 // indirect - golang.org/x/sys v0.38.0 // indirect - google.golang.org/protobuf v1.36.10 // indirect + github.com/prometheus/common v0.67.5 // indirect + github.com/prometheus/procfs v0.20.1 // indirect + go.yaml.in/yaml/v2 v2.4.4 // indirect + golang.org/x/sys v0.42.0 // indirect + google.golang.org/protobuf v1.36.11 // indirect gopkg.in/robfig/cron.v2 v2.0.0-20150107220207-be2e0b0deed5 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index 7a691fb..636aee8 100644 --- a/go.sum +++ b/go.sum @@ -60,10 +60,10 @@ github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg= github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk= github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE= -github.com/prometheus/common v0.67.4 h1:yR3NqWO1/UyO1w2PhUvXlGQs/PtFmoveVO0KZ4+Lvsc= -github.com/prometheus/common v0.67.4/go.mod h1:gP0fq6YjjNCLssJCQp0yk4M8W6ikLURwkdd/YKtTbyI= -github.com/prometheus/procfs v0.19.2 h1:zUMhqEW66Ex7OXIiDkll3tl9a1ZdilUOd/F6ZXw4Vws= -github.com/prometheus/procfs v0.19.2/go.mod h1:M0aotyiemPhBCM0z5w87kL22CxfcH05ZpYlu+b4J7mw= +github.com/prometheus/common v0.67.5 h1:pIgK94WWlQt1WLwAC5j2ynLaBRDiinoAb86HZHTUGI4= +github.com/prometheus/common v0.67.5/go.mod h1:SjE/0MzDEEAyrdr5Gqc6G+sXI67maCxzaT3A2+HqjUw= +github.com/prometheus/procfs v0.20.1 h1:XwbrGOIplXW/AU3YhIhLODXMJYyC1isLFfYCsTEycfc= +github.com/prometheus/procfs v0.20.1/go.mod h1:o9EMBZGRyvDrSPH1RqdxhojkuXstoe4UlK79eF5TGGo= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= @@ -76,8 +76,8 @@ github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= -go.yaml.in/yaml/v2 v2.4.3 h1:6gvOSjQoTB3vt1l+CU+tSyi/HOjfOjRLJ4YwYZGwRO0= -go.yaml.in/yaml/v2 v2.4.3/go.mod h1:zSxWcmIDjOzPXpjlTTbAsKokqkDNAVtZO0WOMiT90s8= +go.yaml.in/yaml/v2 v2.4.4 h1:tuyd0P+2Ont/d6e2rl3be67goVK4R6deVxCUX5vyPaQ= +go.yaml.in/yaml/v2 v2.4.4/go.mod h1:gMZqIpDtDqOfM0uNfy0SkpRhvUryYH0Z6wdMYcacYXQ= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190422183909-d864b10871cd/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= @@ -87,14 +87,14 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc= -golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo= +golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= gomodules.xyz/password-generator v0.2.4/go.mod h1:TvwYYTx9+P1pPwKQKfZgB/wr2Id9MqAQ3B5auY7reNg= gomodules.xyz/version v0.1.0/go.mod h1:Y8xuV02mL/45psyPKG3NCVOwvAOy6T5Kx0l3rCjKSjU= -google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= -google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= +google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE= +google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= From 5a854549ccd8974021abb1c44fab44a8da4842a6 Mon Sep 17 00:00:00 2001 From: Ahmet Oeztuerk Date: Wed, 11 Mar 2026 11:08:29 +0100 Subject: [PATCH 09/11] move files from pkg/nagflux/ to pkg/ reflects the snclient structure, and makes it easier to work in makefile --- pkg/{nagflux => }/collector/Filterable.go | 0 .../collector/Filterable_test.go | 0 pkg/{nagflux => }/collector/IPrintable.go | 0 pkg/{nagflux => }/collector/ResultQueues.go | 2 +- .../collector/SimplePrintable.go | 2 +- .../collector/livestatus/Cache.go | 0 .../collector/livestatus/CacheBuilder.go | 4 +-- .../collector/livestatus/CacheBuilder_test.go | 2 +- .../collector/livestatus/Cache_test.go | 0 .../collector/livestatus/Collector.go | 12 ++++----- .../collector/livestatus/Collector_test.go | 4 +-- .../collector/livestatus/CommentData.go | 6 ++--- .../collector/livestatus/CommentData_test.go | 4 +-- .../collector/livestatus/Connector.go | 0 .../collector/livestatus/Connector_test.go | 4 +-- .../collector/livestatus/Data.go | 4 +-- .../collector/livestatus/Data_test.go | 2 +- .../collector/livestatus/DowntimeData.go | 6 ++--- .../collector/livestatus/DowntimeData_test.go | 4 +-- .../collector/livestatus/NotificationData.go | 6 ++--- .../livestatus/NotificationData_test.go | 4 +-- .../collector/modgearman/gearmanWorker.go | 16 ++++++------ .../collector/modgearman/secret.go | 0 .../collector/nagflux/NagfluxPrintable.go | 4 +-- .../collector/nagflux/dumpfileCollector.go | 6 ++--- .../collector/nagflux/nagfluxFileCollector.go | 10 +++---- .../spoolfile/nagiosSpoolfileCollector.go | 12 ++++----- .../spoolfile/nagiosSpoolfileWorker.go | 14 +++++----- .../spoolfile/nagiosSpoolfileWorker_test.go | 6 ++--- .../collector/spoolfile/performanceData.go | 6 ++--- pkg/{nagflux => }/config/Config.go | 0 pkg/{nagflux => }/config/ConfigProvider.go | 0 .../config/ConfigProvider_test.go | 0 pkg/{nagflux => }/config/GlobalObjects.go | 2 +- .../config/GlobalObjects_test.go | 2 +- pkg/{nagflux => }/data/Datatype.go | 0 pkg/{nagflux => }/data/Target.go | 0 pkg/{nagflux => }/filter/Filter.go | 2 +- pkg/{nagflux => }/filter/Filter_test.go | 4 +-- pkg/{nagflux => }/helper/config_helper.go | 2 +- .../helper/cryptohelper/aes-ecb.go | 0 .../helper/cryptohelper/aes-ecb_test.go | 0 pkg/{nagflux => }/helper/elastic.go | 2 +- pkg/{nagflux => }/helper/elastic_test.go | 2 +- pkg/{nagflux => }/helper/http.go | 0 pkg/{nagflux => }/helper/influx.go | 2 +- pkg/{nagflux => }/helper/influx_test.go | 2 +- pkg/{nagflux => }/helper/map.go | 0 pkg/{nagflux => }/helper/map_test.go | 0 pkg/{nagflux => }/helper/slice.go | 0 pkg/{nagflux => }/helper/slice_test.go | 0 pkg/{nagflux => }/helper/string.go | 2 +- pkg/{nagflux => }/helper/string_test.go | 0 pkg/{nagflux => }/helper/tcp.go | 0 pkg/{nagflux => }/helper/tcp_test.go | 0 pkg/{nagflux => }/logging/logging.go | 0 pkg/nagflux/nagflux.go | 26 +++++++++---------- pkg/nagflux/nagflux_test.go | 2 +- pkg/{nagflux => }/statistics/prometheus.go | 4 +-- pkg/{nagflux => }/target/IHasWorker.go | 0 .../target/elasticsearch/Connector.go | 8 +++--- .../target/elasticsearch/JSONResult.go | 0 .../target/elasticsearch/Worker.go | 8 +++--- .../target/file/jsontarget/Worker.go | 4 +-- pkg/{nagflux => }/target/influx/Connector.go | 10 +++---- .../target/influx/ShowSeriesResult.go | 0 pkg/{nagflux => }/target/influx/Worker.go | 12 ++++----- 67 files changed, 118 insertions(+), 118 deletions(-) rename pkg/{nagflux => }/collector/Filterable.go (100%) rename pkg/{nagflux => }/collector/Filterable_test.go (100%) rename pkg/{nagflux => }/collector/IPrintable.go (100%) rename pkg/{nagflux => }/collector/ResultQueues.go (52%) rename pkg/{nagflux => }/collector/SimplePrintable.go (89%) rename pkg/{nagflux => }/collector/livestatus/Cache.go (100%) rename pkg/{nagflux => }/collector/livestatus/CacheBuilder.go (97%) rename pkg/{nagflux => }/collector/livestatus/CacheBuilder_test.go (97%) rename pkg/{nagflux => }/collector/livestatus/Cache_test.go (100%) rename pkg/{nagflux => }/collector/livestatus/Collector.go (96%) rename pkg/{nagflux => }/collector/livestatus/Collector_test.go (88%) rename pkg/{nagflux => }/collector/livestatus/CommentData.go (89%) rename pkg/{nagflux => }/collector/livestatus/CommentData_test.go (97%) rename pkg/{nagflux => }/collector/livestatus/Connector.go (100%) rename pkg/{nagflux => }/collector/livestatus/Connector_test.go (96%) rename pkg/{nagflux => }/collector/livestatus/Data.go (94%) rename pkg/{nagflux => }/collector/livestatus/Data_test.go (96%) rename pkg/{nagflux => }/collector/livestatus/DowntimeData.go (91%) rename pkg/{nagflux => }/collector/livestatus/DowntimeData_test.go (94%) rename pkg/{nagflux => }/collector/livestatus/NotificationData.go (92%) rename pkg/{nagflux => }/collector/livestatus/NotificationData_test.go (98%) rename pkg/{nagflux => }/collector/modgearman/gearmanWorker.go (91%) rename pkg/{nagflux => }/collector/modgearman/secret.go (100%) rename pkg/{nagflux => }/collector/nagflux/NagfluxPrintable.go (90%) rename pkg/{nagflux => }/collector/nagflux/dumpfileCollector.go (94%) rename pkg/{nagflux => }/collector/nagflux/nagfluxFileCollector.go (92%) rename pkg/{nagflux => }/collector/spoolfile/nagiosSpoolfileCollector.go (94%) rename pkg/{nagflux => }/collector/spoolfile/nagiosSpoolfileWorker.go (97%) rename pkg/{nagflux => }/collector/spoolfile/nagiosSpoolfileWorker_test.go (99%) rename pkg/{nagflux => }/collector/spoolfile/performanceData.go (92%) rename pkg/{nagflux => }/config/Config.go (100%) rename pkg/{nagflux => }/config/ConfigProvider.go (100%) rename pkg/{nagflux => }/config/ConfigProvider_test.go (100%) rename pkg/{nagflux => }/config/GlobalObjects.go (91%) rename pkg/{nagflux => }/config/GlobalObjects_test.go (90%) rename pkg/{nagflux => }/data/Datatype.go (100%) rename pkg/{nagflux => }/data/Target.go (100%) rename pkg/{nagflux => }/filter/Filter.go (95%) rename pkg/{nagflux => }/filter/Filter_test.go (90%) rename pkg/{nagflux => }/helper/config_helper.go (98%) rename pkg/{nagflux => }/helper/cryptohelper/aes-ecb.go (100%) rename pkg/{nagflux => }/helper/cryptohelper/aes-ecb_test.go (100%) rename pkg/{nagflux => }/helper/elastic.go (95%) rename pkg/{nagflux => }/helper/elastic_test.go (98%) rename pkg/{nagflux => }/helper/http.go (100%) rename pkg/{nagflux => }/helper/influx.go (93%) rename pkg/{nagflux => }/helper/influx_test.go (96%) rename pkg/{nagflux => }/helper/map.go (100%) rename pkg/{nagflux => }/helper/map_test.go (100%) rename pkg/{nagflux => }/helper/slice.go (100%) rename pkg/{nagflux => }/helper/slice_test.go (100%) rename pkg/{nagflux => }/helper/string.go (97%) rename pkg/{nagflux => }/helper/string_test.go (100%) rename pkg/{nagflux => }/helper/tcp.go (100%) rename pkg/{nagflux => }/helper/tcp_test.go (100%) rename pkg/{nagflux => }/logging/logging.go (100%) rename pkg/{nagflux => }/statistics/prometheus.go (97%) rename pkg/{nagflux => }/target/IHasWorker.go (100%) rename pkg/{nagflux => }/target/elasticsearch/Connector.go (96%) rename pkg/{nagflux => }/target/elasticsearch/JSONResult.go (100%) rename pkg/{nagflux => }/target/elasticsearch/Worker.go (97%) rename pkg/{nagflux => }/target/file/jsontarget/Worker.go (96%) rename pkg/{nagflux => }/target/influx/Connector.go (96%) rename pkg/{nagflux => }/target/influx/ShowSeriesResult.go (100%) rename pkg/{nagflux => }/target/influx/Worker.go (96%) diff --git a/pkg/nagflux/collector/Filterable.go b/pkg/collector/Filterable.go similarity index 100% rename from pkg/nagflux/collector/Filterable.go rename to pkg/collector/Filterable.go diff --git a/pkg/nagflux/collector/Filterable_test.go b/pkg/collector/Filterable_test.go similarity index 100% rename from pkg/nagflux/collector/Filterable_test.go rename to pkg/collector/Filterable_test.go diff --git a/pkg/nagflux/collector/IPrintable.go b/pkg/collector/IPrintable.go similarity index 100% rename from pkg/nagflux/collector/IPrintable.go rename to pkg/collector/IPrintable.go diff --git a/pkg/nagflux/collector/ResultQueues.go b/pkg/collector/ResultQueues.go similarity index 52% rename from pkg/nagflux/collector/ResultQueues.go rename to pkg/collector/ResultQueues.go index c2ebd1d..d803c13 100644 --- a/pkg/nagflux/collector/ResultQueues.go +++ b/pkg/collector/ResultQueues.go @@ -1,5 +1,5 @@ package collector -import "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/data" +import "github.com/ConSol-Monitoring/nagflux/pkg/data" type ResultQueues map[data.Target]chan Printable diff --git a/pkg/nagflux/collector/SimplePrintable.go b/pkg/collector/SimplePrintable.go similarity index 89% rename from pkg/nagflux/collector/SimplePrintable.go rename to pkg/collector/SimplePrintable.go index 10ac556..600b934 100644 --- a/pkg/nagflux/collector/SimplePrintable.go +++ b/pkg/collector/SimplePrintable.go @@ -1,6 +1,6 @@ package collector -import "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/data" +import "github.com/ConSol-Monitoring/nagflux/pkg/data" // SimplePrintable can be used to send strings as printable type SimplePrintable struct { diff --git a/pkg/nagflux/collector/livestatus/Cache.go b/pkg/collector/livestatus/Cache.go similarity index 100% rename from pkg/nagflux/collector/livestatus/Cache.go rename to pkg/collector/livestatus/Cache.go diff --git a/pkg/nagflux/collector/livestatus/CacheBuilder.go b/pkg/collector/livestatus/CacheBuilder.go similarity index 97% rename from pkg/nagflux/collector/livestatus/CacheBuilder.go rename to pkg/collector/livestatus/CacheBuilder.go index a2e3ca0..abd56a1 100644 --- a/pkg/nagflux/collector/livestatus/CacheBuilder.go +++ b/pkg/collector/livestatus/CacheBuilder.go @@ -6,8 +6,8 @@ import ( "sync" "time" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/config" + "github.com/ConSol-Monitoring/nagflux/pkg/logging" "github.com/kdar/factorlog" ) diff --git a/pkg/nagflux/collector/livestatus/CacheBuilder_test.go b/pkg/collector/livestatus/CacheBuilder_test.go similarity index 97% rename from pkg/nagflux/collector/livestatus/CacheBuilder_test.go rename to pkg/collector/livestatus/CacheBuilder_test.go index d5d0311..47d2c4f 100644 --- a/pkg/nagflux/collector/livestatus/CacheBuilder_test.go +++ b/pkg/collector/livestatus/CacheBuilder_test.go @@ -4,7 +4,7 @@ import ( "testing" "time" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/logging" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/pkg/nagflux/collector/livestatus/Cache_test.go b/pkg/collector/livestatus/Cache_test.go similarity index 100% rename from pkg/nagflux/collector/livestatus/Cache_test.go rename to pkg/collector/livestatus/Cache_test.go diff --git a/pkg/nagflux/collector/livestatus/Collector.go b/pkg/collector/livestatus/Collector.go similarity index 96% rename from pkg/nagflux/collector/livestatus/Collector.go rename to pkg/collector/livestatus/Collector.go index 9cb4a26..dea5d5c 100644 --- a/pkg/nagflux/collector/livestatus/Collector.go +++ b/pkg/collector/livestatus/Collector.go @@ -6,12 +6,12 @@ import ( "strings" "time" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/data" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/filter" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/collector" + "github.com/ConSol-Monitoring/nagflux/pkg/config" + "github.com/ConSol-Monitoring/nagflux/pkg/data" + "github.com/ConSol-Monitoring/nagflux/pkg/filter" + "github.com/ConSol-Monitoring/nagflux/pkg/helper" + "github.com/ConSol-Monitoring/nagflux/pkg/logging" "github.com/kdar/factorlog" ) diff --git a/pkg/nagflux/collector/livestatus/Collector_test.go b/pkg/collector/livestatus/Collector_test.go similarity index 88% rename from pkg/nagflux/collector/livestatus/Collector_test.go rename to pkg/collector/livestatus/Collector_test.go index 606d318..543a3ff 100644 --- a/pkg/nagflux/collector/livestatus/Collector_test.go +++ b/pkg/collector/livestatus/Collector_test.go @@ -5,8 +5,8 @@ import ( "testing" "time" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/collector" + "github.com/ConSol-Monitoring/nagflux/pkg/logging" ) func TestNewLivestatusCollector(t *testing.T) { diff --git a/pkg/nagflux/collector/livestatus/CommentData.go b/pkg/collector/livestatus/CommentData.go similarity index 89% rename from pkg/nagflux/collector/livestatus/CommentData.go rename to pkg/collector/livestatus/CommentData.go index 9b288dd..cab1b22 100644 --- a/pkg/nagflux/collector/livestatus/CommentData.go +++ b/pkg/collector/livestatus/CommentData.go @@ -1,9 +1,9 @@ package livestatus import ( - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/collector" + "github.com/ConSol-Monitoring/nagflux/pkg/helper" + "github.com/ConSol-Monitoring/nagflux/pkg/logging" ) // CommentData adds Comments types to the livestatus data diff --git a/pkg/nagflux/collector/livestatus/CommentData_test.go b/pkg/collector/livestatus/CommentData_test.go similarity index 97% rename from pkg/nagflux/collector/livestatus/CommentData_test.go rename to pkg/collector/livestatus/CommentData_test.go index 69e1814..fc2a76f 100644 --- a/pkg/nagflux/collector/livestatus/CommentData_test.go +++ b/pkg/collector/livestatus/CommentData_test.go @@ -3,8 +3,8 @@ package livestatus import ( "testing" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/config" + "github.com/ConSol-Monitoring/nagflux/pkg/logging" ) var PrintCommentData = []struct { diff --git a/pkg/nagflux/collector/livestatus/Connector.go b/pkg/collector/livestatus/Connector.go similarity index 100% rename from pkg/nagflux/collector/livestatus/Connector.go rename to pkg/collector/livestatus/Connector.go diff --git a/pkg/nagflux/collector/livestatus/Connector_test.go b/pkg/collector/livestatus/Connector_test.go similarity index 96% rename from pkg/nagflux/collector/livestatus/Connector_test.go rename to pkg/collector/livestatus/Connector_test.go index 8257721..b3cf552 100644 --- a/pkg/nagflux/collector/livestatus/Connector_test.go +++ b/pkg/collector/livestatus/Connector_test.go @@ -9,8 +9,8 @@ import ( "testing" "time" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/helper" + "github.com/ConSol-Monitoring/nagflux/pkg/logging" "github.com/stretchr/testify/assert" ) diff --git a/pkg/nagflux/collector/livestatus/Data.go b/pkg/collector/livestatus/Data.go similarity index 94% rename from pkg/nagflux/collector/livestatus/Data.go rename to pkg/collector/livestatus/Data.go index edc2b36..43b8ccc 100644 --- a/pkg/nagflux/collector/livestatus/Data.go +++ b/pkg/collector/livestatus/Data.go @@ -4,8 +4,8 @@ import ( "fmt" "strings" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" + "github.com/ConSol-Monitoring/nagflux/pkg/config" + "github.com/ConSol-Monitoring/nagflux/pkg/helper" ) // Data contains basic data extracted from livestatusqueries. diff --git a/pkg/nagflux/collector/livestatus/Data_test.go b/pkg/collector/livestatus/Data_test.go similarity index 96% rename from pkg/nagflux/collector/livestatus/Data_test.go rename to pkg/collector/livestatus/Data_test.go index 142bb48..daff428 100644 --- a/pkg/nagflux/collector/livestatus/Data_test.go +++ b/pkg/collector/livestatus/Data_test.go @@ -5,7 +5,7 @@ import ( "reflect" "testing" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" + "github.com/ConSol-Monitoring/nagflux/pkg/helper" ) func TestDataSanitizeValues(t *testing.T) { diff --git a/pkg/nagflux/collector/livestatus/DowntimeData.go b/pkg/collector/livestatus/DowntimeData.go similarity index 91% rename from pkg/nagflux/collector/livestatus/DowntimeData.go rename to pkg/collector/livestatus/DowntimeData.go index 8c8d783..f4a44f1 100644 --- a/pkg/nagflux/collector/livestatus/DowntimeData.go +++ b/pkg/collector/livestatus/DowntimeData.go @@ -4,9 +4,9 @@ import ( "fmt" "strings" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/collector" + "github.com/ConSol-Monitoring/nagflux/pkg/helper" + "github.com/ConSol-Monitoring/nagflux/pkg/logging" ) // DowntimeData adds Comments types to the livestatus data diff --git a/pkg/nagflux/collector/livestatus/DowntimeData_test.go b/pkg/collector/livestatus/DowntimeData_test.go similarity index 94% rename from pkg/nagflux/collector/livestatus/DowntimeData_test.go rename to pkg/collector/livestatus/DowntimeData_test.go index 1cc67be..74f6fd7 100644 --- a/pkg/nagflux/collector/livestatus/DowntimeData_test.go +++ b/pkg/collector/livestatus/DowntimeData_test.go @@ -3,8 +3,8 @@ package livestatus import ( "testing" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/config" + "github.com/ConSol-Monitoring/nagflux/pkg/logging" "github.com/stretchr/testify/assert" ) diff --git a/pkg/nagflux/collector/livestatus/NotificationData.go b/pkg/collector/livestatus/NotificationData.go similarity index 92% rename from pkg/nagflux/collector/livestatus/NotificationData.go rename to pkg/collector/livestatus/NotificationData.go index 16e1279..975f04a 100644 --- a/pkg/nagflux/collector/livestatus/NotificationData.go +++ b/pkg/collector/livestatus/NotificationData.go @@ -4,9 +4,9 @@ import ( "fmt" "strings" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/collector" + "github.com/ConSol-Monitoring/nagflux/pkg/helper" + "github.com/ConSol-Monitoring/nagflux/pkg/logging" ) // NotificationData adds notification types to the livestatus data diff --git a/pkg/nagflux/collector/livestatus/NotificationData_test.go b/pkg/collector/livestatus/NotificationData_test.go similarity index 98% rename from pkg/nagflux/collector/livestatus/NotificationData_test.go rename to pkg/collector/livestatus/NotificationData_test.go index 444ff6b..062c2f7 100644 --- a/pkg/nagflux/collector/livestatus/NotificationData_test.go +++ b/pkg/collector/livestatus/NotificationData_test.go @@ -3,8 +3,8 @@ package livestatus import ( "testing" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/config" + "github.com/ConSol-Monitoring/nagflux/pkg/logging" ) func TestSanitizeValuesNotification(t *testing.T) { diff --git a/pkg/nagflux/collector/modgearman/gearmanWorker.go b/pkg/collector/modgearman/gearmanWorker.go similarity index 91% rename from pkg/nagflux/collector/modgearman/gearmanWorker.go rename to pkg/collector/modgearman/gearmanWorker.go index e18a904..3360718 100644 --- a/pkg/nagflux/collector/modgearman/gearmanWorker.go +++ b/pkg/collector/modgearman/gearmanWorker.go @@ -4,14 +4,14 @@ import ( "fmt" "time" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector/livestatus" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector/spoolfile" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/filter" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper/cryptohelper" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/collector" + "github.com/ConSol-Monitoring/nagflux/pkg/collector/livestatus" + "github.com/ConSol-Monitoring/nagflux/pkg/collector/spoolfile" + "github.com/ConSol-Monitoring/nagflux/pkg/config" + "github.com/ConSol-Monitoring/nagflux/pkg/filter" + "github.com/ConSol-Monitoring/nagflux/pkg/helper" + "github.com/ConSol-Monitoring/nagflux/pkg/helper/cryptohelper" + "github.com/ConSol-Monitoring/nagflux/pkg/logging" libworker "github.com/appscode/g2/worker" "github.com/kdar/factorlog" ) diff --git a/pkg/nagflux/collector/modgearman/secret.go b/pkg/collector/modgearman/secret.go similarity index 100% rename from pkg/nagflux/collector/modgearman/secret.go rename to pkg/collector/modgearman/secret.go diff --git a/pkg/nagflux/collector/nagflux/NagfluxPrintable.go b/pkg/collector/nagflux/NagfluxPrintable.go similarity index 90% rename from pkg/nagflux/collector/nagflux/NagfluxPrintable.go rename to pkg/collector/nagflux/NagfluxPrintable.go index cf76ba6..415522e 100644 --- a/pkg/nagflux/collector/nagflux/NagfluxPrintable.go +++ b/pkg/collector/nagflux/NagfluxPrintable.go @@ -3,8 +3,8 @@ package nagflux import ( "fmt" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" + "github.com/ConSol-Monitoring/nagflux/pkg/collector" + "github.com/ConSol-Monitoring/nagflux/pkg/helper" ) // Printable converts from nagfluxfile format to X diff --git a/pkg/nagflux/collector/nagflux/dumpfileCollector.go b/pkg/collector/nagflux/dumpfileCollector.go similarity index 94% rename from pkg/nagflux/collector/nagflux/dumpfileCollector.go rename to pkg/collector/nagflux/dumpfileCollector.go index 0926c50..7cf00a9 100644 --- a/pkg/nagflux/collector/nagflux/dumpfileCollector.go +++ b/pkg/collector/nagflux/dumpfileCollector.go @@ -8,9 +8,9 @@ import ( "os" "time" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/data" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/collector" + "github.com/ConSol-Monitoring/nagflux/pkg/data" + "github.com/ConSol-Monitoring/nagflux/pkg/logging" "github.com/kdar/factorlog" ) diff --git a/pkg/nagflux/collector/nagflux/nagfluxFileCollector.go b/pkg/collector/nagflux/nagfluxFileCollector.go similarity index 92% rename from pkg/nagflux/collector/nagflux/nagfluxFileCollector.go rename to pkg/collector/nagflux/nagfluxFileCollector.go index 3b1246b..ae32bd8 100644 --- a/pkg/nagflux/collector/nagflux/nagfluxFileCollector.go +++ b/pkg/collector/nagflux/nagfluxFileCollector.go @@ -5,11 +5,11 @@ import ( "os" "time" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector/spoolfile" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/collector" + "github.com/ConSol-Monitoring/nagflux/pkg/collector/spoolfile" + "github.com/ConSol-Monitoring/nagflux/pkg/config" + "github.com/ConSol-Monitoring/nagflux/pkg/helper" + "github.com/ConSol-Monitoring/nagflux/pkg/logging" "github.com/kdar/factorlog" ) diff --git a/pkg/nagflux/collector/spoolfile/nagiosSpoolfileCollector.go b/pkg/collector/spoolfile/nagiosSpoolfileCollector.go similarity index 94% rename from pkg/nagflux/collector/spoolfile/nagiosSpoolfileCollector.go rename to pkg/collector/spoolfile/nagiosSpoolfileCollector.go index a85f76c..a2624d8 100644 --- a/pkg/nagflux/collector/spoolfile/nagiosSpoolfileCollector.go +++ b/pkg/collector/spoolfile/nagiosSpoolfileCollector.go @@ -6,12 +6,12 @@ import ( "path" "time" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector/livestatus" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/statistics" + "github.com/ConSol-Monitoring/nagflux/pkg/collector" + "github.com/ConSol-Monitoring/nagflux/pkg/collector/livestatus" + "github.com/ConSol-Monitoring/nagflux/pkg/config" + "github.com/ConSol-Monitoring/nagflux/pkg/helper" + "github.com/ConSol-Monitoring/nagflux/pkg/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/statistics" ) const ( diff --git a/pkg/nagflux/collector/spoolfile/nagiosSpoolfileWorker.go b/pkg/collector/spoolfile/nagiosSpoolfileWorker.go similarity index 97% rename from pkg/nagflux/collector/spoolfile/nagiosSpoolfileWorker.go rename to pkg/collector/spoolfile/nagiosSpoolfileWorker.go index 6ff8d0f..f988a6e 100644 --- a/pkg/nagflux/collector/spoolfile/nagiosSpoolfileWorker.go +++ b/pkg/collector/spoolfile/nagiosSpoolfileWorker.go @@ -11,13 +11,13 @@ import ( "strings" "time" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector/livestatus" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/filter" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/statistics" + "github.com/ConSol-Monitoring/nagflux/pkg/collector" + "github.com/ConSol-Monitoring/nagflux/pkg/collector/livestatus" + "github.com/ConSol-Monitoring/nagflux/pkg/config" + "github.com/ConSol-Monitoring/nagflux/pkg/filter" + "github.com/ConSol-Monitoring/nagflux/pkg/helper" + "github.com/ConSol-Monitoring/nagflux/pkg/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/statistics" "github.com/kdar/factorlog" ) diff --git a/pkg/nagflux/collector/spoolfile/nagiosSpoolfileWorker_test.go b/pkg/collector/spoolfile/nagiosSpoolfileWorker_test.go similarity index 99% rename from pkg/nagflux/collector/spoolfile/nagiosSpoolfileWorker_test.go rename to pkg/collector/spoolfile/nagiosSpoolfileWorker_test.go index 1410c2c..a1dd9cb 100644 --- a/pkg/nagflux/collector/spoolfile/nagiosSpoolfileWorker_test.go +++ b/pkg/collector/spoolfile/nagiosSpoolfileWorker_test.go @@ -3,9 +3,9 @@ package spoolfile import ( "testing" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" + "github.com/ConSol-Monitoring/nagflux/pkg/collector" + "github.com/ConSol-Monitoring/nagflux/pkg/config" + "github.com/ConSol-Monitoring/nagflux/pkg/helper" "github.com/stretchr/testify/assert" ) diff --git a/pkg/nagflux/collector/spoolfile/performanceData.go b/pkg/collector/spoolfile/performanceData.go similarity index 92% rename from pkg/nagflux/collector/spoolfile/performanceData.go rename to pkg/collector/spoolfile/performanceData.go index 64954cb..0bd81ef 100644 --- a/pkg/nagflux/collector/spoolfile/performanceData.go +++ b/pkg/collector/spoolfile/performanceData.go @@ -3,9 +3,9 @@ package spoolfile import ( "fmt" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" + "github.com/ConSol-Monitoring/nagflux/pkg/collector" + "github.com/ConSol-Monitoring/nagflux/pkg/config" + "github.com/ConSol-Monitoring/nagflux/pkg/helper" ) // PerformanceData represents the nagios perfdata diff --git a/pkg/nagflux/config/Config.go b/pkg/config/Config.go similarity index 100% rename from pkg/nagflux/config/Config.go rename to pkg/config/Config.go diff --git a/pkg/nagflux/config/ConfigProvider.go b/pkg/config/ConfigProvider.go similarity index 100% rename from pkg/nagflux/config/ConfigProvider.go rename to pkg/config/ConfigProvider.go diff --git a/pkg/nagflux/config/ConfigProvider_test.go b/pkg/config/ConfigProvider_test.go similarity index 100% rename from pkg/nagflux/config/ConfigProvider_test.go rename to pkg/config/ConfigProvider_test.go diff --git a/pkg/nagflux/config/GlobalObjects.go b/pkg/config/GlobalObjects.go similarity index 91% rename from pkg/nagflux/config/GlobalObjects.go rename to pkg/config/GlobalObjects.go index 6d6b4ae..89bb469 100644 --- a/pkg/nagflux/config/GlobalObjects.go +++ b/pkg/config/GlobalObjects.go @@ -3,7 +3,7 @@ package config import ( "sync" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/data" + "github.com/ConSol-Monitoring/nagflux/pkg/data" ) // PauseMap is a map to store if an target requested pause or not diff --git a/pkg/nagflux/config/GlobalObjects_test.go b/pkg/config/GlobalObjects_test.go similarity index 90% rename from pkg/nagflux/config/GlobalObjects_test.go rename to pkg/config/GlobalObjects_test.go index 7dd4298..63f9516 100644 --- a/pkg/nagflux/config/GlobalObjects_test.go +++ b/pkg/config/GlobalObjects_test.go @@ -3,7 +3,7 @@ package config import ( "testing" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/data" + "github.com/ConSol-Monitoring/nagflux/pkg/data" ) func TestStoreValue(t *testing.T) { diff --git a/pkg/nagflux/data/Datatype.go b/pkg/data/Datatype.go similarity index 100% rename from pkg/nagflux/data/Datatype.go rename to pkg/data/Datatype.go diff --git a/pkg/nagflux/data/Target.go b/pkg/data/Target.go similarity index 100% rename from pkg/nagflux/data/Target.go rename to pkg/data/Target.go diff --git a/pkg/nagflux/filter/Filter.go b/pkg/filter/Filter.go similarity index 95% rename from pkg/nagflux/filter/Filter.go rename to pkg/filter/Filter.go index b88e856..f567b46 100644 --- a/pkg/nagflux/filter/Filter.go +++ b/pkg/filter/Filter.go @@ -5,7 +5,7 @@ import ( "strings" "sync" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/logging" ) type Processor struct { diff --git a/pkg/nagflux/filter/Filter_test.go b/pkg/filter/Filter_test.go similarity index 90% rename from pkg/nagflux/filter/Filter_test.go rename to pkg/filter/Filter_test.go index d0587d0..f5e8637 100644 --- a/pkg/nagflux/filter/Filter_test.go +++ b/pkg/filter/Filter_test.go @@ -3,8 +3,8 @@ package filter import ( "testing" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/config" + "github.com/ConSol-Monitoring/nagflux/pkg/logging" "github.com/stretchr/testify/assert" ) diff --git a/pkg/nagflux/helper/config_helper.go b/pkg/helper/config_helper.go similarity index 98% rename from pkg/nagflux/helper/config_helper.go rename to pkg/helper/config_helper.go index 38dd180..0d1995c 100644 --- a/pkg/nagflux/helper/config_helper.go +++ b/pkg/helper/config_helper.go @@ -4,7 +4,7 @@ import ( "reflect" "strings" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/logging" ) // Config parser tries to populate the Config struct with values from config file diff --git a/pkg/nagflux/helper/cryptohelper/aes-ecb.go b/pkg/helper/cryptohelper/aes-ecb.go similarity index 100% rename from pkg/nagflux/helper/cryptohelper/aes-ecb.go rename to pkg/helper/cryptohelper/aes-ecb.go diff --git a/pkg/nagflux/helper/cryptohelper/aes-ecb_test.go b/pkg/helper/cryptohelper/aes-ecb_test.go similarity index 100% rename from pkg/nagflux/helper/cryptohelper/aes-ecb_test.go rename to pkg/helper/cryptohelper/aes-ecb_test.go diff --git a/pkg/nagflux/helper/elastic.go b/pkg/helper/elastic.go similarity index 95% rename from pkg/nagflux/helper/elastic.go rename to pkg/helper/elastic.go index 9d545e0..f3c1eee 100644 --- a/pkg/nagflux/helper/elastic.go +++ b/pkg/helper/elastic.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" + "github.com/ConSol-Monitoring/nagflux/pkg/config" ) // CreateJSONFromStringMap creates a part of a JSON object diff --git a/pkg/nagflux/helper/elastic_test.go b/pkg/helper/elastic_test.go similarity index 98% rename from pkg/nagflux/helper/elastic_test.go rename to pkg/helper/elastic_test.go index de4c37b..ed9c4dd 100644 --- a/pkg/nagflux/helper/elastic_test.go +++ b/pkg/helper/elastic_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" + "github.com/ConSol-Monitoring/nagflux/pkg/config" ) var CreateJSONFromStringMapData = []struct { diff --git a/pkg/nagflux/helper/http.go b/pkg/helper/http.go similarity index 100% rename from pkg/nagflux/helper/http.go rename to pkg/helper/http.go diff --git a/pkg/nagflux/helper/influx.go b/pkg/helper/influx.go similarity index 93% rename from pkg/nagflux/helper/influx.go rename to pkg/helper/influx.go index 3225dfe..b99df5a 100644 --- a/pkg/nagflux/helper/influx.go +++ b/pkg/helper/influx.go @@ -3,7 +3,7 @@ package helper import ( "strings" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" + "github.com/ConSol-Monitoring/nagflux/pkg/config" ) // SanitizeInfluxInput adds backslashes to special chars. diff --git a/pkg/nagflux/helper/influx_test.go b/pkg/helper/influx_test.go similarity index 96% rename from pkg/nagflux/helper/influx_test.go rename to pkg/helper/influx_test.go index 6c847f9..d837684 100644 --- a/pkg/nagflux/helper/influx_test.go +++ b/pkg/helper/influx_test.go @@ -4,7 +4,7 @@ import ( "reflect" "testing" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" + "github.com/ConSol-Monitoring/nagflux/pkg/config" ) var SanitizeInfluxData = []struct { diff --git a/pkg/nagflux/helper/map.go b/pkg/helper/map.go similarity index 100% rename from pkg/nagflux/helper/map.go rename to pkg/helper/map.go diff --git a/pkg/nagflux/helper/map_test.go b/pkg/helper/map_test.go similarity index 100% rename from pkg/nagflux/helper/map_test.go rename to pkg/helper/map_test.go diff --git a/pkg/nagflux/helper/slice.go b/pkg/helper/slice.go similarity index 100% rename from pkg/nagflux/helper/slice.go rename to pkg/helper/slice.go diff --git a/pkg/nagflux/helper/slice_test.go b/pkg/helper/slice_test.go similarity index 100% rename from pkg/nagflux/helper/slice_test.go rename to pkg/helper/slice_test.go diff --git a/pkg/nagflux/helper/string.go b/pkg/helper/string.go similarity index 97% rename from pkg/nagflux/helper/string.go rename to pkg/helper/string.go index 37c1059..2647690 100644 --- a/pkg/nagflux/helper/string.go +++ b/pkg/helper/string.go @@ -6,7 +6,7 @@ import ( "strings" "time" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/logging" ) // IsStringANumber returns true if the given string can be casted to int or float. diff --git a/pkg/nagflux/helper/string_test.go b/pkg/helper/string_test.go similarity index 100% rename from pkg/nagflux/helper/string_test.go rename to pkg/helper/string_test.go diff --git a/pkg/nagflux/helper/tcp.go b/pkg/helper/tcp.go similarity index 100% rename from pkg/nagflux/helper/tcp.go rename to pkg/helper/tcp.go diff --git a/pkg/nagflux/helper/tcp_test.go b/pkg/helper/tcp_test.go similarity index 100% rename from pkg/nagflux/helper/tcp_test.go rename to pkg/helper/tcp_test.go diff --git a/pkg/nagflux/logging/logging.go b/pkg/logging/logging.go similarity index 100% rename from pkg/nagflux/logging/logging.go rename to pkg/logging/logging.go diff --git a/pkg/nagflux/nagflux.go b/pkg/nagflux/nagflux.go index 27c9a70..8a8da38 100644 --- a/pkg/nagflux/nagflux.go +++ b/pkg/nagflux/nagflux.go @@ -9,19 +9,19 @@ import ( "syscall" "time" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector/livestatus" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector/modgearman" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector/nagflux" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector/spoolfile" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/data" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/statistics" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/target/elasticsearch" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/target/file/jsontarget" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/target/influx" + "github.com/ConSol-Monitoring/nagflux/pkg/collector" + "github.com/ConSol-Monitoring/nagflux/pkg/collector/livestatus" + "github.com/ConSol-Monitoring/nagflux/pkg/collector/modgearman" + "github.com/ConSol-Monitoring/nagflux/pkg/collector/nagflux" + "github.com/ConSol-Monitoring/nagflux/pkg/collector/spoolfile" + "github.com/ConSol-Monitoring/nagflux/pkg/config" + "github.com/ConSol-Monitoring/nagflux/pkg/data" + "github.com/ConSol-Monitoring/nagflux/pkg/helper" + "github.com/ConSol-Monitoring/nagflux/pkg/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/statistics" + "github.com/ConSol-Monitoring/nagflux/pkg/target/elasticsearch" + "github.com/ConSol-Monitoring/nagflux/pkg/target/file/jsontarget" + "github.com/ConSol-Monitoring/nagflux/pkg/target/influx" "github.com/kdar/factorlog" ) diff --git a/pkg/nagflux/nagflux_test.go b/pkg/nagflux/nagflux_test.go index f37ebaa..6780ca9 100644 --- a/pkg/nagflux/nagflux_test.go +++ b/pkg/nagflux/nagflux_test.go @@ -12,7 +12,7 @@ import ( "testing" "time" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/target/influx" + "github.com/ConSol-Monitoring/nagflux/pkg/target/influx" ) const ( diff --git a/pkg/nagflux/statistics/prometheus.go b/pkg/statistics/prometheus.go similarity index 97% rename from pkg/nagflux/statistics/prometheus.go rename to pkg/statistics/prometheus.go index 635202f..66dfca5 100644 --- a/pkg/nagflux/statistics/prometheus.go +++ b/pkg/statistics/prometheus.go @@ -7,8 +7,8 @@ import ( "sync" "time" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/collector" + "github.com/ConSol-Monitoring/nagflux/pkg/logging" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" ) diff --git a/pkg/nagflux/target/IHasWorker.go b/pkg/target/IHasWorker.go similarity index 100% rename from pkg/nagflux/target/IHasWorker.go rename to pkg/target/IHasWorker.go diff --git a/pkg/nagflux/target/elasticsearch/Connector.go b/pkg/target/elasticsearch/Connector.go similarity index 96% rename from pkg/nagflux/target/elasticsearch/Connector.go rename to pkg/target/elasticsearch/Connector.go index 9dc305a..2eb56ae 100644 --- a/pkg/nagflux/target/elasticsearch/Connector.go +++ b/pkg/target/elasticsearch/Connector.go @@ -6,10 +6,10 @@ import ( "strings" "time" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/collector" + "github.com/ConSol-Monitoring/nagflux/pkg/config" + "github.com/ConSol-Monitoring/nagflux/pkg/helper" + "github.com/ConSol-Monitoring/nagflux/pkg/logging" "github.com/kdar/factorlog" ) diff --git a/pkg/nagflux/target/elasticsearch/JSONResult.go b/pkg/target/elasticsearch/JSONResult.go similarity index 100% rename from pkg/nagflux/target/elasticsearch/JSONResult.go rename to pkg/target/elasticsearch/JSONResult.go diff --git a/pkg/nagflux/target/elasticsearch/Worker.go b/pkg/target/elasticsearch/Worker.go similarity index 97% rename from pkg/nagflux/target/elasticsearch/Worker.go rename to pkg/target/elasticsearch/Worker.go index 4cf5fd3..06c7535 100644 --- a/pkg/nagflux/target/elasticsearch/Worker.go +++ b/pkg/target/elasticsearch/Worker.go @@ -12,10 +12,10 @@ import ( "sync" "time" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/statistics" + "github.com/ConSol-Monitoring/nagflux/pkg/collector" + "github.com/ConSol-Monitoring/nagflux/pkg/helper" + "github.com/ConSol-Monitoring/nagflux/pkg/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/statistics" "github.com/kdar/factorlog" ) diff --git a/pkg/nagflux/target/file/jsontarget/Worker.go b/pkg/target/file/jsontarget/Worker.go similarity index 96% rename from pkg/nagflux/target/file/jsontarget/Worker.go rename to pkg/target/file/jsontarget/Worker.go index db5649d..573d19d 100644 --- a/pkg/nagflux/target/file/jsontarget/Worker.go +++ b/pkg/target/file/jsontarget/Worker.go @@ -7,8 +7,8 @@ import ( "path" "time" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/data" + "github.com/ConSol-Monitoring/nagflux/pkg/collector" + "github.com/ConSol-Monitoring/nagflux/pkg/data" "github.com/kdar/factorlog" ) diff --git a/pkg/nagflux/target/influx/Connector.go b/pkg/target/influx/Connector.go similarity index 96% rename from pkg/nagflux/target/influx/Connector.go rename to pkg/target/influx/Connector.go index 86b4c95..d8d4199 100644 --- a/pkg/nagflux/target/influx/Connector.go +++ b/pkg/target/influx/Connector.go @@ -9,11 +9,11 @@ import ( "regexp" "time" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/config" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/data" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/collector" + "github.com/ConSol-Monitoring/nagflux/pkg/config" + "github.com/ConSol-Monitoring/nagflux/pkg/data" + "github.com/ConSol-Monitoring/nagflux/pkg/helper" + "github.com/ConSol-Monitoring/nagflux/pkg/logging" "github.com/kdar/factorlog" ) diff --git a/pkg/nagflux/target/influx/ShowSeriesResult.go b/pkg/target/influx/ShowSeriesResult.go similarity index 100% rename from pkg/nagflux/target/influx/ShowSeriesResult.go rename to pkg/target/influx/ShowSeriesResult.go diff --git a/pkg/nagflux/target/influx/Worker.go b/pkg/target/influx/Worker.go similarity index 96% rename from pkg/nagflux/target/influx/Worker.go rename to pkg/target/influx/Worker.go index 20a9e24..42e5b00 100644 --- a/pkg/nagflux/target/influx/Worker.go +++ b/pkg/target/influx/Worker.go @@ -11,12 +11,12 @@ import ( "sync" "time" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/collector/nagflux" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/data" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/helper" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/logging" - "github.com/ConSol-Monitoring/nagflux/pkg/nagflux/statistics" + "github.com/ConSol-Monitoring/nagflux/pkg/collector" + "github.com/ConSol-Monitoring/nagflux/pkg/collector/nagflux" + "github.com/ConSol-Monitoring/nagflux/pkg/data" + "github.com/ConSol-Monitoring/nagflux/pkg/helper" + "github.com/ConSol-Monitoring/nagflux/pkg/logging" + "github.com/ConSol-Monitoring/nagflux/pkg/statistics" "github.com/kdar/factorlog" ) From 477805c61498e7e1e1c349879db2f6a16dd34385 Mon Sep 17 00:00:00 2001 From: Ahmet Oeztuerk Date: Wed, 11 Mar 2026 11:09:35 +0100 Subject: [PATCH 10/11] makefile tests: fix package discovery --- Makefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 2b5c5db..f103441 100644 --- a/Makefile +++ b/Makefile @@ -84,7 +84,7 @@ build-watch: vendor tools test: dump vendor - $(GO) test -short -v $(TEST_FLAGS) pkg/... + $(GO) test -short -v $(TEST_FLAGS) ./pkg/* if grep -Irn TODO: ./cmd/ ./pkg/; then exit 1; fi if grep -Irn Dump ./cmd/ ./pkg/ | $(DUMPEXCEPTIONS); then exit 1; fi @@ -135,18 +135,18 @@ citest: tools vendor # benchmark: - $(GO) test $(TEST_FLAGS) -v -bench=B\* -run=^$$ -benchmem pkg/... + $(GO) test $(TEST_FLAGS) -v -bench=B\* -run=^$$ -benchmem ./pkg/* racetest: - $(GO) test -race -short $(TEST_FLAGS) -coverprofile=coverage.txt -covermode=atomic -gcflags "-d=checkptr=0" pkg/... + $(GO) test -race -short $(TEST_FLAGS) -coverprofile=coverage.txt -covermode=atomic -gcflags "-d=checkptr=0" ./pkg/* covertest: - $(GO) test -v $(TEST_FLAGS) -coverprofile=cover.out pkg/... + $(GO) test -v $(TEST_FLAGS) -coverprofile=cover.out ./pkg/* $(GO) tool cover -func=cover.out $(GO) tool cover -html=cover.out -o coverage.html coverweb: - $(GO) test -v $(TEST_FLAGS) -coverprofile=cover.out pkg/... + $(GO) test -v $(TEST_FLAGS) -coverprofile=cover.out ./pkg/* $(GO) tool cover -html=cover.out clean: From 72ce4a1d8e63ece8ca80112ed182d3334a068e78 Mon Sep 17 00:00:00 2001 From: Ahmet Oeztuerk Date: Wed, 11 Mar 2026 12:28:53 +0100 Subject: [PATCH 11/11] staticcheck: use fmt.Prinftf instead of strings.Builder.WriteString --- pkg/helper/elastic.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/helper/elastic.go b/pkg/helper/elastic.go index f3c1eee..4b32357 100644 --- a/pkg/helper/elastic.go +++ b/pkg/helper/elastic.go @@ -11,8 +11,7 @@ import ( func CreateJSONFromStringMap(input map[string]string) string { str := strings.Builder{} for k, v := range input { - //nolint:staticcheck // cant use fmt.Fprintf() on a strings.Builder - str.WriteString(fmt.Sprintf(`,%s:%s`, GenJSONValueString(k), GenJSONValueString(v))) + fmt.Fprintf(&str, ",%s:%s", GenJSONValueString(k), GenJSONValueString(v)) } return str.String() }