-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprecent_move
31 lines (25 loc) · 1.31 KB
/
precent_move
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
# This unRAID bash script will run the mover if the cache drive is over a certain percentage full
# Modify the value to set what percentage is the threshold to start the mover
SETPOINT=80
# Only run script if cache disk enabled and in use (script chunk taken from stock mover script at /usr/local/sbin/mover) - DISABLED FOR 6.4
#if [ ! -d /mnt/cache -o ! -d /mnt/user0 ]; then
# exit 0
#fi
# If the mover is already running then exit (script chunk taken from stock mover script at /usr/local/sbin/mover - just added the pipe to logger)
if [ -f /var/run/mover.pid ]; then
if ps h `cat /var/run/mover.pid` | grep mover ; then
echo "mover already running" | /usr/bin/logger -s -tpercent_mover.sh[$$]
exit 0
fi
fi
# Check how full the cache drive is
AMOUNTFULL=$(df | grep /mnt/cache | awk '{ printf "%d", $5 }')
# Simple logic - if setpoint has been met or exceeded, run the mover. If not, don't run.
if [ "$AMOUNTFULL" -ge "$SETPOINT" ]
then
echo "Cache is $AMOUNTFULL% full, which is greater than or equal to the set point of $SETPOINT%. Running mover." | /usr/bin/logger -s -tpercent_mover.sh[$$]
/usr/local/sbin/mover
else
echo "Cache is $AMOUNTFULL% full, which is less than the set point of $SETPOINT%. Not running mover." | /usr/bin/logger -s -tpercent_mover.sh[$$]
fi