Gem for writing, testing, executing Nagios checks inside Rails application. Checks running throught http or script.
Ruby
Latest commit bf41339 Aug 22, 2014 @kostya add mutex to sync errors
Permalink
Failed to load latest commit information.
bin try to set rails_root in unknown env Apr 24, 2014
lib add mutex to sync errors Aug 22, 2014
spec add checkname Nov 11, 2013
.gitignore # init Sep 9, 2012
Gemfile fix gemfile Oct 5, 2013
LICENSE # init Sep 9, 2012
README.md add generator Oct 19, 2013
Rakefile # init Sep 9, 2012
nagios_helper.gemspec add mutex to sync errors Aug 22, 2014

README.md

NagiosHelper

Gem for writing, testing, executing Nagios checks inside Rails application. Checks running throught http or script.

gem 'nagios_helper', :require => 'nagios'
$ rails generate nagios:check some

Check example:

app/nagios/some.rb

class Nagios::Some < Nagios::Check
  params :x

  def execute
    count = User.count + x.to_i

    warn "hmmm" if count < 10
    crit "ouch" if count < 5

    ok "good #{count}"
  end

end

Run:

$ RAILS_ENV=production bundle exec nagios_check some x 1

Nagios Check Initilizers:

All files in app/nagios/initializers will auto loads.

Server:

Inside rails server

Create controller: app/controllers/nagios_controller.rb

class NagiosController < ApplicationController
  http_basic_authenticate_with :name => "nagios", :password => "password"

  def check
    status, message = Nagios::Runner.check(params)
    render :text => "#{status}|#{message}", :layout => false
  end

end
$ curl http://nagios:password@localhost:3000/nagios/check?method=some&x=1