Created
September 16, 2013 12:17
-
-
Save nicdoye/6579975 to your computer and use it in GitHub Desktop.
Gradually (nearly) fill a disk. Using it to test monit rules. Obviously on a real box, with other users, the disk could fill up. Caveat user.
This file contains 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
#!/bin/bash | |
mountpoint=/tmp | |
sleeper=240 | |
# percentage of disk used | |
function percentage { df $1 | tail -1 | awk '{print $4}' | tr -d % ; } | |
# Where we'll write | |
tempdir=$(mktemp -d --tmpdir=${mountpoint}) | |
# Total disk in kB (Solaris needs the -k) | |
totalsize=$(df -k ${mountpoint}| tail -1 | awk '{print $1}') | |
# (roughly) 5% of the disk | |
writesize=$((${totalsize} / 20)) | |
pct=$(percentage /tmp) | |
while [ ${pct} -lt 95 ] | |
do | |
# Create a file (roughly) 5% of the disk size | |
dd if=/dev/zero of=$(mktemp --tmpdir=${tempdir}) bs=${writesize}K count=1 &>> /dev/null | |
pct=$(percentage /tmp) | |
sleep ${sleeper} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment