Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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