Created
August 4, 2010 11:49
-
-
Save Paxa/508009 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env ruby | |
# send request on website every 10 seconds | |
# checks request time and show growl notify and tell you by `say` if response time is more then 2 seconds | |
require 'rubygems' | |
require 'httparty' | |
require 'growl' | |
include Growl | |
while true | |
t = Time.now.to_f | |
r = HTTParty.get 'http://example.com/' | |
dt = Time.now.to_f - t | |
if dt > 2 || r.parsed_response.size < 300 | |
`say -v Kathy 'server is under attack'` | |
`growlnotify -s -m "server is under attack"` | |
end | |
puts sprintf "%3.3f", Time.now.to_f - t | |
sleep 10 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment