Fix mountpoint after full fs transfer if needed
[zfs-ubuntu/.git] / zfs-check-admin-lock
1 #!/bin/bash
2 # Checks to make sure the $lockdir hasn't been held for too long
3
4 MAXAGE_MIN=1440
5
6 # source our configuration
7 config="/etc/bin/zfs-scripts.conf"
8 [ -e "${config}.dist" ] && . ${config}.dist
9 [ -e "${config}" ] && . ${config}
10
11 if test "`find $lockdir -mmin +$MAXAGE_MIN 2>/dev/null`"; then
12   #echo "-> Found $lockdir that is > 1 day old"
13   ls -ld $lockdir | $mailx -s "zfs admin lock file > 1 day old" "$mailto"
14   exit 1
15 fi
16
17 PROC_ID=$(ps -e -o pid,etimes,command | grep zfs-replicate-all | grep -v tail | awk '{if($2>86400) print $0}' | head -n 1  | awk '{print $1}')
18 if [[ -n "$PROC_ID" ]]; then
19    ps -ef | grep $PROC_ID | grep -v grep | $mailx -s "zfs-replicate-all running > 1 day" "$mailto"
20   exit 1
21 fi
22
23 exit 0