Quick proof of concept
This commit is contained in:
parent
d4d6c044e5
commit
cbf4199f78
1 changed files with 29 additions and 0 deletions
29
uptime-notifier.rb
Normal file
29
uptime-notifier.rb
Normal file
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue