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%
require 'net/http'
require 'sys/filesystem' # gem install sys-filesystem
api_id="api_id from" # get one on
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("{api_id}&to=#{phone_number}&text=#{space}%25+of+disk+space+left")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment