Skip to content

lscheidler/go-nagios

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nagios

Usage

package main

import (
  "math"
  "github.com/lscheidler/go-nagios"
)

func main() {
  nagios := nagios.New()
  nagios.SetName("myCheck")
  defer nagios.Exit()

  // do not add perfdata to message, default is true
  nagios.ShowPerfdata = false

  var (
    value float64 = 5
    warning float64 = 4
    critical float64 = math.NaN()

    valueP float64 = 20
    maxP float64 = 100
    warningP float64 = 40
    criticalP float64 = 80
  )

  // check value against warning threshold and ignore critical, because it is NaN
  nagios.CheckThreshold("example", value, warning, critical)

  // check percentage calculated from valueP and maxP against warningP and criticalP thresholds
  nagios.CheckPercentageThreshold("percentage.example", valueP, maxP, warningP, criticalP)

  // add Ok
  nagios.Ok("This is ok.")

  // add Warning
  nagios.Warning("This is a warning.")

  // add Critical
  nagios.Critical("This is a critical.")

  // add Unknown
  nagios.Unknown("This is an unknown.")
}

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/lscheidler/go-nagios.

License

The code is available as open source under the terms of the Apache 2.0 License.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published