Page 1 of 1

USB connection events?

PostPosted: Thu Mar 21, 2019 9:49 pm
by jburts
I have need to be able to run webservice programs that can trap and respond to events when a USB thumb drive is connected to USB ports. This could either be an app running in the ADM directly, or it could be in a separate VM on the appliance.

We have looked at QNAP devices and Synology, but neither seem to allow us to receive the USB connection events to automatically take steps when a thumb drive is connected. Is this something that we can accomplish with Asustor units?

Thank you.

--James--

Re: USB connection events?

PostPosted: Thu Mar 21, 2019 10:31 pm
by father.mande
Hi,
jburts wrote:I have need to be able to run webservice programs that can trap and respond to events when a USB thumb drive is connected to USB ports. This could either be an app running in the ADM directly, or it could be in a separate VM on the appliance.
We have looked at QNAP devices and Synology, but neither seem to allow us to receive the USB connection events to automatically take steps when a thumb drive is connected. Is this something that we can accomplish with Asustor units?
Thank you.
--James--


In "presales" sub-forum we have normally to answer only for Asustor ... but in fact it's also possible on some other brand ...

In Asustor, when an USB is connected to the NAS ... a new device is created and if file system in partition are supported ... a share folder is created
... so a simple solution (to be open to all your approach) is to use some tools like inotify (include in kernel) to receive an event on the creation of new device or new share
... ... inotify can launch automatically a shell on file or folder event (or have a shell looping to wait for) ... and all is file in Linux
... ... inotify tools can be added (if not delivered by Asustor, I have not verified) using APKG Entware ... you can use iontifywatch ; inotifywait or better incron a cron based on file / folder event and NOT on time events
... ... with icron you can survey event in multiple folder and launch corresponding shell when event occurs

Others solution, even more technical, can be used ... but this is ease of use, ease of management, ease of build ...

In Qnap you can do the same ... even the device tree is more complex, due to another device structure for external device ... but similar solution can be run when you have understand the specific Q approach.

N.B. this response is based on the minimal information you provide ... so can be adapted to your own project.
in Virtualbox ... if USB is directly attached to the VM you must do the same in the VM O.S. (so same for any Linux) ... if USB is first view by Asustor NAS ... the response is correct, even you must have to pass the event to the V.M. (possible but another subject) ... require a full scheme of your software or appliance architecture ...

Philippe.