Created
January 23, 2012 09:51
-
-
Save denzuko/1662141 to your computer and use it in GitHub Desktop.
With thanks to Jason Noble's post at http://pivotallabs.com/blabs/categories/capistrano. I created this updated version that pushes to alerts to my android device. I have a Jabber version in the works and with a little hacking iPhone support should work
This file contains 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
require 'httparty' | |
require 'ruby-notify-my-android' | |
set :application, "example" | |
set :repository, "" | |
set :scm, :none | |
role :web, "localhost" | |
role :web, "example.tld" | |
role :app, "example.tld" | |
role :db, "db.example.tld", :primary => true | |
def push_notify(hostname) | |
NMA.notify do |n| | |
n.apikey = YAML.load_file('nmaapi.yml')['apikey'] | |
n.application = application | |
n.event = "Check Load Balencer Status" | |
n.description = message | |
end | |
end | |
desc "Retrieves the check.txt file to see if the host is in the load balancer" | |
task :check_load_balancer do | |
roles[:web].map(&:host).each do |hostname| | |
url = "http://#{hostname}/check.txt" | |
response = HTTParty.get url | |
message = "Retrieving #{url}: #{response.message}" | |
puts message | |
push_notify message | |
end | |
end | |
#-- | |
# (C)2012 Dwight Spencer <dspencer@denzuko.co.cc> | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to | |
# deal in the Software without restriction, including without limitation the | |
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | |
# sell copies of the Software, and to permit persons to whom the Software is | |
# furnished to do so, subject to the following conditions: | |
# | |
# The above copyright notice and this permission notice shall be included in | |
# all copies or substantial portions of the Software. | |
# | |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
# THE SOFTWARE. | |
#++ |
This file contains 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
--- | |
apikey: API_KEY_FROM_notifymyandroid.com |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment