dotfiles/home/utils/disk_check.nix

19 lines
526 B
Nix
Raw Normal View History

2024-06-13 11:53:29 +02:00
{ pkgs }:
2024-06-10 16:31:23 +02:00
{
when = "*-*-* *:00:00";
script = toString (pkgs.writeShellScript "script" ''
REPORT_EMAIL=email@thomasave.be
ZPOOL_STATUS=$(zpool status -x)
if [ "$ZPOOL_STATUS" = "all pools are healthy" ] || [ "$ZPOOL_STATUS" = "no pools available" ]
then
printf 0 > /var/db/zpool.status
else
if [ "$(cat /var/db/zpool.status)" -eq 0 ]
then
zpool status | mail -s "ZPOOL NOT HEALTHY" $REPORT_EMAIL
printf 1 > /var/db/zpool.status
fi
fi
'');
}