Monitor disk usage with a simple Ruby script
1 2 dev = 'sda1' 3 report = `df -h` 4 disk_remaining = report[/sda\w+\s+\d+?.?\dG\s+\d+?.?\dG\s+(\d+.?\d+?G)/,1] 5 puts "running low on disk space (#{dev}: #{disk_remaining })" if disk_remaining.to_i < 3
DZone Snippets > jrobertson > usage
13480 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
1 2 dev = 'sda1' 3 report = `df -h` 4 disk_remaining = report[/sda\w+\s+\d+?.?\dG\s+\d+?.?\dG\s+(\d+.?\d+?G)/,1] 5 puts "running low on disk space (#{dev}: #{disk_remaining })" if disk_remaining.to_i < 3