Shared Golang package for Nagios plugins
Alpha quality.
This codebase is subject to change without notice and may break client code that depends on it. You are encouraged to vendor this package if you find it useful until such time that the API is considered stable.
This package contains common types and package-level variables used when developing Nagios plugins. The intent is to reduce code duplication between various plugins and help reduce typos associated with literal strings.
- Nagios state constants
- state labels (e.g.,
StateOKLabel
) - state exit codes (e.g.,
StateOKExitCode
)
- state labels (e.g.,
- Nagios
CheckOutputEOL
constant- provides a consistent newline format for both Nagios Core and Nagios XI (and presumably other similar monitoring systems)
- Nagios
ServiceState
type- simple label and exit code "wrapper"
- useful in client code as a way to map internal check results to a Nagios service state value
- Support for evaluating a given performance data value and setting the final plugin state exit code
- Support for parsing a given performance data metric string and generating
one or more
PerformanceData
values - Support for using a "branding" callback function to display application
name, version, or other information as a "trailer" for check results
provided to Nagios
- this could be useful for identifying what version of a plugin determined the service or host state to be an issue
- Panics from client code are captured and reported
- panics are surfaced as
CRITICAL
state - service output and error details are overridden to panic prominent
- panics are surfaced as
- Optional support for emitting performance data generated by plugins
- if not overridden by client code and if using the provided
nagios.NewPlugin()
constructor, a defaulttime
performance data metric is emitted to indicate total plugin runtime
- if not overridden by client code and if using the provided
- Support for collecting multiple errors from client code
- Support for explicitly omitting Errors section in
LongServiceOutput
- this section is automatically omitted if no errors were recorded (by client code or panic handling code)
- Support for explicitly omitting Thresholds section in
LongServiceOutput
- this section is automatically omitted if no thresholds were specified by client code
- Automatically omit
LongServiceOutput
section if not specified by client code - Support for overriding text used for section headers/labels
See the CHANGELOG.md
file for the changes associated with
each release of this application. Changes that have been merged to master
,
but not yet an official release may also be noted in the file under the
Unreleased
section. A helpful link to the Git commit history since the last
official release is also provided for further review.
Add this line to your imports like so:
package main
import (
"fmt"
"log"
"os"
"github.com/atc0005/go-nagios"
)
and pull in a specific version of this library that you'd like to use.
go get github.com/atc0005/[email protected]
Alternatively, you can use the latest stable tag available to get started:
go get github.com/atc0005/go-nagios@latest
See https://pkg.go.dev/github.com/atc0005/go-nagios for specific examples.
See https://pkg.go.dev/github.com/atc0005/go-nagios?tab=importedby for projects that are using this library.
From the LICENSE file:
MIT License
Copyright (c) 2020 Adam Chalkley
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
See the Known importers lists below for a dynamically updated list of projects using either this library or the original project.
- Known importers (pkg.go.dev)
- https://github.com/infraweavers/monitoring-agent-check-nt-replacement
- Nagios
- https://github.com/nagios-plugins/nagios-plugins/blob/master/plugins-scripts/utils.sh.in
- https://nagios-plugins.org/doc/guidelines.html
- https://www.monitoring-plugins.org/doc/guidelines.html
- https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/3/en/pluginapi.html
- https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/pluginapi.html
- https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/3/en/perfdata.html
- https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/perfdata.html
- https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/3/en/macrolist.html
- https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/macrolist.html
- Icinga
- Go Modules
- Panics, stack traces
See also the Used by section for projects known to be using this package. Please report any additional projects that we've missed!