-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Welcome to the Directory-Polling-Monitor wiki!
Self-contained Python tool (stdlib only) for polling-based directory monitoring.
Allows you to watch one or more folders, apply advanced filters, and log changes in real time—all from a simple text menu.
- Monitor multiple directories at once
- Recursive or non-recursive scanning
- Include or exclude hidden files and folders
- Advanced glob-based include/exclude filters
- Detects creation, deletion, and modification of files & directories
- Real-time logging to console and/or a log file
- Press ESC at any time during monitoring to stop and return to the menu
- No external dependencies—runs on Python 3.6+ with the standard library only
-
Clone this repository or download the script:
git clone https://github.com/bocaletto-luca/Directory-Polling-Monitor.git cd Directory-Polling-Monitor
-
Ensure you have Python 3.6 or newer installed:
python3 --version
-
(Optional) Make the script executable:
chmod +x monitor_poll.py
Run the monitor script directly:
python3 monitor_poll.py
# or, if executable:
./monitor_poll.py
You’ll be greeted by an interactive menu to configure your monitoring session.
-
Add directory
Enter an absolute or~/
path to include in the watch list. -
Remove directory
Remove a previously added path from the list. -
Show configured directories
Display all paths currently queued for monitoring. -
Polling interval
Set the time (in seconds) between directory scans. Default is 5.0s. -
Recursive scan
Toggle whether subdirectories should be included in the scan. -
Include hidden
Toggle whether files/folders starting with.
are monitored. -
Advanced filters
Enter the include/exclude submenu to add or remove glob patterns.- Include patterns: Only files/folders matching at least one pattern are monitored.
- Exclude patterns: Any file/folder matching an exclude pattern is skipped.
-
Log file path
Specify a filename to capture logs. If left empty, all events print to stdout. -
Start monitoring
Begin the polling loop. Press ESC anytime to stop and return to the main menu. -
Exit
Quit the program.
Within the “Advanced filters” option, you can:
-
Add INCLUDE pattern (e.g.
*.log
,data/**/*.csv
) - Remove INCLUDE pattern
- List current INCLUDE patterns
-
Add EXCLUDE pattern (e.g.
temp/*
,*/.git/*
) - Remove EXCLUDE pattern
- List current EXCLUDE patterns
Patterns use standard Unix glob syntax via Python’s fnmatch
module.
During an active monitoring session, the script switches the terminal to “cbreak” mode, allowing it to detect single keystrokes. Press the ESC key at any time to immediately break out of the loop and return to the configuration menu. The terminal’s original settings are restored automatically upon exit.
Each event is logged with a timestamp and severity level:
2025-07-05 22:58:53,080 INFO [<base_path>] +Added FILE: example.txt
2025-07-05 22:59:12,345 INFO [<base_path>] *Modified DIR : docs/
2025-07-05 22:59:20,123 INFO [<base_path>] -Removed FILE: old.log
-
+Added
→ created file/dir -
*Modified
→ modified timestamp changed -
-Removed
→ deleted file/dir
Distributed under the GPL License. See LICENSE for details.
Enjoy monitoring your file system with ease!