Continuing on my series on ZFS storage, below is the script that will monitor the today snapshot creation/archiving, this can also be integrated with Zabbix.

Snapshot format is snapshotname@todaysdate

#!/bin/bash

TODAY=$(date +%Y-%m-%d)
WARNING=()
TARGETLIST=($(zfs list -t snapshot -o name -H | awk -F'@' '{print $1}' | sort | uniq))
for i in ${TARGETLIST[@]}; do
        FINDSNAPSHOT=$(zfs list -t snapshot -o name -H | grep "$i@$TODAY")
        if [ -z "$FINDSNAPSHOT" ]; then
                WARNING+=("$i@$TODAY snapshot is missing!")
        else
                continue
        fi
done
END=${#WARNING[@]}
COUNTER=1
while [[ $COUNTER -lt $END ]]; do
        echo ${WARNING[$COUNTER]}
        COUNTER=$COUNTER+1
done