site monitoring with Ruby on Rails
I needed a way to show the status (Up/down) of internal Ruby applications. I found an answer on StackOverflow that pointed me in the right direction (Apologies that I can’t locate that post). . I modified that somewhat by putting it into a method and passing the site name to it.
If you put the following code in a controller, and all it as indicated in the remarks from your view, it will check the site and respond with UP or down. I have a list of about a half dozen applications in a table with a status column.
NOTE – adding this WILL slow the page response where you are using multiple calls to check_apps. I’m noticing about a 2-3 second load time instead of an instantaneous load.
# ————————- check apps ——————————# This method will do a quick and dirty check to see if a site is up or not.
# call the method with check_apps(‘http://www.sitename.com:port’)# the port is optional
status = ‘-‘
url = URI.parse(site) req = Net::HTTP::Get.new(url.to_s)
res = Net::HTTP.start(url.host, url.port) do |http| http.request(req) status = “UP”
rescue status = ‘down’
- Google Apps Status Page – Find out if Google apps are currently down
- server 2003 hang up at mup.sys on a safe boot
- Privacy Danger from Android Flashlight and other apps
- Have Google do a quick security check on your Google account with the Google Security Check
- Rails – Pop up window with no header, footer or navigation
- Using Always Up to run Ruby on Rails Puma Servers as a service on Microsoft IIS servers.
- Is your site on HTTPs yet? Chrome will warn users who visit http sites.
- Validating CSV imports in Rails