File monitor and auto-indexer for Synology DiskStation NAS.
I'm using this on a DS213j, but I expect it may work on other models as well.
Updated for DSM 6.0+. May still work on earlier DSM versions, but I can't vouch for that.
Install Python3 from the DiskStation package manager.
Copy
mediamon.py
andS99mediamon.sh
to your admin user's homedir (i.e./volume1/homes/admin/
):scp *.{py,sh} [email protected]:~
.SSH into your DiskStation as admin (e.g.
ssh [email protected]
-- use the right IP address for your DiskStation) and move the files into a bin directorymkdir bin && mv *.{py,sh} bin
Install pyinotify:
sudo -i
to become the root user. This will require re-entering your admin user's password.python3 -m ensurepip && python3 -m pip install pyinotify
- Test that pyinotify works:
python3 -m pyinotify -v /tmp
Setup two triggered tasks in Task Scheduler user defined scripts:
- Boot
/volume1/homes/admin/bin/S99mediamon.sh start
- Shutdown
/volume1/homes/admin/bin/S99mediamon.sh stop
Restart your Synology (if you want to verify that the mediamon service will start up automatically in the future), or start it up yourself:
/volume1/homes/admin/bin/S99mediamon.sh start
.Add some media files to
/volume1/photo
,/volume1/music
, or/volume1/video
, and check the log at/var/log/mediamon.log
to verify that it's working. You should see asynoindex -a
entry for each added file.
If you have a lot of files/directories in some watched volumes, you may see "No
space on device" errors from pyinotify. This doesn't actually have to do with
space on the drive, it means you're hitting the watched-files limit. You can
increase this limit by running (as root): echo
fs.inotify.max_user_watches=100000 | sudo tee -a /etc/sysctl.conf; sudo sysctl
-p
.
Suggestions, improvements, bug reports or pull requests welcome!
Based on a blog post.