From cbf4199f788b3b89b1ecec566a3335f586c49de0 Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Thu, 22 Nov 2012 16:36:31 -0500 Subject: [PATCH] Quick proof of concept --- uptime-notifier.rb | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 uptime-notifier.rb diff --git a/uptime-notifier.rb b/uptime-notifier.rb new file mode 100644 index 0000000..6142022 --- /dev/null +++ b/uptime-notifier.rb @@ -0,0 +1,29 @@ +#!/usr/bin/ruby + +# Uptime Notifier +# +# Super simplistic website monitoring. Crontab is up and enjoy! +# +# Usage: ruby uptime-notifier.rb +# +# p.s. This was just a quick Thanksgiving proof of concept, I do plan on +# expanding this and giving is some sick configuration options. +# +# Requires terminal-notifier: +# https://github.com/alloy/terminal-notifier + +require 'net/http' + +url = 'http://this-website-should-be-down.com' + +resource = Net::HTTP.get_response(URI.parse(url.to_s)) + +unless (resource.code =~ /2|3\d{2}/) +then + `terminal-notifier \ + -title "Uptime Notifier" \ + -message "OH NOES, it looks like #{URI.parse(url).host} is down!!~!" \ + -open #{url} \ + -group Uptime Notifier \ + -remove Uptime Notifier` +end