Created
September 15, 2012 13:33
-
-
Save petethepig/3727908 to your computer and use it in GitHub Desktop.
Sending SMS every time the available disk space is less than 25%
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
#!/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