Giter Site home page Giter Site logo

go-monitoringplugin's Introduction

go-monitoringplugin

Go Go Reference

Description

Golang package for writing monitoring check plugins for nagios, icinga2, zabbix, checkmk, etc.

The package complies with the Monitoring Plugins Development Guidelines.

This project is a fork of go-monitoringplugin.

Changes from upstream:

  • Use generics, instead of big.Float and big.ParseFloat. See #1.

Example / Usage

package main

import "github.com/inexio/go-monitoringplugin/v2"

func main() {
	// Creating response with a default ok message, that will be displayed when
	// the checks exits with status ok.
	response := monitoringplugin.NewResponse("everything checked!")

	// Set output delimiter (default is \n)
	// response.SetOutputDelimiter(" / ")

	// Updating check plugin status and adding message to the output (status only
	// changes if the new status is worse than the current one).

	// check status stays ok
	response.UpdateStatus(monitoringplugin.OK, "something is ok!")
	// check status updates to critical
	response.UpdateStatus(monitoringplugin.CRITICAL,
		"something else is critical!")
	// check status stays critical, but message will be added to the output
	response.UpdateStatus(monitoringplugin.WARNING, "something else is warning!")

	// adding performance data
	p1 := monitoringplugin.NewPerformanceDataPoint("response_time", 10).
		SetUnit("s").SetMin(0)
	p1.NewThresholds(0, 10, 0, 20)
	if err := response.AddPerformanceDataPoint(p1); err != nil {
		// error handling
	}

	p2 := monitoringplugin.NewPerformanceDataPoint("memory_usage", 50.6).
		SetUnit("%").SetMin(0).SetMax(100)
	p2.NewThresholds(0, 80, 0, 90)
	if err := response.AddPerformanceDataPoint(p2); err != nil {
		// error handling
	}

	err = response.AddPerformanceDataPoint(
		monitoringplugin.NewPerformanceDataPoint("memory_usage", 50.6).
			SetUnit("%").SetMin(0).SetMax(100).
			SetThresholds(monitoringplugin.NewThresholds(0, 80.0, 0, 90.0)))
	if err != nil {
		// error handling
	}

	response.OutputAndExit()
	/* exits program with exit code 2 and outputs:
	CRITICAL: something is ok!
	something else is critical!
	something else is warning! | 'response_time'=10s;10;20;0; 'memory_usage'=50%;80;90;0;100
	*/
}

go-monitoringplugin's People

Contributors

thefiremike avatar babos77 avatar dsh2dsh avatar zatroa avatar lostboi avatar toberd avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.