Recieve notification when folder reaches a certain size?


Recommended Posts

Hi!

 

I have a docker container that slowly fills up a folder, and currently clearing it manually is the best solution while I write a script to handle it for me.

 

Is there a way to cause a dashboard pop-up if a folder goes above say 5GB used or maybe a % of the disk?

 

(I searched the forums and didn't see a similar question, sorry if it's a repeat!)

Link to comment

image.png.a9112413750eaefab4dc9b45075868de.png

 

#!/bin/bash
#description=Checks if the chosen folder is over a certain amount, alerts you if so.
#arrayStarted=true
#name=Warn if Folder too big
#clearLog=true
#noParity=true 

# Add more text to name if you need several? Or just add onto the script.

warningMessage="Your appdata folder is getting too big!"

checkedPath="/mnt/disk1/appdata/"

# Size in gigabytes that you want to be warned at and above.
let warningSize=5

# ----------------

let "warningSize = warningSize * 1000000"

# https://stackoverflow.com/a/11518088
duSize=$(du -sk $checkedPath | awk '{print$1}')

if (( duSize > warningSize )); then
    /usr/local/emhttp/webGui/scripts/notify -i alert -s "$warningMessage" -d "$(du -hs $checkedPath)"
fi

#echo ${duSize}
#echo ${warningSize}

echo Finished

 

Works with the User Scripts add-on for scheduling!

  • Like 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.