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

Function AddPerfDatum - MIN:MAX defined as float64, range format not possible #15

Open
ronator opened this issue Jun 8, 2017 · 5 comments

Comments

@ronator
Copy link

ronator commented Jun 8, 2017

Hi,

I am totally new to Go, just got my environment setup. I am trying to fix a problem in a nagios plugins written in Go that relies on nagiosplugin.go (@egnite). Now it seems to me this nagiosplugin.go does not support performance data output as it should. Let me explain:

The tutorial is refering to Nagios Plugin Developers Guideline that says format for perf data is

'label'=value[UOM];[warn];[crit];[min];[max]

but the function AddPerfDatum is changing position of MIN-MAX with CRIT-WARN

// Add some perfdata too (label, unit, value, min, max, warn, crit)

Anyway. But furthermore, I wonder why warn, crit, min and max are defined as float64 since 'warn' and 'crit' can of course be in the range format so it should be able to use "20:40" as a value : https://docs.icinga.com/latest/en/perfdata.html

This means neither can't I set the MIN to "20:28" nor can't I set the MAX to "18:30" which is quite important for monitoring ranges like temperature or process counters.

So logically, any plugin based on this repo cannot use the range format as standard plugins do. Any nagios plugin should be able to output the min:max range with a colon between them:

/usr/lib/nagios/plugins/check_procs -w 300:400 -c 500:600
PROCS KRITISCH: 192 Prozesse | procs=192;300:400;500:600;0

Is there a chance this code will be improved in time?

@egnite
Copy link

egnite commented Jun 8, 2017 via email

@ronator
Copy link
Author

ronator commented Jun 8, 2017

Dear Harald,
well, I wouldn't say bad quality in general and I guess the issue here is not your fault. I went through the code and the problem is that the function AddPerfDatum does not support min:max ranges. Maybe the original author also stumbled upon that and that's why it was never used correctly in check_querx.

So we can't fix the perf data issue in check_querx until we can output the whole range. That's why I opened this issue here.

I sent you a mail from my work account.

@ronator
Copy link
Author

ronator commented Jun 8, 2017

Maybe I was wrong and the problem seems to be in check_querx:

func main() {
	var cUpper, cLower, wUpper, wLower, value float64

Let me check this in detail; I will come back and close this issue when I can confirm it is NOT a problem with nagiosplugin.go - sorry for the noise.

@ronator
Copy link
Author

ronator commented Jun 8, 2017

Okay, so the problem is in perfdata.go:

min *float64
max *float64

This means I can't set a range for min and/or max, only float values. Using values like "20:40" - which is the range format for nagios plugins - is impossible.

This is really my first day writing some Go code, so I am totally unsure if this can be fixed easily. What do you think @olorin?

@olorin
Copy link
Owner

olorin commented Jun 14, 2017

Apologies for the delayed response @ronator. You're right; the current version is incomplete and should support ranges. I'm not sure when I'll next have time to work on this myself, but I think the fix should be fairly simple and I'd be very happy to review changes. Only thing to be careful of is not making breaking changes to the interface at this point.

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

No branches or pull requests

3 participants