No release in over a year
Monitor one or multiple servers at once and see stats in web UI
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

~> 1.0, >= 1.0.4
>= 6.0.0, < 7
~> 1.0, >= 1.0.3
>= 6.0.0.beta.7, < 7.0.0
 Project Readme

Rails Server Monitor

A performance dashboard for rails applications which work with one or multiple servers at once. Stats can be collected from a Rack application or Sidekiq.

See it in action

demo demo

Usage

1)

gem 'rails-server-monitor', require: "rails_server_monitor"

2) generate Rails Server Monitor tables

rails g rails_server_monitor:install
rails db:migrate

3) hook Rails Server Monitor's rack middleware

# inside config/application.rb
config.middleware.use RailsServerMonitor::RackMiddleware

4) compile Rails Server Monitor assets locally

if you aren't using webpacker already

# you don't need to do this in production, it's prepended to rake assets:precompile
# but you need to do it again after you after you update the gem locally
rake webpacker:compile 

or if you are using

# inside bin/webpack-dev-server
require "rails_server_monitor/compile_locally"
RailsServerMonitor::CompileLocally.compile 

# insert before this before
# Dir.chdir(APP_ROOT) do
#   Webpacker::DevServerRunner.run(ARGV)
# end

5) (Optional) configure gem

# inside config/initializers/rails_server_monitor

RailsServerMonitor.config do |c|
  c.update_server_interval = 1.hour 
  c.snapshot_server_interval = 15.minutes
  c.cleanup_snapshots_after = 90.days
  c.ignore_workers = %w(MyIgnoredWorker)
  c.ignore_urls = ["/", /ignored-url/]
  
  c.high_cpu_usage_threshold = 95
  c.low_memory_threshold = 20
  c.low_free_disk_disk_threshold = 30
  c.hostname = -> do
    `hostname`
  end # how to retrieve server hostname, heroku generates a hostname each time your app reboots
end

6) Mount engine to routes

# inside config/routes.rb
constraints LoggedInAsAdmin do
  mount RailsServerMonitor::Engine => "/system-information"
end

Your should define a constraint to protect against unauthorized access

# example LoggedInAsAdmin, this is a basic implementation

class LoggedInAsAdmin
  def self.matches?(request)
    AdminUser.find_by(id: request.session[:admin_id]).present?
  end
end

7) (Optional) Add sidekiq middleware

# append to config/sidekiq.rb

Sidekiq.configure_server do |config|
  config.server_middleware do |chain|
    chain.add RailsServerMonitor::SidekiqMiddleware
  end
end

8) Result

you should now go to http://localhost:3000/system-information

Contributing

Everyone is encouraged to help improve this project. Here are a few ways you can help:

Development

# fork project, clone
bundle install
yarn install

bin/start # to start local server
bin/rspec # to run specs

License

The gem is available as open source under the terms of the MIT License.