I facing the issue where there are too many file being written, modifed and sometime removed on the system I was able to log the files and path changed and sort of event logged on them using Python Watchdog llibrary However, I was unable to catch the process that performed the event
what watchdog offers for an even is event.is_directory and event.src_path only.
def on_deleted(self, event):
if event.is_directory:
print(f"[Directory deleted] Path: {event.src_path}")
else:
print(f"[File deleted] Path: {event.src_path}")
process_event(event, 'remove')
What I am looking for is something like this
def on_deleted(self, event):
if event.is_directory:
print(f"[Directory deleted] Path: {event.src_path}")
else:
print(f"[File deleted] Path: {event.src_path}")
print(f'The pid of process performing removal is: {event.pid}')
process_event(event, 'remove')
I have tried multiple stuff with watchdog, loggeddfs, inotify and pyinotify but it seems non support this and some were very hard to treat due lack of docs and resources