Hi,
Is it possible to configure the watch node with credentials to watch a folder on a network path?
What would be an alternative solution, if this is not possible?
Thanks for the help in advanced.
Regards,
Hi,
Is it possible to configure the watch node with credentials to watch a folder on a network path?
What would be an alternative solution, if this is not possible?
Thanks for the help in advanced.
Regards,
I'm not the best to reply, but I hope in my doing so, it will prompt others to reply.
If you want to watch
a network folder, I can only think of one way.
This needs a bit of work done:
1 - You will have to mount the remote directory on this machine.
On the remote machine you will have to allow remote access.
If linux/ubuntu/raspi, edit the /etc/exports
file and add a line allowing your machine access to that directory.
2 - Mount it on the main machine.
3 - point the watch
node to that path.
That should do.
Not all network drives allow watch as it typically is a low-level filing system thing.
Alternatives depend on what you are actually trying to achieve. You could keep hash tables that periodically update and then compare hashes - you will find that most file sync and some backup tools do this.
Alternatively, you could poll the destination folder periodically to look for changes in last changed timestamps.
@Trying_to_learn Thanks for your reply.
I mounted the network location and can browse it on my local node-red machine /mnt/test
But hte watch folder does not seem to work. I realized that in general the mount uses the user account as root. Therefore a /test is actually /home/usr/test so it does not know /mnt/.... Could this be it?
See my comment.
How would the poll look like?
You could use an inject node set to repeat, say once an hour, get the file or folder details and compare the changed timestamp. Update the timestamp(s) in a flow variable and then wait for the next inject.
You are probably right abut root
access required to set up the mount.
I am not getting that you are pointing to/using /mnt/test
My external mounts are usually in: /meida/pi/. . . .
I just tried it and it works as expected.
Not wanting to dismiss @TotallyInformation (Julian) but how are you mounting the drawers?
See pictures.
Thanks. I also mounted the network path in the user folder now. And it is also "working".
Weirdly just when I change/create and file in the folder from the node-red machine where the path is mounted. NOT when I create a file on the network share.
Unfortunately I can't upload more than 2 pics as I'm a new user. I created another file in the windows network share and this will not trigger the watch node.
Don't fret.
It is good that you are moving in the right direction.
I'm confused.
(I don't understand what you mean)
You can cheat with your pictures uploading.
Have the CLI open over Node-red and post a screen shot showing both the CLI and the debug
output on one picture.
The watch node just get triggered when I am change/create/delete a file on the local machine.
When I copy a file into the share on a different machine (windows) it does not get triggered:
--> no debug output.
Yeah, ok.
So it is windows. That shouldn't be a problem.
My example was on a remote machine that I modified / touched the file.
Don't confuse yourself looking at the local path.
Well, in that you don't look at the files on your local machine.
Ok, let's look at the mount.
How do you mount the remote machine?
From the CLI, what is the command you use to mount the remote?
On the remote machine, how have you got shares set up?
It's a NAS storage using CIFS to mount it.
I used following command to mount:
sudo mount -t cifs -o user=username@domain //ip-address/folder /home/usr/test
That is what I was saying, many network drives don't support watch functions, not the fault of Node-RED, the underlying filing system doesn't support it. However, clearly, when you've mounted it under Linux, the local FS does support it. On Windows though, this may or may not be the same, I've not tested it.
Ok. Good to see the command.
Alas you are getting ahead of me with it.
I haven't used the windows machine for a long time now.
But my mount command is slightly different.
I won't bother showing you. I don't think it is part of the problem.
So: after mounting
the folder, what happens if you ssh
to the remote folder and try to delete something?
Or make something.
And what path is it you watch?
What NAS are you using - most of them are running on Linux so you may be better accessing the remote folder that way rather than through CIFS
Most CIFS implementations will not provide folder change notification
You could use NFS to share the folder and then mount it locally on your PI - or just run Rsync on the NAS and push any folder changes to the PI as they happen
Craig
Thank you both for your advise.
I will try the NFS possibility next and update afterwards.
Cheers
I know that is an old thread but I just had the same issue with the watch node on a SMB but also on the NFS mounted file system. The watch node triggers when I create a file on the share from the machine node-red is running on but does not trigger when I create a file from another machine. However, it works with the node https://flows.nodered.org/node/node-red-contrib-watchdirectory with the SMB and NFS share.
Watch Directory may be usefull for your condition.
Watch directory will not work on network drives either.