Skip to content

Commit 8560712

Browse files
authored
Modify to handle longer scrub times
Modify parsing of zpool status output to accommodate users with scrub times > 24 hours
1 parent 8e22ba9 commit 8560712

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

zpool_report.sh

+17-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ email=""
1919
# FreeBSD 11.0 1100512
2020
# FreeBSD 11.1 1101505
2121
# FreeBSD 12.2 1202000
22+
#
23+
# If a scrub runs longer than 24 hours, we have two additional tokens to parse in the
24+
# zpool status scan line output ("'x' days"):
25+
#
26+
# 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
27+
# scan: scrub repaired 0B in 1 days 11:56:46 with 0 errors on Wed Dec 9 06:07:04 2020
28+
#
29+
# 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
30+
# scan: scrub repaired 0B in 00:09:11 with 0 errors on Sun Dec 13 17:31:24 2020
2231

2332
fbsd_relver=$(uname -K)
2433

@@ -101,8 +110,15 @@ for pool in $pools; do
101110
scrubErrors="N/A"
102111
scrubAge="N/A"
103112
if [ "$(zpool status "$pool" | grep "scan" | awk '{print $2}')" = "scrub" ]; then
104-
scrubRepBytes="$(zpool status "$pool" | grep "scan" | awk '{print $4}')"
113+
parseLong=0
105114
if [ "$fbsd_relver" -gt 1101000 ] && [ "$fbsd_relver" -lt 1200000 ]; then
115+
parseLong=$((parseLong+1))
116+
fi
117+
if [ "$(zpool status "$pool" | grep "scan" | awk '{print $7}')" = "days" ]; then
118+
parseLong=$((parseLong+1))
119+
fi
120+
scrubRepBytes="$(zpool status "$pool" | grep "scan" | awk '{print $4}')"
121+
if [ $parseLong -gt 0 ]; then
106122
scrubErrors="$(zpool status "$pool" | grep "scan" | awk '{print $10}')"
107123
scrubDate="$(zpool status "$pool" | grep "scan" | awk '{print $17"-"$14"-"$15"_"$16}')"
108124
else

0 commit comments

Comments
 (0)