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
- Privacy Danger from Android Flashlight and other apps
- 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
- “Your computer needs maintenance” scams.
- Gmail appears to be down
- Embedding a youtube video in Joomla without using a video extension and disabling related videos at the end.