GithubHelp home page GithubHelp logo

everbox / monittr Goto Github PK

View Code? Open in Web Editor NEW

This project forked from karmi/monittr

1.0 3.0 0.0 371 KB

Ruby and web interface for Monit statistics

Home Page: http://ephemera.karmi.cz/post/1714578431/monittr-ruby-and-web-interface-for-multiple-monits

License: MIT License

Ruby 100.00%

monittr's Introduction

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

monittr's People

Contributors

karmi avatar lidaobing avatar

Watchers

jessinio.liang avatar guolijing avatar James Cloos 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.