GithubHelp home page GithubHelp logo

pombredanne / sensu-plugin-python Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sensu-plugins/sensu-plugin-python

0.0 1.0 0.0 60 KB

A framework for writing Sensu plugins & handlers with Python.

Home Page: http://sensuapp.org/

License: MIT License

sensu-plugin-python's Introduction

sensu

Python Sensu Plugin

This is a framework for writing your own Sensu plugins in Python. It's not required to write a plugin (most Nagios plugins will work without modification); it just makes it easier.

Build Status

Checks

To implement your own check, subclass SensuPluginCheck, like this:

from sensu_plugin import SensuPluginCheck

class MyCheck(SensuPluginCheck):
  def setup(self):
    # Setup is called with self.parser set and is responsible for setting up
    # self.options before the run method is called

    self.parser.add_argument(
      '-w',
      '--warning',
      required=True,
      type=int,
      help='Integer warning level to output'
    )
    self.parser.add_argument(
      '-m',
      '--message',
      default=None,
      help='Message to print'
    )


  def run(self):
    # this method is called to perform the actual check

    self.check_name('my_awesome_check') # defaults to class name

    if self.options.warning == 0:
      self.ok(self.options.message)
    elif self.options.warning == 1:
      self.warning(self.options.message)
    elif self.options.warning == 2:
      self.critical(self.options.message)
    else:
      self.unknown(self.options.message)

if __name__ == "__main__":
  f = MyCheck()

Metrics

JSON

from sensu_plugin import SensuPluginMetricJSON

class FooBarBazMetricJSON(SensuPluginMetricJSON):
    def run(self):
        self.ok({'foo': 1, 'bar': { 'baz': 'stuff' } })

if __name__ == "__main__":
f = FooBarBazMetricJSON()

Graphite

from sensu_plugin import SensuPluginMetricGraphite

class FooBarBazMetricGraphite(SensuPluginMetricGraphite):
    def run(self):
        self.output('a', 1)
        self.output('b', 2)
        self.ok()

if __name__ == "__main__":
f = FooBarBazMetricGraphite()

StatsD

from sensu_plugin import SensuPluginMetricStatsd

class FooBarBazMetricStatsd(SensuPluginMetricStatsd):
    def run(self):
        self.output('a', 1, 'ms')
        self.output('b.c.d', 15)
        self.ok()

if __name__ == "__main__":
f = FooBarBazMetricStatsd()

License

  • Based heavily on sensu-plugin Copyright 2011 Decklin Foster
  • Python port Copyright 2014 S. Zachariah Sprackett

Released under the same terms as Sensu (the MIT license); see LICENSE for details

sensu-plugin-python's People

Contributors

zsprackett avatar

Watchers

 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.