mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-10 21:19:59 +00:00
Make check_disk_space() use bytes (given new size type options with are converted to bytes, 1k=>1024).
This commit is contained in:
@@ -18,36 +18,51 @@ is \
|
||||
"2" \
|
||||
"2-line df output"
|
||||
|
||||
check_disk_space "$SAMPLE/diskspace001.txt" 22000 18 >$TMPDIR/out 2>&1
|
||||
# Filesystem 1024-blocks Used Available Capacity Mounted on
|
||||
# /dev/disk0s2 118153176 94409664 23487512 81% /
|
||||
#
|
||||
# Those values are in Kb, so:
|
||||
# used = 94409664 (94.4G) = 96_675_495_936 bytes
|
||||
# free = 23487512 (23.4G) = 24_051_212_288 bytes
|
||||
# pct free = 100 - 81 = 19 %
|
||||
|
||||
# want free - 100, 18 < 19, so this should be ok.
|
||||
check_disk_space "$SAMPLE/diskspace001.txt" 24051212188 18 >$TMPDIR/out 2>&1
|
||||
is "$?" "0" "Enough disk space"
|
||||
is \
|
||||
"`cat $TMPDIR/out`" \
|
||||
"" \
|
||||
"No output if enough disk space"
|
||||
|
||||
check_disk_space "$SAMPLE/diskspace001.txt" 24000 18 >$TMPDIR/out 2>&1
|
||||
# want free - 100 is ok, but 20 < 19 is not.
|
||||
check_disk_space "$SAMPLE/diskspace001.txt" 24051212188 20 >$TMPDIR/out 2>&1
|
||||
is "$?" "1" "Not enough % free"
|
||||
|
||||
# want free + 100, so this should fail
|
||||
# (real free is 100 bytes under what we want)
|
||||
check_disk_space "$SAMPLE/diskspace001.txt" 24051212388 18 >$TMPDIR/out 2>&1
|
||||
is "$?" "1" "Not enough MB free"
|
||||
cmd_ok \
|
||||
"grep -q '19% free, 23487512 KB free; wanted more than 18% free or 24576000 KB free' $TMPDIR/out" \
|
||||
"grep -q 'Actual: 19% free, 24051212288 bytes free (- 0 bytes margin)' $TMPDIR/out" \
|
||||
"Warning if not enough disk space"
|
||||
|
||||
check_disk_space "$SAMPLE/diskspace001.txt" 22000 19 >$TMPDIR/out 2>&1
|
||||
is "$?" "1" "Not enough % free"
|
||||
|
||||
# ###########################################################################
|
||||
# Check with a margin (amount we plan to use in the future).
|
||||
# ###########################################################################
|
||||
|
||||
check_disk_space "$SAMPLE/diskspace001.txt" 22000 18 100
|
||||
# want free - 100 + 50 margin, so effectively want free - 50 is ok.
|
||||
check_disk_space "$SAMPLE/diskspace001.txt" 24051212188 18 50
|
||||
is "$?" "0" "Enough disk space with margin"
|
||||
|
||||
check_disk_space "$SAMPLE/diskspace001.txt" 23000 18 100 >$TMPDIR/out 2>&1
|
||||
# want free - 100 + 101 margin, so real free is 1 byte under what we want.
|
||||
check_disk_space "$SAMPLE/diskspace001.txt" 24051212188 18 101 >$TMPDIR/out 2>&1
|
||||
is "$?" "1" "Not enough MB free with margin"
|
||||
|
||||
check_disk_space "$SAMPLE/diskspace001.txt" 100 5 20000 >$TMPDIR/out 2>&1
|
||||
# want free - 100 + 50 margin ok but %free will be 19 which is < 25.
|
||||
check_disk_space "$SAMPLE/diskspace001.txt" 24051212188 25 50 >$TMPDIR/out 2>&1
|
||||
is "$?" "1" "Not enough % free with margin"
|
||||
cmd_ok \
|
||||
"grep -q '3% free,' $TMPDIR/out" \
|
||||
"grep -q 'Actual:[ ]*19% free,' $TMPDIR/out" \
|
||||
"Calculates % free with margin"
|
||||
|
||||
# ###########################################################################
|
||||
|
Reference in New Issue
Block a user