From 8b6acf7791f1ee23cccf702526830a861782286a Mon Sep 17 00:00:00 2001 From: cronekorkn Date: Thu, 2 Mar 2023 15:38:07 +0100 Subject: [PATCH] bundles/zfs/files/check_zpool_online: refactor --- bundles/zfs/files/check_zpool_online | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/bundles/zfs/files/check_zpool_online b/bundles/zfs/files/check_zpool_online index da1f9a2..cb37848 100755 --- a/bundles/zfs/files/check_zpool_online +++ b/bundles/zfs/files/check_zpool_online @@ -1,16 +1,18 @@ #!/bin/bash -for pool in $(zpool get name -H -o value) +for result in "$(zpool list -H -o name,health tank)" do - status=$(zpool get health -H -o value $pool) - if [ "$status" != ONLINE ] + name=$(cut -f1 <<< $result) + health=$(cut -f2 <<< $result) + + if [ "$health" != ONLINE ] then - errors="$error\"$pool\" status is $status\n" + errors="$errors\"$name\" health is \"$health\"\n" fi done if [ "$errors" != "" ] then - echo "CRITICAL - $errors" + echo $errors exit 2 fi