memtest probe
authorTomas Mudrunka <tomas.mudrunka@gmail.com>
Thu, 23 Mar 2023 22:44:58 +0000 (23:44 +0100)
committerTomas Mudrunka <tomas.mudrunka@gmail.com>
Thu, 23 Mar 2023 22:44:58 +0000 (23:44 +0100)
bash/probe_memtest.sh [new file with mode: 0755]

diff --git a/bash/probe_memtest.sh b/bash/probe_memtest.sh
new file mode 100755 (executable)
index 0000000..2034fd1
--- /dev/null
@@ -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
This page took 0.111597 seconds and 4 git commands to generate.