using inotify with nfs

  • jbellenger

    jbellenger - 2009-02-23

    A couple weeks ago I started looking into why my mediatomb server wasn't picking up new media from inotify. My library, which is stored on a NAS and made available to my mediatomb machine via NFS, was being frequently updated with new files but mediatomb would not find these files unless I did a complete restart of the mediatomb process or I manually added them via the web UI. It turns out that an NFS server does not propagate inotify events to connected clients, and that library changes made on a machine other than the one running mediatomb would not be reflected in the mt database.

    I suspect that there are other users on this mailing list with setups similar to mine who have had a hard time keeping their mt database up to date with their library. I've put together a program that listens for inotify events on a fileserver and converts them into HTTP requests that the mediatomb daemon can understand. The program and some notes on its usage are available at the address below:

    Thanks for the great program.


    • Jin

      Jin - 2009-02-25

      Sounds interesting, thanks for posting.

      Just as a word of warning: the UI API is not really stable and may change unexpectedly (in fact, 0.11 and upcoming 0.12 are already slightly different).

      Kind regards,

  • Lord_PInhead

    Lord_PInhead - 2011-05-15

    Is there a copy of the Proxy somewhere? I setup my new homebox and mount my partitions into an xen VM, where Mediatomb is running.

    If there is no copy of it, what is the URL to send an the new filename to MT? I still have some Perlscripts with inotfy here, should not be that hard to change it.


  • chowjok

    chowjok - 2011-08-22

    Found the script on

    Remove all instances of ".EventsCodes" from the script and script won't have any errors. The mediatomb API has been changed so that needs to be fixed. I haven't yet found the URL that adds files. If someone knows something, please let me know.

  • Lord_PInhead

    Lord_PInhead - 2011-08-23

    Great, no i have to inspect the API. Should´nt be a big problem, just use an proxy and capture the traffic, you should see the POST-Uri. The alternative is, use Wireshark to capture and reverse-engineere it. I will give it a shot when i´m back home.

  • chowjok

    chowjok - 2011-08-26

    I'm not sure what to look for. Am I supposed to pass the entire directory to the Mediatomb API URL, or just the new file(s)?

    Because in the web interface, you add entire directories and it picks up the new files from there so I don't know how to make it add just the newly added fles.

  • Lord_PInhead

    Lord_PInhead - 2011-08-26

    This isn´t that hard. Just watch an directory via inotify, and if an supportet File was added (on_file_close, so its done with saving), just pass the new file incl. his path to Mediatomb and it adds it to you PC-Directory.

    I add a new file under:
    my monitoring programm with inotify waits util it gets closed, and send it to mediatomb, like:


    just to get you an picture of it. I could send of course the whole directory, but think about 12 TB of Musik, Videos and Pictures it should reindex every 5 min. or i send the /media/movies folder him, i has atm around 3 TB movies. Damn HD-Camcorder :)

  • chowjok

    chowjok - 2011-08-26

    Ah, cool. That sounds simple enough. I'll give that a try tonight.

  • chowjok

    chowjok - 2011-08-27

    I've made some progress. I managed to modify the script to make it add files and I'm looking at getting it to remove deleted files. It doesn't seem to trigger my custom import script though. I'll post an updated version soon.

  • Lord_PInhead

    Lord_PInhead - 2011-08-27

    Great, i was to install an testserver tomorrow in Virtualbox and grep the traffic my browser would make. Maybe i see what URL it uses, could be an Javascript Post like an AJAX Request. The fileadd was just an example, didn't know what the real URL is ;)

  • chowjok

    chowjok - 2011-08-27

    Okay, this is what I've cooked up so far -

    It can add and delete files using the new API
    It can resolve rar files to the rar content filename (enable with -rar option)

    My custom import script isn't getting triggered when it adds new files. I'm not sure why. But I can see the files in "PC Directory"


Log in to post a comment.