开发者

Python, how to setup hooks for tracing I/O Events

开发者 https://www.devze.com 2023-01-26 18:05 出处:网络
My app downloads fil开发者_高级运维es, creates files as final/intermediate data. I would like to setup a hook (outside the app), to alert/log whenever my app does any I/O events - like writing a file,

My app downloads fil开发者_高级运维es, creates files as final/intermediate data. I would like to setup a hook (outside the app), to alert/log whenever my app does any I/O events - like writing a file, deleting a file, downloading a file from the file server. I use the urllib to retrieve fits files from the data servers.


If you know where the file will be downloaded to, one solution could be to use inotify. In particular, pyinotify seems interesting. I don't know if CentOS has a recent enough version of the Linux kernel for this to work though.


If you want a list of your process file operations, you can use FileMon or ProcMon from SysInternals.

Edit: for Linux, you can use strace.

0

精彩评论

暂无评论...
验证码 换一张
取 消