Skip to content

atc0005/go-nagios

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-nagios

Shared Golang package for Nagios plugins

Latest Release Go Reference go.mod Go version Lint and Build Project Analysis

Table of contents

Overview

This package provides support and functionality common to monitoring plugins. While Nagios (Core and XI) are primary monitoring platform targets, the intent is to support (where feasible) all monitoring platforms compatible with Nagios plugins.

Status

While attempts are made to provide stability, 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.

Features

  • Nagios state constants
    • state labels (e.g., StateOKLabel)
    • state exit codes (e.g., StateOKExitCode)
  • Nagios CheckOutputEOL constant
    • provides a common newline format shown to produce consistent results 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 make panics prominent
  • Optional support for emitting performance data generated by plugins
    • if not overridden by client code and if using the provided nagios.NewPlugin() constructor, a default time performance data metric is emitted to indicate total plugin runtime
  • Support for collecting multiple errors from client code
  • Support for explicitly omitting Errors section
    • this section is automatically omitted if no errors were recorded (by client code or panic handling code)
  • Support for explicitly omitting Thresholds section
    • 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
  • Support for adding/embedding a compressed and encoded payload in plugin output
  • Support for decoding and decompressing encoded input (payload)
  • Support for extracting (without decoding & decompressing) an encoded payload from captured plugin output
  • Support for extracting, decoding and decompressing an encoded payload (into the original non-encoded form) from captured plugin output
  • Optional debug logging for plugin activity
    • debug log output is sent to stderr by default but can be redirected to a custom target
    • toggles are provided to enable debug logging for all plugin activity or for select types

Changelog

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.

Examples

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/go-nagios@v0.9.0

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.

License

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.

Used by

See the Known importers lists below for a dynamically updated list of projects using either this library or the original project.

References

See also the Used by section for projects known to be using this package. Please report any additional projects that we've missed!