Giter VIP home page Giter VIP logo

nagiosplugin's Introduction

NagiosPlugin

The one Nagios Plugin framework, forged in the fires of Mount Doom.

Build Status

NOTE: The API has changed since version 2.1 (see issues #2 and #4)!!!

Introduction

NagiosPlugin is an embarrassingly simple framework to write custom monitoring plugins for Nagios. It was born out of duplication, because all nagios plugins share some common behaviour...

Installation

Via bundler: Add this to your Gemfile and run bundle install:

gem 'nagiosplugin'

Manually via Rubygems: Run gem install nagiosplugin.

Usage

Writing your custom plugin is really simple:

Step 1: Describe when something is critical, warning and ok.

Create your subclass from NagiosPlugin::Plugin and define these instance methods to determine the status:

require 'nagiosplugin'

class MyFancyPlugin < NagiosPlugin::Plugin
  def critical?
    # Enter your code here (returns true when critical, else false).
  end

  def warning?
    # Enter your code here (returns true when warning, else false).
  end

  def ok?
    # Enter your code... you get the idea.
  end
end

Please keep in mind that the "worst" status always wins, i.e. if both critical? and warning? are true then the status would be critical (if none is true, then the status would be unknown of course)!

You may use your initialize method to setup check data (NagiosPlugin doesn't use that either), parse CLI options, etc.

Step 2: Provide some context via status message (optionally).

Ask yourself what might be important to know (and fits into a text message) when Nagios just send you an alert in the middle of the night.

def message
  # Create an info string (this will be printed after the
  # status on stdout).
  # Service name, status and message should be longer than 78 chars!!!
end

Step 3: Perform the actual check.

In your binary then call the build-in class method check and you're done:

MyFancyPlugin.check

This will output the check result and exits in compliance with the official Nagios plug-in development guidelines

If anything funky happens in your code: NagiosPlugin does a "blind rescue mission" and transforms any execptions to an unknown status.

One more thing...

The API changed completely compared to v1.3 as well as the default command line options (they are gone). I suggest that you use 3rd party CLI Option Parsers because everyone has different preferences on this.

Please let me know if you find this usefull or if you want to contribute!

Note on Patches/Pull Requests

  • Fork the project and run bundle install to resolve all development dependencies.
  • Add specs and/or features for it. This is important so I don't break it in a future version unintentionally.
  • Make your feature addition or bug fix.
  • Commit, do not mess with the Rakefile or gemspec. (If you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull.)
  • Send me a pull request. Bonus points for topic branches.

Acknowledgments

Thanks to the following contributors for improving NagiosPlugin:

Copyright

Copyright (c) 2011-2013 Björn Albers. See LICENSE for details.

nagiosplugin's People

Contributors

bjoernalbers avatar szuecs avatar kalabiyau avatar

Watchers

James Cloos avatar Philippe Green 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.