bundlewrap/bundles/zfs/files/check_zpool_online

19 lines
360 B
Bash

#!/bin/bash
if [ $# -eq 0 ] ; then
echo "Please provide pool name as first argument, e.g. 'tank'."
exit 3
fi
status="$(zpool status "$1")"
if [ "$(echo "$status" | grep '^ state:')" = ' state: ONLINE' ]
then
echo "OK - Pool '$1' is online"
exit 0
else
echo "CRITICAL - Pool '$1' is FAULTY or NOT ONLINE"
echo "$status"
exit 2
fi