fsmon-0.1.3 is not a library.
Visit the last successful build:
fsmon-0.3.2
đ Select Language | éæŠč¯č¨
Features
- Real-time Monitoring: Captures 8 core fanotify events (CREATE, DELETE, CLOSE_WRITE, ATTRIB, etc.)
- Process Attribution: Tracks PID, command name, and user for every file change â even short-lived processes like
touch,rm,mv - Recursive Monitoring: Watch entire directory trees with automatic tracking of newly created subdirectories
- Complete Deletion Capture: No more missing events during
rm -rfâ captures every file deleted in recursive operations - High Performance: Written in Rust, <5MB memory footprint, zero-copy event parsing
- Flexible Filtering: Filter by time, size, process, user, and event type
- Multiple Formats: Human-readable, JSON, and CSV output
- Systemd Service: Install as systemd service for long-term auditing with auto-restart
Why fsmon
Ever needed to answer "Who modified this file?" on a Linux server? That's exactly what fsmon is for.
Traditional file monitoring tools give you events without context â fsmon bridges that gap by attributing every file change to its responsible process. Whether it's a rogue script, an automated deployment, or a misconfigured service, you'll know exactly what happened, when, and who (or what) caused it.
Quick Start
Prerequisites
- OS: Linux 5.9+ (requires fanotify FID mode)
- Filesystem: ext4, XFS, tmpfs (btrfs partial support)
- Build: Rust toolchain (
cargo)
# Verify kernel version
# Install Rust if needed
|
Installation
# Build from source
# Or install from crates.io
Important: Copy to system path for sudo usage:
Basic Usage
# Monitor a directory
# Monitor with recursive watching
# Install as systemd service for long-term auditing
# Query historical events
# Check service status
Examples
Investigate Configuration Changes
# Monitor /etc for modifications
# In another terminal, make a change
|
# Query the results
Track Large File Creation
# Watch for files larger than 50MB
# Trigger
Audit Deletion Operations
# Capture complete recursive deletion
# Trigger
# Output shows every file deleted (even in subdirectories)
)
)
Command Reference
Technical Architecture
- fanotify (FID mode): Linux kernel-level file monitoring
- Proc Connector: Caches process info at
exec()time for accurate attribution - name_to_handle_at: Directory handle caching for complete deletion tracking
- Rust + Tokio: Async runtime with high concurrency
Event Types
Default captures 8 core events. Use --all-events for all 14.
Default Events (8):
| Event | Description |
|---|---|
| CLOSE_WRITE | File closed after write (best "modified" signal) |
| ATTRIB | Metadata changed (permissions, timestamps, owner) |
| CREATE | File/directory created |
| DELETE | File/directory deleted |
| DELETE_SELF | The monitored file/directory itself was deleted |
| MOVED_FROM | File moved out of monitored directory |
| MOVED_TO | File moved into monitored directory |
| MOVE_SELF | The monitored file/directory itself was moved |
Additional Events (6, via --all-events):
| Event | Description |
|---|---|
| ACCESS | File read |
| MODIFY | File content written (very noisy) |
| OPEN | File/directory opened |
| OPEN_EXEC | File opened for execution |
| CLOSE_NOWRITE | Read-only file closed |
| FS_ERROR | Filesystem error (Linux 5.16+) |