Skip to content

Instantly share code, notes, and snippets.

@JanDintel
Last active December 23, 2015 06:39
Show Gist options
  • Save JanDintel/6595737 to your computer and use it in GitHub Desktop.
Save JanDintel/6595737 to your computer and use it in GitHub Desktop.
InfrastructureController to support Nagios health check
# app/controllers/infrastructure_controller.rb
class InfrastructureController < ActionController::Base
def health_check
@checks = { database: ActiveRecord::Migrator.current_version,
redis: redis_check,
version: %x(git log --pretty=format:'%h' -1) }
if @checks[:redis] == "Not connected"
@notification = "Error 500, Can't find Redis"
else
@notification = 'Everything seems fine'
end
end
private
def redis_check
r = Redis.new
r.ping rescue "Not connected"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment