Open gtr33m opened 8 years ago
Alternatively storage alerts would be nice. If you could fire off an email or http request at 95% disk usage at least you would know that you ran our of space.
Yes, same problem for me. Could you had the program "quota" in the OS ?
If you are using MotionEye you can stick a script into crontab and make it run every lets say 10 minutes:
#!/bin/bash
CURRENT=$(df /path/to/mounted/disk/with/your/motioneye/files | grep / | awk '{ print $5}' | sed 's/%//g')
THRESHOLD=95
if [ "$CURRENT" -gt "$THRESHOLD" ] ; then
mail -s 'Disk Space Alert' Your email address << EOF
You are running out of space. Used: $CURRENT%
EOF
fi
You can set to run this script every 10 minutes in crontab and if the disk is 95% full wil send you a warning email.
#!/bin/bash
CURRENT=$(df /path/to/mounted/disk/with/your/motioneye/files | grep / | awk '{ print $5}' | sed 's/%//g')
THRESHOLD=95
if [ "$CURRENT" -gt "$THRESHOLD" ] ; then
mail -s 'Disk Space Alert' Your email address << EOF
You are running out of space. Used: $CURRENT% The older than 7 days files will be removed in 9 minutes.
EOF
sleep 540
find /path/to/where/yourmotioneye/recordings/are/being/stored/ -mtime +7 -delete
fi
This script will do exactly the same thing as the one above, but will sleep for 9 minutes and the delete 7 days and older files. I have added the delay just in case there is something important in the older than 7 days files you want to keep, so you have got time to react.
You can modify the scripts any way you want!
You have to have ssmtp up and running on your system before you can use "mail" command.
Pretty straight forward, I would love a feature that overwrites or deletes old files when a disk nears capacity. I've been using motioneye for a while now and it's very reliable, but a couple of times it has stalled because the storage disk was full.