diff options
author | Erich Eckner <git@eckner.net> | 2024-01-29 21:23:59 +0100 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2024-01-29 21:23:59 +0100 |
commit | 84862abc33643172424dcd08241d0580db842a84 (patch) | |
tree | 3e5d5438c5a6b853951d64456749869200481588 | |
parent | 625ea4d23360dea41f0200bd69afd92f94d97cce (diff) | |
download | print-status-84862abc33643172424dcd08241d0580db842a84.tar.xz |
print-status-html: only check mdadm if soft raid exists
-rwxr-xr-x | print-status-html | 126 |
1 files changed, 65 insertions, 61 deletions
diff --git a/print-status-html b/print-status-html index 12dba2b..9ff06d3 100755 --- a/print-status-html +++ b/print-status-html @@ -52,73 +52,77 @@ EOF s/$/<br>/ ' - cat <<EOF + if [ -f /proc/mdstat ]; then + + cat <<EOF <h1>Software RAIDs</h1> EOF - { - sed -n ' - /^Personalities/d - /^\S/ { - N - s/^\(\S\+\)\s*:\s*\(\S\+\)\s.*\n\s*\([0-9]\)/\1: \2 \3/ + { + sed -n ' + /^Personalities/d + /^\S/ { + N + s/^\(\S\+\)\s*:\s*\(\S\+\)\s.*\n\s*\([0-9]\)/\1: \2 \3/ + T + p + } + s/^\s\+\(\[[^][]\+]\)\s\+\(\S\+\)\s\+=\s\+\(\S\+\)\s\+\S\+\s\+\(finish=\S\+\)\s.*$/\2 \3 \1 \4/ T p - } - s/^\s\+\(\[[^][]\+]\)\s\+\(\S\+\)\s\+=\s\+\(\S\+\)\s\+\S\+\s\+\(finish=\S\+\)\s.*$/\2 \3 \1 \4/ - T - p - ' /proc/mdstat \ - | sed ' - s/^md\([0-9]\+\):/\1 \0/ - ' \ - | sort -k1n,1 \ - | sed ' - s/^\([0-9]\+\) md\1:/md\1:/ - ' \ - | while read -r line; do - if [ -z "${line%%* finish=*min*}" ]; then - duration="${line##* finish=}" - duration="${duration%%min*}" - time=$( - date +'%F %T' -d@$(( - $(date +%s) + $(echo "60 * ${duration}" | bc -l | sed 's/\..*$//') - )) - ) - printf '%s (%s)\n' "${line}" "${time}" - else - printf '%s\n' "${line}" - fi - done \ - | sed ' - s,^\(.* \)active \(.*\[U\+\]\)$,<font color="#008000">\1\2</font>, - t - s,^\(re\(shape\|covery\|sync\) \S\+\) \[\(\S*\)>\(\.*\)\] \(\S\+\s\+\S\+\s\+\S\+\)$,<font color="#808000">\1</font> <tt>[<font color="#008000">\3</font><font color="#808000">\></font><font color="#800000">\4</font>]</tt> \5, - t - s,^\(.* \)active \(.*\)$,<font color="#008000">\1\2</font>, - t - s,^.*$,<font color="#800000">\0</font>, - ' + ' /proc/mdstat \ + | sed ' + s/^md\([0-9]\+\):/\1 \0/ + ' \ + | sort -k1n,1 \ + | sed ' + s/^\([0-9]\+\) md\1:/md\1:/ + ' \ + | while read -r line; do + if [ -z "${line%%* finish=*min*}" ]; then + duration="${line##* finish=}" + duration="${duration%%min*}" + time=$( + date +'%F %T' -d@$(( + $(date +%s) + $(echo "60 * ${duration}" | bc -l | sed 's/\..*$//') + )) + ) + printf '%s (%s)\n' "${line}" "${time}" + else + printf '%s\n' "${line}" + fi + done \ + | sed ' + s,^\(.* \)active \(.*\[U\+\]\)$,<font color="#008000">\1\2</font>, + t + s,^\(re\(shape\|covery\|sync\) \S\+\) \[\(\S*\)>\(\.*\)\] \(\S\+\s\+\S\+\s\+\S\+\)$,<font color="#808000">\1</font> <tt>[<font color="#008000">\3</font><font color="#808000">\></font><font color="#800000">\4</font>]</tt> \5, + t + s,^\(.* \)active \(.*\)$,<font color="#008000">\1\2</font>, + t + s,^.*$,<font color="#800000">\0</font>, + ' + + find /sys/block/ \ + -mindepth 1 \ + -maxdepth 1 \ + -name 'md*' \ + -exec sh -c 'test -f "{}/md/mismatch_cnt"' \; \ + -printf '%f: ' \ + -exec cat '{}/md/mismatch_cnt' \; \ + | sed 's@^md\([0-9]\+\): @\1 \0@' \ + | sort -k1n,1 \ + | sed 's@^\S\+ @@' \ + | sed ' + s@^\S\+: 0$@<font color="#008000">\0</font>@ + t + s@^.*$@<font color="#800000">\0</font>@ + ' + } \ + | sed ' + s/$/<br>/ + ' - find /sys/block/ \ - -mindepth 1 \ - -maxdepth 1 \ - -name 'md*' \ - -exec sh -c 'test -f "{}/md/mismatch_cnt"' \; \ - -printf '%f: ' \ - -exec cat '{}/md/mismatch_cnt' \; \ - | sed 's@^md\([0-9]\+\): @\1 \0@' \ - | sort -k1n,1 \ - | sed 's@^\S\+ @@' \ - | sed ' - s@^\S\+: 0$@<font color="#008000">\0</font>@ - t - s@^.*$@<font color="#800000">\0</font>@ - ' - } \ - | sed ' - s/$/<br>/ - ' + fi if command -v ssacli >/dev/null 2>&1; then |