• Stars
    star
    237
  • Rank 169,885 (Top 4 %)
  • Language
    Ruby
  • License
    MIT License
  • Created about 14 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Ruby and web interface for Monit statistics

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

More Repositories

1

retire

A rich Ruby API and DSL for the Elasticsearch search engine
Ruby
1,870
star
2

elasticsearch-paramedic

A simple tool to inspect the state and statistics about ElasticSearch clusters
JavaScript
664
star
3

marley

Minimalist blogging engine without textareas based on Markdown, Ruby, Sinatra and Git push hooks
Ruby
246
star
4

localized_country_select

Rails plugin for localized "country_select" helper with Rake task for downloading locales from Unicode.org's CLDR
Ruby
180
star
5

pushr

Deploy Rails applications automatically by running Capistrano tasks with Git post-commit hooks
Ruby
113
star
6

ember-data-elasticsearch

elasticsearch adapter for Ember Data
JavaScript
94
star
7

rails-deployment-setups-sprinkle

Collection of recipes for various Ruby On Rails deployment setups
Ruby
69
star
8

tire-contrib

Additions and extensions for the Tire gem
Ruby
65
star
9

chef-hello-cloud

A demo of a full stack Rails application deployment (1x load balancer, 3x appserver, 1x database, 3x elasticsearch) with Chef Server
Ruby
59
star
10

visualizing-couchdb-changes-with-node-js

An experiment in basic real-time visualization of CouchDB _changes stream with Node.js and Socket.IO
JavaScript
32
star
11

chef-solo-hello-world

A tutorial for Chef Solo
Ruby
31
star
12

yaml_micro_chat

YAML based micro-chat in Sinatra framework for Ruby
Ruby
31
star
13

rails_i18n_demo_app

Demo for Rails 2.2 internationalization &amp; localization features
Ruby
27
star
14

dotfiles

Vim Script
19
star
15

couchdb-showcase

A small application to demonstrate basic CouchDB features
JavaScript
18
star
16

clearance_http_auth

Simple, instant HTTP Basic Authentication for applications using Clearance
Ruby
16
star
17

redis_twitter_example

An executable tutorial showcasing Twitter “lookalike” in Redis for the Czech and Slovak PostgreSQL User Group talk
Shell
14
star
18

hide

Search for Jekyll websites
Ruby
13
star
19

sheep_in_your_shoes

A tutorial game in Shoes for teaching OOP
Ruby
12
star
20

sinatra_workshop_tutorials

Collection of small apps to demonstrate Sinatra micro-framework and it's stage
Ruby
10
star
21

workshop_tutorial_application

Tutorial Ruby on Rails application (similar to www.tadalist.com) coded live on workshops. Development steps can be reconstructed from commits.
Ruby
10
star
22

smokes

Tracking your nicotine intake with CouchDB and Protovis
JavaScript
9
star
23

colibriary

Demo application to show how to use Cucumber stories in Czech
Ruby
8
star
24

markout

Export sexy formatted documents with history from plain text files. Work in progress.
JavaScript
8
star
25

shoes_demonstration_apps

Collection of tiny apps to demonstrate Shoes GUI toolkit at lectures, user group meetings, etc
Ruby
7
star
26

elastic-stack-demo

Demo of the observability features of the Elastic Stack
Go
6
star
27

gotalks

JavaScript
5
star
28

es-rails-example

Demo for the Elasticsearch integration with Ruby On Rails (ElasticON 2016)
Ruby
5
star
29

wikipedia_history_viz

Ruby
5
star
30

elasticsearch_webexpo_demo

Demo of Distributed Features for Webexpo 2011
Ruby
4
star
31

resque-demo

A set of scripts to demonstrate the Resque framework for processing background jobs
Ruby
3
star
32

markout-tmbundle

Ruby
3
star
33

consolelog

A ConsoleWriter for rs/zerolog
Go
3
star
34

calculator

Calculator: example repository for Git workshops
JavaScript
2
star
35

tdd_tutorial_by_numbers

Test-Driven Development in Ruby by Numbers (tutorial)
Ruby
2
star
36

test_default_url_options

testing default_url_options in Rails
Ruby
2
star
37

bouncy_air

Just. Fooling. Around
ActionScript
2
star
38

dm-elasticsearch

Ruby
2
star
39

pushr_notifiers

Example of notification classes for Pushr. Heavily inspired by Integrity
Ruby
2
star
40

pushr_test_app

Just testing something :)
Ruby
1
star
41

wikipedia_metal_umlaut

1
star
42

webexpo_demo_app

Demonstrační aplikace pro přednášku na konferenci Webexpo
Ruby
1
star
43

tire_facet_filter_problem

Ruby
1
star
44

karmi.github.com

1
star
45

slingshot

Ruby client for ElasticSearch
1
star