Skip to content

Instantly share code, notes, and snippets.

@Paxa
Created August 4, 2010 11:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Paxa/508009 to your computer and use it in GitHub Desktop.
Save Paxa/508009 to your computer and use it in GitHub Desktop.
#!/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