Skip to content

Instantly share code, notes, and snippets.

@petethepig
Created September 15, 2012 13:33
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save petethepig/3727908 to your computer and use it in GitHub Desktop.
Save petethepig/3727908 to your computer and use it in GitHub Desktop.
Sending SMS every time the available disk space is less than 25%
#!/usr/local/bin/ruby
require 'net/http'
require 'sys/filesystem' # gem install sys-filesystem
api_id="api_id from sms.ru" # get one on sms.ru
phone_number="79111234567" # your phone number
stat = Sys::Filesystem.stat("/")
space = (stat.blocks_available.to_f / stat.blocks * 100).round
if space < 25
uri = URI("http://sms.ru/sms/send?api_id=#{api_id}&to=#{phone_number}&text=#{space}%25+of+disk+space+left")
Net::HTTP.get(uri)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment