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

Use UNKNOWN state for invalid command-line args #55

Closed
12 tasks done
atc0005 opened this issue Mar 2, 2023 · 0 comments
Closed
12 tasks done

Use UNKNOWN state for invalid command-line args #55

atc0005 opened this issue Mar 2, 2023 · 0 comments
Assignees

Comments

@atc0005
Copy link
Owner

atc0005 commented Mar 2, 2023

Overview

The Nagios Plugin Guidelines (see refs) provides this guidance for setting exit states:

Numeric Value Service Status Status Description
0 OK The plugin was able to check the service and it appeared to be functioning properly
1 Warning The plugin was able to check the service, but it appeared to be above some "warning" threshold or did not appear to be working properly
2 Critical The plugin detected that either the service was not running or it was above some "critical" threshold
3 Unknown Invalid command line arguments were supplied to the plugin or low-level failures internal to the plugin (such as unable to fork, or open a tcp socket) that prevent it from performing the specified operation. Higher-level errors (such as name resolution errors, socket timeouts, etc) are outside of the control of plugins and should generally NOT be reported as UNKNOWN states.

The last item is the focus of this GH issue.

Most of the projects I'm currently working with opt to exit with a CRITICAL state when invalid command-line arguments, flags or flag values are used. Instead, based on the guidance listed above an UNKNOWN state should be returned.

Example fix:

diff --git a/cmd/check_cert/main.go b/cmd/check_cert/main.go
index fa13b79..fbf14fd 100644
--- a/cmd/check_cert/main.go
+++ b/cmd/check_cert/main.go
@@ -53,10 +53,10 @@ func main() {
 
 		plugin.ServiceOutput = fmt.Sprintf(
 			"%s: Error initializing application",
-			nagios.StateCRITICALLabel,
+			nagios.StateUNKNOWNLabel,
 		)
 		plugin.AddError(cfgErr)
-		plugin.ExitStatusCode = nagios.StateCRITICALExitCode
+		plugin.ExitStatusCode = nagios.StateUNKNOWNExitCode
 
 		return
 	}

TODO

This is not an exhaustive list; I should verify all Nagios related projects that I maintain have these corrections applied.

  • atc0005/check-cert
  • atc0005/check-illiad
  • atc0005/check-mail
  • atc0005/check-ntpt
  • atc0005/check-path
  • atc0005/check-process
  • atc0005/check-restart
  • atc0005/check-statuspage
  • atc0005/check-vmware
  • atc0005/check-whois
  • atc0005/mysql2sqlite
  • atc0005/nagios-debug

References

@atc0005 atc0005 self-assigned this Mar 2, 2023
atc0005 added a commit to atc0005/check-cert that referenced this issue Mar 2, 2023
Update handling of invalid flags/values to use an UNKNOWN
exit state to comply with Nagios Plugin Guideline
recommendations.

refs #464
refs atc0005/todo#55
refs https://nagios-plugins.org/doc/guidelines.html
This was referenced Mar 2, 2023
atc0005 added a commit to atc0005/check-process that referenced this issue Mar 6, 2023
Update handling of invalid flags/values to use an UNKNOWN
exit state to comply with Nagios Plugin Guideline
recommendations.

refs #51
refs atc0005/todo#55
refs https://nagios-plugins.org/doc/guidelines.html
atc0005 added a commit to atc0005/check-process that referenced this issue Mar 6, 2023
- failure to evaluate process directories
- failure to obtain list of process values

These changes are made to comply with Nagios Plugin Guideline
recommendations.

refs #51
refs atc0005/todo#55
refs https://nagios-plugins.org/doc/guidelines.html
atc0005 added a commit to atc0005/check-statuspage that referenced this issue Mar 7, 2023
Update handling of invalid flags/values to use an UNKNOWN
exit state to comply with Nagios Plugin Guideline
recommendations.

refs #196
refs atc0005/todo#55
refs https://nagios-plugins.org/doc/guidelines.html
atc0005 added a commit to atc0005/check-restart that referenced this issue Mar 8, 2023
Update handling of invalid flags/values to use an UNKNOWN exit
state to comply with Nagios Plugin Guideline recommendations.

refs #93
refs atc0005/todo#55
refs https://nagios-plugins.org/doc/guidelines.html
atc0005 added a commit to atc0005/check-mail that referenced this issue Mar 9, 2023
Update handling of invalid flags/values to use an UNKNOWN
exit state to comply with Nagios Plugin Guideline
recommendations.

refs #386
refs atc0005/todo#55
refs https://nagios-plugins.org/doc/guidelines.html
atc0005 added a commit to atc0005/check-whois that referenced this issue Apr 4, 2023
Update handling of invalid flags/values to use an UNKNOWN
exit state to comply with Nagios Plugin Guideline
recommendations.

refs GH-152
refs atc0005/todo#55
refs https://nagios-plugins.org/doc/guidelines.html
atc0005 added a commit to atc0005/check-whois that referenced this issue Apr 4, 2023
Update handling of invalid flags/values to use an UNKNOWN
exit state to comply with Nagios Plugin Guideline
recommendations.

refs GH-152
refs atc0005/todo#55
refs https://nagios-plugins.org/doc/guidelines.html
atc0005 added a commit to atc0005/check-illiad that referenced this issue Apr 6, 2023
Update handling of invalid flags/values to use an UNKNOWN
exit state to comply with Nagios Plugin Guideline
recommendations.

refs #159
refs atc0005/todo#55
refs https://nagios-plugins.org/doc/guidelines.html
atc0005 added a commit to atc0005/mysql2sqlite that referenced this issue May 15, 2023
Update handling of invalid flags/values to use an UNKNOWN
exit state to comply with Nagios Plugin Guideline
recommendations.

refs #225
refs atc0005/todo#55
refs https://nagios-plugins.org/doc/guidelines.html
atc0005 added a commit to atc0005/check-path that referenced this issue May 18, 2023
Update handling of invalid flags/values to use an UNKNOWN
exit state to comply with Nagios Plugin Guideline
recommendations.

refs GH-171
refs atc0005/todo#55
refs https://nagios-plugins.org/doc/guidelines.html
atc0005 added a commit to atc0005/check-vmware that referenced this issue Jun 27, 2023
Update handling of invalid flags/values to use an UNKNOWN
exit state to comply with Nagios Plugin Guideline
recommendations.

refs GH-767
refs atc0005/todo#55
refs https://nagios-plugins.org/doc/guidelines.html
atc0005 added a commit to atc0005/check-illiad that referenced this issue Jun 27, 2023
After further evaluation of Nagios Plugin Guideline
recommendations and review of official plugin design, using
a CRITICAL exit state appears to be the appropriate response for
connection failures.

- refs #159
- refs atc0005/check-vmware#767
- refs atc0005/todo#55
- refs https://nagios-plugins.org/doc/guidelines.html#AEN78
- refs https://icinga.com/docs/icinga-2/latest/doc/05-service-monitoring/#status
@atc0005 atc0005 closed this as completed Jul 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant