Skip to content

Instantly share code, notes, and snippets.



Last active Aug 29, 2015
What would you like to do?
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
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 #{}:\n"
puts "#{status}\n"
m =
message = {
:subject=> "Status: #{status} [#{f}]",
:from_name=> "Your Friendly Neighborhood Server",
:email=> "",
:name=> "Billy"
:html=>"#{status} for #{f}",
sending = m.messages.send message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment