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

Status should be initialized as UNKNOWN instead of OK #16

Open
hrak opened this issue Feb 15, 2019 · 1 comment
Open

Status should be initialized as UNKNOWN instead of OK #16

hrak opened this issue Feb 15, 2019 · 1 comment

Comments

@hrak
Copy link

hrak commented Feb 15, 2019

The initial state of check.String() (which uses check.status) is OK while the initial check result is UNKNOWN. These should match.

// Initialize the check - this will return an UNKNOWN result
// until more results are added.
check := nagiosplugin.NewCheck()

fmt.Printf("%s", check.String())   // returns: 'OK'

check.Finish()  // returns 'UNKNOWN: no check result specified'
stevemeier added a commit to stevemeier/nagiosplugin that referenced this issue Apr 5, 2021
@stevemeier
Copy link

I have created a pull request to implement this.

As I understand the code, the Status is a uint which is initialized as 0, which maps to OK, according to Nagios standards.
I have changed this default value to be 3, which represents UNKNOWN.

I also had to change another piece of the code which seems to allow transition only "downwards":
OK -> WARNING -> ERROR -> UNKNOWN

With the new default being UNKNOWN, I changed this to allow transition from UNKNOWN to any other state.

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

2 participants