From 5992345c3bec84557ba3792d505e614662019d93 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 17 Dec 2016 15:09:25 +0100 Subject: [PATCH] Add BTRFS file system checking and notifications save state of notifications --- plugins/dynamix/scripts/monitor | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/plugins/dynamix/scripts/monitor b/plugins/dynamix/scripts/monitor index cd88fd1a5..e49ce3183 100755 --- a/plugins/dynamix/scripts/monitor +++ b/plugins/dynamix/scripts/monitor @@ -237,9 +237,22 @@ foreach ($disks as $disk) { // count disk errors if ($disk['numErrors']>0) $errors[] = "$text - $info (errors {$disk['numErrors']})"; // check file system of cache pool + $item = 'pool'; if ($name=='cache' && $disk['fsType']=='btrfs') { - if (exec("/sbin/btrfs filesystem show {$disk['uuid']}|grep -c 'missing'")>0) exec("$notify -e \"unRAID $text message\" -s \"Warning [$server] - Cache pool BTRFS missing device(s)\" -d \"$info\" -i \"warning\""); - if (exec("/sbin/btrfs filesystem df /mnt/cache|grep -c '^Data'")>1) exec("$notify -e \"unRAID $text message\" -s \"Warning [$server] - Cache pool BTRFS too many profiles\" -d \"$info\" -i \"warning\""); + $attr = 'missing'; + if (exec("/sbin/btrfs filesystem show {$disk['uuid']}|grep -c 'missing'")>0) { + if (empty($saved[$item][$attr])) { + exec("$notify -e \"unRAID $text message\" -s \"Warning [$server] - Cache pool BTRFS missing device(s)\" -d \"$info\" -i \"warning\""); + $saved[$item][$attr] = 1; + } + } elseif (isset($saved[$item][$attr])) unset($saved[$item][$attr]); + $attr = 'profile'; + if (exec("/sbin/btrfs filesystem df /mnt/cache|grep -c '^Data'")>1) { + if (empty($saved[$item][$attr])) { + exec("$notify -e \"unRAID $text message\" -s \"Warning [$server] - Cache pool BTRFS too many profiles\" -d \"$info\" -i \"warning\""); + $saved[$item][$attr] = 1; + } + } elseif (isset($saved[$item][$attr])) unset($saved[$item][$attr]); } }