Last active
December 23, 2015 06:39
-
-
Save JanDintel/6595737 to your computer and use it in GitHub Desktop.
InfrastructureController to support Nagios health check
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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