I'm running the following on Debian 10:


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:

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
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)
        /usr/bin/zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -k "$TRAPPER" -o "$RESULT"

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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.