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