I'm on FreeBSD11. I have one or more zfs pool on my system. I want a script to check pool status and update the database, my code is:
pool=$(/sbin/zpool status | grep pool |awk '{print $2}')
for i in $pool
do
status=$(/sbin/zpool status ${i} | egrep -i '(ONLINE|DEGRADED|FAULTED|OFFLINE|UNAVAIL|REMOVED|FAIL|DESTROYED|corrupt|cannot|unrecover)')
sqlite3 <address>/my.db <<EOS
update myTable set status = $status where name = ${i};
EOS
echo $status
done
This code has error, and doesn't update my database. Can you help me figure out the mistake?