Wiki/Proxmox/Notification/ZFS-Alarm.md

1.3 KiB

ZFS Alarm

Richte zuerst dein Proxmox ein um Emails zu senden.

Erstelle ein neues Script

#!/bin/bash

# pool to check
POOLS=("Name-deines-Tanks" "Name-deines-Tanks2" "Name-deines-Tanks3")

# needed paths
LOGFILE="/var/log/poolStatusCheck.log"
ZFS="/sbin/zfs"

for POOL in ${POOLS[@]}; do
  if [ "$(zpool status $POOL -x)" != "pool '$POOL' is healthy" ]; then
        echo "$(date) - Alarm - zPool $POOL is not healthy" >> $LOGFILE
        echo $'From: Proxmox <EMAIL DIE DU EINGERICHTET HAST>\nSubject: ZFS ALARM\n'$(date)' - Alarm - zPool '$POOL' is not healthy' | proxmox-mail-forward
  fi
done

Bearbeite das Script.

Ändere die Poolnamen
Ändere die From Email. Die From Email muss die gleiche sein wie die in deiner SMTP Einstellung, oder die deines Root Accounts.
Wichtig: Die <> Klammern braucht es.

Autorun Cronjob

Mit Cronjobs kannst du commands automatisch starten.

Arbeite in der Root shell

Gib dafür crontab -e in deiner Konsole ein.

Auf der Website cron.help kannst du ein Pattern erstellen.

*/10 * * * * *

Dieses Pattern wird dafür sorgen, dass das Script alle 10 Minuten ausgeführt wird.

In der Konsole sollte jetzt Crontab offen sein und da kannst du ganz unten nun die folgende Zeile einfügen:

*/10 * * * * /PFAD/ZU/DEINEM/SCRIPT.sh

Fertig.