def run_inotify(): # IN_CREATE is only needed for auto_add to work masks = IN_CLOSE_WRITE | IN_DELETE | IN_MOVED_FROM | IN_MOVED_TO | IN_ISDIR | IN_CREATE wm = pyinotify.WatchManager() notifier = pyinotify.Notifier(wm, default_proc_fun=InotifyHandler()) log.info("initializing inotify monitoring") for watch_dir in args["watch_dirs"]: log.info("now monitoring: '{0}'".format(watch_dir)) wm.add_watch(watch_dir, masks, rec=True, auto_add=True) log.info("starting inotify monitoring") try: notifier.loop() except: # catch-all, log any exceptions raised and continue log_traceback(sys.exc_info(), "Exception raised in run_inotify():")
def run_oswalk(): log.info("oswalk thread: start") while True: db = sql.DatabaseConnection(args["db_host"], args["db_user"], args["db_pass"], args["db_name"], args["db_port"], "archive", ) try: for watch_dir in args["watch_dirs"]: scan_dir(db, watch_dir) except: # catch-all, log any exceptions raised and continue log_traceback(sys.exc_info(), "Exception raised in run_oswalk():") log.info("oswalk thread: sleeping") time.sleep(args["scan_interval"]*3600)