From: Tomas Mudrunka Date: Thu, 23 Mar 2023 22:44:58 +0000 (+0100) Subject: memtest probe X-Git-Url: https://git.harvie.cz/?a=commitdiff_plain;h=0b8d006aa72c56eff1368c6c69b09547c455a5ed;p=mirrors%2FPrograms.git memtest probe --- diff --git a/bash/probe_memtest.sh b/bash/probe_memtest.sh new file mode 100755 index 0000000..2034fd1 --- /dev/null +++ b/bash/probe_memtest.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +prefix="RAM STATUS:" +unsure_ret=0 + +[ "$1" = "-f" ] && unsure_ret=1 + +get_meminfo() { + field="$1" + file="/proc/meminfo" + grep ^"$field": "$file" | grep -o '[0-9]*' || + echo "$prefix Field $field not found in $file" >&2 +} + +memtest=$(get_meminfo EarlyMemtestBad) +ecccorr=$(get_meminfo HardwareCorrupted) + +[ -z "$memtest" -o -z "$ecccorr" ] && { + echo "$prefix Memtest not enabled in kernel" + exit $unsure_ret +} + +echo "$prefix EarlyMemtestBad:$memtest HardwareCorrupted:$ecccorr" +[ $memtest -gt 0 -o $ecccorr -gt 0 ] && { + echo "$prefix Corrupted" + exit 255 +} +echo "$prefix OK" +exit 0