Monitor disk usage with a simple Ruby script
dev = 'sda1' report = `df -h` disk_remaining = report[/sda\w+\s+\d+?.?\dG\s+\d+?.?\dG\s+(\d+.?\d+?G)/,1] puts "running low on disk space (#{dev}: #{disk_remaining })" if disk_remaining.to_i < 3
DZone Snippets > jrobertson > disk
12382 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
James Robertson http://www.r0bertson.co.uk
dev = 'sda1' report = `df -h` disk_remaining = report[/sda\w+\s+\d+?.?\dG\s+\d+?.?\dG\s+(\d+.?\d+?G)/,1] puts "running low on disk space (#{dev}: #{disk_remaining })" if disk_remaining.to_i < 3