From 0b8d006aa72c56eff1368c6c69b09547c455a5ed Mon Sep 17 00:00:00 2001 From: Tomas Mudrunka Date: Thu, 23 Mar 2023 23:44:58 +0100 Subject: [PATCH] memtest probe --- bash/probe_memtest.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 bash/probe_memtest.sh 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 -- 2.30.2