Last active
August 29, 2015 14:08
-
-
Save trueheart78/a61c35018ebe467b4685 to your computer and use it in GitHub Desktop.
A simple ruby script to monitor filesizes during a large transfer. Setup to run through cron. Requires the mandrill-api gem to be installed, as well as a mandrill API key in your enviroment in MANDRILL_APIKEY
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
require 'mandrill' | |
files = ["mh-files-wo-lb-20141026_0009.tar.gz","mh-files-lb-only-20141026_0009.tar.gz"] | |
files.each do |f| | |
if File.exist?(f) | |
size = File.stat(f).size | |
gb = 1024 ** 3 | |
mb = 1024 ** 2 | |
status = "#{size / gb} gb (#{size / mb} mb)" | |
puts "File #{f} - as of #{Time.now}:\n" | |
puts "#{status}\n" | |
m = Mandrill::API.new | |
message = { | |
:subject=> "Status: #{status} [#{f}]", | |
:from_name=> "Your Friendly Neighborhood Server", | |
:text=>"See?", | |
:to=>[ | |
{ | |
:email=> "[email protected]", | |
:name=> "Billy" | |
} | |
], | |
:html=>"#{status} for #{f}", | |
:from_email=>"[email protected]" | |
} | |
sending = m.messages.send message | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment