Directory monitoring

howto

(Hz2102) #1

I am new to St2 and wondering if there is any pack available to monitor directory/folder.

I have found a pack GitHub - userlocalhost/st2-pack-example: An example for creating a original pack
but seems like it is not compatible with the recent version.

So if you know anything which can be useful to monitor directory activity please let me know.

Regards,
hz2102


(Eugen C.) #2

So you need a Sensor which will monitor a dir for changes.

You can create a st2 pack and write a sensor yourself using some external python lib (https://stackoverflow.com/questions/4708511/how-to-watch-a-directory-for-changes) which will monitor local dir. Here is the info how to write own st2 Sensor: Sensors and Triggers — StackStorm 2.8.1 documentation

Additionally, you can fix incompatibilities in GitHub - userlocalhost/st2-pack-example: An example for creating a original pack, which should be easy to do considering that we haven’t done some big breaking changes. Usually it’s some schema fixes.

Let us know what errors are you getting exactly with the beforementioned pack.


(Hz2102) #3

Thanks :slight_smile:

So as there is no pack available for now, i’ll try to make one as you suggested. And also try to fix the incompatibilities of this one. GitHub - userlocalhost/st2-pack-example: An example for creating a original pack

Regards,
hz2102


(Tomaz Muraus) #4

We do have an existing sensor for monitoring files for changes (st2/file_watch_sensor.py at master · StackStorm/st2 · GitHub), but I’m not 100% sure it also works on directories.


(Eugen C.) #5

Yes, I believe linux.FileWatchSensor is only for tailing files, but still might be a good example to write a custom Sensor.


(Hz2102) #6

Thanks, Kami and armab for your comments.
Yes, I have tried linux.FileWatchSensor at first, but it is only for files (can trace file changes) as you mentioned.

I think I should close this one.

Thanks again for your comments :slight_smile:

Regards,
hz2102