Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

monittr

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

monittr

  • 0.0.7
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Monittr

Monittr provides a Ruby interface for the Monit systems management system. Its main goal is to aggregate statistics from multiple Monit instances and display them in an attractive web interface.

Monittr loads XML from the web server embedded in Monit and makes it accessible as Ruby objects. It also provides helpers for Sinatra applications, to display the information as HTML. You can insert the statistics into any page, or create a dedicated one. You can use the default template, or create your own. The default template is located in lib/monittr/sinatra/template.erb and pictured below.

Screenshot: Monittr, a web interface for Monit statistics

Usage

First, clone or download the sources from Github, to get the latest version:

$ git clone http://github.com/karmi/monittr.git
$ cd monittr

You can try the Ruby interface in a IRB console:

$ irb -Ilib -rubygems -rmonittr

You have to pass one or more URLs to a local or remote Monit HTTP server:

cluster = Monittr::Cluster.new ['http://localhost:2812/']

In case you don't have a running Monit server at hand, use the provided FakeWeb setup:

require 'fakeweb'
FakeWeb.register_uri(:get, 'http://localhost:2812/_status?format=xml', :body => File.read('test/fixtures/status.xml') ); nil

cluster = Monittr::Cluster.new ['http://localhost:2812/']

Now, you can display the information from the cluster:

cluster.servers.size

server = cluster.servers.first
server.system.status
server.system.load

server.filesystems.first.name
server.filesystems.first.percent

server.processes.first.name
server.processes.first.cpu
server.processes.first.memory

...

You can also check out the HTML display by running the example application:

$ ruby examples/application.rb
$ open http://localhost:4567/

You should see the information about two faked Monit instances in your browser. (You may need to comment out the FakeWeb section, if you're passing localhost URLs.)

To use the gem in a Sinatra application, you have to require the gem, the Sinatra helper and provide the URLs to Monit instances:

require 'monittr'
require 'monittr/sinatra/monittr'
set :monit_urls,  %w[ http://production.example.com:2812 http://staging.example.com:2812 ]

In a “modular” Sinatra application, you have to register the module explicitely as well:

register Sinatra::MonittrHTML

Then, just call the helper in your template:

<%= monittr.html %>

You may use the example application as the starting point.

Customization

It's easy to customize the HTML output by setting the appropriate options in your Sinatra application.

set :template,   Proc.new { File.join(root, 'template.erb') }
set :stylesheet, '/path/to/my/stylesheet'

Installation

The best way to install the gem is from the source:

$ git clone http://github.com/karmi/monittr.git
$ cd monittr
$ rake install

Stable versions of the gem can be installed from Rubygems:

$ gem install monittr

Other

Any feedback, suggestions or patches are welcome via e-mail or Github Issues/Pull Requests.

Check out the monit gem for another Ruby interface to Monit.


Karel Minarik

FAQs

Package last updated on 22 Mar 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc