mirror of
https://github.com/Spearfoot/FreeNAS-scripts
synced 2025-12-06 01:23:19 +00:00
Modify to work with TrueNAS 12.0
This commit is contained in:
@@ -8,6 +8,8 @@ email=""
|
||||
# zpool output changed from FreeNAS version 11.0 to 11.1, breaking
|
||||
# our parsing of the scrubErrors and scrubDate variables. Added a
|
||||
# conditional to test for the FreeNAS version and parse accordingly.
|
||||
# This changed again with the release of TrueNAS. Ironically, back to
|
||||
# the way parsing worked with older versions of FreeNAS.
|
||||
#
|
||||
# We obtain the FreeBSD version using uname, as suggested by user
|
||||
# Chris Moore on the FreeBSD forum.
|
||||
@@ -16,6 +18,7 @@ email=""
|
||||
#
|
||||
# FreeBSD 11.0 1100512
|
||||
# FreeBSD 11.1 1101505
|
||||
# FreeBSD 12.2 1202000
|
||||
|
||||
fbsd_relver=$(uname -K)
|
||||
|
||||
@@ -54,11 +57,16 @@ Content-Disposition: inline
|
||||
) >> ${logfile}
|
||||
|
||||
for pool in $pools; do
|
||||
if [ "${pool}" = "freenas-boot" ]; then
|
||||
frag=""
|
||||
else
|
||||
if [ "$fbsd_relver" -ge 1101000 ]; then
|
||||
frag="$(zpool list -H -o frag "$pool")"
|
||||
else
|
||||
if [ "${pool}" = "freenas-boot" ] || [ "${pool}" = "boot-pool" ]; then
|
||||
frag=""
|
||||
else
|
||||
frag="$(zpool list -H -o frag "$pool")"
|
||||
fi
|
||||
fi
|
||||
|
||||
status="$(zpool list -H -o health "$pool")"
|
||||
errors="$(zpool status "$pool" | grep -E "(ONLINE|DEGRADED|FAULTED|UNAVAIL|REMOVED)[ \t]+[0-9]+")"
|
||||
readErrors=0
|
||||
@@ -94,7 +102,7 @@ for pool in $pools; do
|
||||
scrubAge="N/A"
|
||||
if [ "$(zpool status "$pool" | grep "scan" | awk '{print $2}')" = "scrub" ]; then
|
||||
scrubRepBytes="$(zpool status "$pool" | grep "scan" | awk '{print $4}')"
|
||||
if [ "$fbsd_relver" -gt 1101000 ]; then
|
||||
if [ "$fbsd_relver" -gt 1101000 ] && [ "$fbsd_relver" -lt 1200000 ]; then
|
||||
scrubErrors="$(zpool status "$pool" | grep "scan" | awk '{print $10}')"
|
||||
scrubDate="$(zpool status "$pool" | grep "scan" | awk '{print $17"-"$14"-"$15"_"$16}')"
|
||||
else
|
||||
@@ -105,19 +113,18 @@ for pool in $pools; do
|
||||
currentTS="$(date "+%s")"
|
||||
scrubAge=$((((currentTS - scrubTS) + 43200) / 86400))
|
||||
fi
|
||||
if [ "$status" = "FAULTED" ] \
|
||||
|| [ "$used" -gt "$usedCrit" ] \
|
||||
|| ( [ "$scrubErrors" != "N/A" ] && [ "$scrubErrors" != "0" ] )
|
||||
then
|
||||
if [ "$status" = "FAULTED" ] || [ "$used" -gt "$usedCrit" ]; then
|
||||
symbol="$critSymbol"
|
||||
elif [ "$scrubErrors" != "N/A" ] && [ "$scrubErrors" != "0" ]; then
|
||||
symbol="$critSymbol"
|
||||
elif [ "$status" != "ONLINE" ] \
|
||||
|| [ "$readErrors" != "0" ] \
|
||||
|| [ "$writeErrors" != "0" ] \
|
||||
|| [ "$cksumErrors" != "0" ] \
|
||||
|| [ "$used" -gt "$usedWarn" ] \
|
||||
|| [ "$scrubRepBytes" != "0" ] \
|
||||
|| [ "$(echo "$scrubAge" | awk '{print int($1)}')" -gt "$scrubAgeWarn" ]
|
||||
then
|
||||
|| [ "$(echo "$scrubAge" | awk '{print int($1)}')" -gt "$scrubAgeWarn" ]; then
|
||||
symbol="$warnSymbol"
|
||||
elif [ "$scrubRepBytes" != "0" ] && [ "$scrubRepBytes" != "0B" ] && [ "$scrubRepBytes" != "N/A" ]; then
|
||||
symbol="$warnSymbol"
|
||||
else
|
||||
symbol=" "
|
||||
|
||||
Reference in New Issue
Block a user