Skip to content

Better perfdata parsing and other improvements#10

Merged
sni merged 11 commits intomasterfrom
nagios-perfdata-parsing-improvements
Mar 11, 2026
Merged

Better perfdata parsing and other improvements#10
sni merged 11 commits intomasterfrom
nagios-perfdata-parsing-improvements

Conversation

@inqrphl
Copy link

@inqrphl inqrphl commented Mar 10, 2026

Perfdata related improvements

  • Add explanations to the regexes used in the parser
  • Use '' when specifying all non-special characters in the regex, including capture fields. No need to concern if a comma, semicolon etc. is a special character
  • Convert some German leftover names to English
  • Add example value of perfdata string regex match
  • Use Enum to browse perdata fields like Value, UOM, Warn, Crit, Min, Max instead of a string keyed map, clearer to read
  • Revise the perdata reading logic, use guards and skip early where possible instead of adding more nested code
  • Add max length filters to each field of the perfdata: value, uom, warn, crit, min, max , the max lengths are configurable from the config line
  • Move config parsing of NagiosSpoolfiles from main function to nagiosCollectorFactory. Main function only parses to check if its enabled, the factory looks through the config. Removes clutter from the main function.
  • Once perfdata values are read from the passed SERVICEPERFDATA, a regex is used to extract different perfdata groups and fields. After the regex match, concatenate the raw matches and see if it makes up the original string. This finds cases where non-digit characters were hanging after the Min value of the last perfdata group

General improvements

  • Fix package structure, now each module is under github.com/ConSol-Monitoring/nagflux/ .
  • No need to use rewrite hacks in go.mod . This also fixes the problem where the package itself had to be vendored since building nagflux did not use sources under pkg/ , it wrongly used the vendored nagflux sources under vendor/
  • Update to golang 1.26.1 , update dependencies including the vulnerable sys package
  • Update golangci lint to 2.11.3 , removes some false positives

Ahmet Oeztuerk added 10 commits March 6, 2026 17:26
- 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
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
if they match the original strings

this detects if there are letters after the last perfdata value
reflects the snclient structure, and makes it easier to work in makefile
@inqrphl inqrphl force-pushed the nagios-perfdata-parsing-improvements branch from ba73522 to 477805c Compare March 11, 2026 10:16
Copy link
Author

@inqrphl inqrphl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed changes that happened due to package renaming, file moving or golangci-lint updates.

Important changes are in other files

@sni sni merged commit 318b37d into master Mar 11, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants