Giter VIP home page Giter VIP logo

redmon's Introduction

Build status - Travis-ci Code Climate Gem Version Coverage Status

Redmon

Simple sinatra based dashboard for redis. After seeing the fnordmetric project I was inspired to write this. Some of the ideas there have be carried over here.


Watch your redis server live.


Interact with redis using a familiar cli interface.


Dynamically update your server configuration.


Installation

Redmon is available as a RubyGem:

gem install redmon

Usage

$ redmon -h
Usage: /Users/sean/codez/steelThread/redmon/vendor/ruby/1.9.1/bin/redmon (options)
    -a, --address ADDRESS            The thin bind address for the app (default: 0.0.0.0)
    -n, --namespace NAMESPACE        The root Redis namespace (default: redmon)
    -l, --lifespan MINUTES           Lifespan(in minutes) for polled data (default: 30)
    -i, --interval SECS              Poll interval in secs for the worker (default: 10)
    -p, --port PORT                  The thin bind port for the app (default: 4567)
    -r, --redis URL                  The Redis url for monitor (default: redis://127.0.0.1:6379)
    -s, --secure CREDENTIALS         Use basic auth. Colon separated credentials, eg admin:admin.
        --no-app                     Do not run the web app to present stats
        --no-worker                  Do not run a worker to collect the stats

$ redmon
>> Thin web server (v1.3.1 codename Triple Espresso)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:4567, CTRL+C to stop
[12-03-10 15:49:40] listening on http#0.0.0.0:4567

If you want to simulate a weak load on redis

$ ruby load_sim.rb

Open your browser to 0.0.0.0:4567

Using in a Rails application

Add to Gemfile:

gem 'redmon', require: false

Mount redmon in config/routes.rb:

mount Redmon::App => '/redmon'

Create a config/initializers/redmon.rb file:

require 'redmon/config'
require 'redmon/redis'
require 'redmon/app'

#
# Optional config overrides
#
Redmon.configure do |config|
  config.redis_url = 'redis://127.0.0.1:6379'
  config.namespace = 'redmon'
end

This will mount the Redmon application to the /redmon path.

Stats worker

The worker that gathers the Redis info stats will not be started when Redmon is mounted like this. In order to get a EventMachine worker running inside your Rails app you can try this Railtie based approach. If you are using a system to execute background tasks in your app (like Sidekiq, Resque, or Delayed Job), you can write your own worker to update the info stats.

A simple worker for Sidekiq looks like this:

class RedmonWorker
  include Sidekiq::Worker

  def perform
    worker = Redmon::Worker.new
    worker.record_stats
    worker.cleanup_old_stats
  ensure
    self.class.perform_in Redmon.config.poll_interval.seconds
  end
end

Once enqueued, the worker updates the stats and automatically enqueues itself to be performed again after the defined poll interval.

Using with another Sinatra application

Create/Edit config.ru:

require './app.rb'
require 'redmon'

map '/' do
  run Sinatra::Application
end
map '/redmon' do
  if EM.reactor_running?
    Redmon::Worker.new.run!
  else
    fork do
      trap('INT') { EM.stop }
      trap('TERM') { EM.stop }
      EM.run { Redmon::Worker.new.run! }
    end
  end

  run Redmon::App
end

In order to configure Redmon use this code in your app.rb file:

Redmon.configure do |config|
  config.redis_url = 'redis://127.0.0.1:6379'
  config.namespace = 'redmon'
end

This will mount the Redmon application to the /redmon path.

License

Copyright (c) 2012 Sean McDaniel

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to use, copy and modify copies of the Software, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

redmon's People

Contributors

dersascha avatar dimshadowww avatar girasquid avatar kiela avatar kmwhite avatar manuelmeurer avatar romanbsd avatar spk avatar steelthread avatar woodhull avatar xylakant avatar

Watchers

 avatar  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.