2016-12-12 22:48:11 -06:00
|
|
|
#!/bin/bash
|
|
|
|
|
2016-12-13 19:31:58 -06:00
|
|
|
if [[ -z $OUTPUT_DIR ]] ; then
|
|
|
|
source scan-dmidecode
|
|
|
|
fi
|
|
|
|
|
|
|
|
cat /proc/meminfo > $OUTPUT_DIR/meminfo
|
|
|
|
|
|
|
|
MEM_RESERVED=256 #MB
|
|
|
|
MEM_AVAILABLE=`cat /proc/meminfo \
|
|
|
|
| grep 'MemAvailable' \
|
|
|
|
| grep 'kB' \
|
|
|
|
| cut -d ':' -f 2 \
|
|
|
|
| sed 's/[^0-9]\+//g'`
|
2016-12-13 19:52:26 -06:00
|
|
|
if [[ -z $MEM_AVAILABLE ]] ; then
|
|
|
|
MEM_AVAILABLE=`cat /proc/meminfo \
|
|
|
|
| grep 'MemFree' \
|
|
|
|
| grep 'kB' \
|
|
|
|
| cut -d ':' -f 2 \
|
|
|
|
| sed 's/[^0-9]\+//g'`
|
|
|
|
|
|
|
|
fi
|
|
|
|
if [[ -z $MEM_AVAILABLE ]] ; then
|
|
|
|
echo "Error: Could not parse /proc/meminfo for available memory" >&2
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
MEM_TESTABLE=$(( MEM_AVAILABLE - (MEM_RESERVED * 1024) ))
|
|
|
|
if (( $MEM_TESTABLE < 1024 )) ; then
|
|
|
|
echo "Testable memory $MEM_TESTABLE lower than 1 MB. Exiting" >&2
|
|
|
|
exit 3
|
|
|
|
fi
|
|
|
|
export MEM_TESTABLE
|
2016-12-13 19:31:58 -06:00
|
|
|
|
|
|
|
echo "$MEM_AVAILABLE kB available in system"
|
2016-12-13 19:52:26 -06:00
|
|
|
echo "$MEM_TESTABLE kB usable for memtester"
|
2016-12-13 19:31:58 -06:00
|
|
|
|
|
|
|
|
|
|
|
|