Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Threshold checks aren't implemented/don't work #176

Closed
infraweavers opened this issue Jan 9, 2023 · 2 comments · Fixed by #181
Closed

Threshold checks aren't implemented/don't work #176

infraweavers opened this issue Jan 9, 2023 · 2 comments · Fixed by #181

Comments

@infraweavers
Copy link

infraweavers commented Jan 9, 2023

Hiya,

Just been converting some of our slower perl checks over to golang, hoped to use this library as a drop-in replacement for https://metacpan.org/dist/Monitoring-Plugin.

It almost looks like the mechanism is there, however at the moment it is entirely "on the plugin" to do things like "if the value is over the warning threshold then set the plugin to warning" etc (unless I have completely missed the feature?).

The https://metacpan.org/dist/Monitoring-Plugin solves this problem by implementing a generic check_threshold method like:

$code = $np->check_threshold(
  check => $value,
  warning => $warning_threshold,
  critical => $critical_threshold,
);

We are looking at implementing the same framework so it would probably be something like:

perfdata := nagios.PerformanceData{
	Label:             outputValue.InstanceName,
	Value:             outputValue.Value,
	UnitOfMeasurement: *counterUnit,
	Warn: warningThreshold.value
	Crit: criticalThreshold.value
}

plugin.AddPerfData(false, perfdata)
plugin.EvaluateThreshold(perfdata)

The call to EvalulateThreshold would set the status of the plugin in accordance with the value against the threshold

@atc0005
Copy link
Owner

atc0005 commented Jan 9, 2023

Hi @infraweavers,

Thanks for opening this GH issue.

In short, I've been building out this library to support plugins that I've developed as I've needed functionality. Not all of the pieces fit together seamlessly, but the library as a whole is usable.

While the recent releases have been focused on adding documentation and smoothing out rough edges, this library has a lot of work left before I'd feel comfortable positioning it as a replacement for any existing options (Go or any other language).

I'm open to adding support such as you've mentioned, but need to consider the changes.

I hope to respond in further detail in the next few days (limited dev time recently).

@infraweavers
Copy link
Author

Thanks for the reply. I'm glad I just didn't miss the functionality somewhere :)

Given that we've already added the functionality in an in-lined copy we have in our project, we might as well PR our implementation later on today so you can have a look. At a minimum it can form a discussion point or a basis to be tweaked/converted across to your preferred style/approach etc.

@atc0005 atc0005 added this to the Next Release milestone Jan 26, 2023
atc0005 added a commit that referenced this issue Jan 26, 2023
Minor changes applied as a follow-up to PR #178:

- concentrate new Range functionality in dedicated files
  - this reflects similar work underway for GH-175
- update README
  - mention new Range support
  - link to dependent projects (including one from contributor
    of new functionality)
- doc comment tweaks
- misc changes to satisfy current CI linters

Credit for original work:

- @infraweavers (https://github.com/infraweavers)
- #178

refs GH-176
refs GH-178
@atc0005 atc0005 added the tests label Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants