Nagios Output
A simple wrapper for creating nagios consumable output - including exit codes.
Installation
Add this line to your application's Gemfile:
gem 'nagios_output'
And then execute:
$ bundle
Or install it yourself as:
$ gem install nagios_output
Usage
There are 3 different ways to access the 4 nagios output methods. Those methods are ok, warning, critical and unknown, they have the following spective exit codes 0, 1, 2 and 3.
Class Method
require 'nagios_output'
n = NagiosOutput.new
n.ok('Everything is ok (Class))')
n.warning('Everything is ok-ish (Class)')
n.critical('Everything is cirtial (Class)')
n.unknown('Everything is erm - I don\'t know (Class)')
Static Method
require 'nagios_output'
NagiosOutputStatic.ok('Everything is ok (Static)')
NagiosOutputStatic.warning('Everything is ok-ish (Static)')
NagiosOutputStatic.critical('Everything is cirtial (Static)')
NagiosOutputStatic.unknown('Everything is erm - I don\'t know (Static)')
Direct Method
require 'nagios_output'
ok('Everything is ok (Direct)')
warning('Everything is ok-ish (Direct)')
critical('Everything is cirtial (Direct)')
unknown('Everything is erm - I don\'t know (Direct)')
It is worth noting that the above examples will not function as you might first expect if you cut and paste them and run them. They will all show the ok() message then stop. Remember each function also makes a call to exit().
Development
After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.
Testing
For local testing make sure that you run bundle exec rspec spec and then rake install to install the gem locally.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/AntiPhotonltd/nagios_output. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
License
The gem is available as open source under the terms of the MIT License.
Code of Conduct
Everyone interacting in the NagiosOutput project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.