2

I'm running the following on Debian 10:

zfs-0.8.4-2~bpo10+1
zfs-kmod-0.8.4-2~bpo10+1

I have a 2TB (passphrase encrypted) dataset used by many colleagues. I am also using Zabbix for monitoring, and have implemented certain alarms to know if too many files have been deleted. This is the script I'm running as a cronjob once a day to check how many files have been modified, deleted or added:

#!/bin/bash
LIST="/tmp/snaplist.txt"
DIFF="/tmp/diff.txt"
zfs list -t snapshot | grep production_dataset | grep 'snap_31' | awk '{print $1}' | tail -2 > $LIST && echo "Snapshot list saved"

while read -r SNAP; do
        snaps+=("$SNAP")
done < $LIST

zfs diff "${snaps[0]}" "${snaps[1]}" > $DIFF && echo "Diff saved successfully"

status=(M - + R)
trappers=(mod rem add ren)

for ((n=0;n<${#status[@]};n++)); do
        RESULT=$(cat $DIFF | grep -E "^${status[n]}" | wc -l)
        TRAPPER="zfsdiff_${trappers[n]}"
        /usr/bin/zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -k "$TRAPPER" -o "$RESULT"
done

rm $LIST
rm $DIFF

If I run the script manually, it works 90% of the time. Sometimes it gives this error (when running the zfs diff command:

Key must be loaded to discover path names: Permission denied

When running the script via cron, it fails almost all the time, unless I had run the script manually first. Then it works for 2 days, and goes back to giving me the error above.

It also takes a very long while to do the diff (15-20 minutes), and I'm not sure whether it has anything to do with the error above or not. Any ideas?

Oleg
  • 373
  • 1
  • 7
  • 17

0 Answers0