stop
Modern process monitoring with structured output
stop (structured top) is a process and system monitoring tool that outputs JSON, CSV, or human-readable formats. Get system metrics and process information in a format that's easy to parse, script, and automate.
Why stop?
Traditional monitoring tools output formatted text that's hard to parse:
top/htop- Interactive TUI, not script-friendlyps- Text output requires complex parsing (awk/grep/sed)iostat/vmstat- Inconsistent formats across platforms
stop provides:
- Structured output - JSON and CSV for easy parsing
- Powerful filtering - Simple syntax with AND/OR logic
- Multiple formats - JSON for scripts, CSV for analysis, human-readable for terminals
- Cross-platform - Consistent behavior across macOS and Linux
- Watch mode - Continuous monitoring with configurable intervals
Status
v0.0.1 - Phases 1-4 complete
✅ Filter, sort, limit processes (with AND/OR logic) ✅ JSON/CSV/human-readable output ✅ Advanced metrics: thread count, disk I/O, open file descriptors ✅ 52 tests passing (16 unit + 19 edge case + 17 integration) ✅ Zero clippy warnings ✅ CI/CD pipeline (GitHub Actions on Ubuntu and macOS) ✅ Tested on macOS and Linux (Fedora) ✅ Performance optimized (86% allocation reduction in watch mode)
Installation
Or from source:
Verify:
Quick Start
# Human-readable output with colors (default)
# JSON output
# CSV output
# Filter high CPU processes
# Top 10 processes by memory
# Combined: filter, sort, limit
# Watch mode (continuous monitoring)
|
Filter Syntax
Build filter expressions with field op value and combine them with and/or:
Fields:
cpu- CPU percentage (float)mem- Memory percentage (float)pid- Process ID (integer)name- Process name (case-insensitive contains)user- User name/ID (exact match)
Operators:
>,>=,<,<=- Numeric comparisons==,!=- Equality (works with all fields)and,or- Combine conditions (case-insensitive)
Precedence: and has higher precedence than or (standard boolean logic)
Simple Examples:
# High CPU processes
# Memory hogs
# System processes (low PIDs)
# Find Chrome processes
# Processes by specific user
Compound Examples:
# High CPU AND high memory
# Chrome OR Firefox processes
# High resource usage (either CPU or memory)
# System processes with high CPU
# Case-insensitive keywords (all equivalent)
# Mixed AND/OR with precedence: (cpu > 50 AND mem > 10) OR name == chrome
Features
✅ Implemented (v0.0.1)
Output Modes:
- JSON - Structured data for AI agents
- CSV - RFC 4180 compliant with proper escaping
- Human-readable - Color-coded table with system summary
Filtering:
- Simple
field op valuesyntax - Compound expressions with
and/orlogic - Fields: cpu, mem, pid, name, user
- Operators:
>,>=,<,<=,==,!= - Proper precedence (AND before OR)
- AI-friendly JSON error messages
Sorting:
- Sort by: cpu, mem, pid, name
- Default: CPU descending
Limiting:
--top-nflag to show top N processes- Default: 20 processes
Watch Mode:
- Continuous monitoring with
--watchflag - Configurable interval with
--interval(default: 2s) - NDJSON output for JSON mode (stream-friendly)
- Screen clearing for human-readable mode
- Works with all filters, sorting, and output modes
- Graceful broken pipe handling (e.g., piping to
head)
Advanced Metrics (Phase 3):
- Thread count per process
- Disk I/O (read/write bytes) per process
- Open file descriptors per process (when available)
🚧 Planned
- Per-process network metrics (sysinfo doesn't support yet)
- Windows support
- Parentheses for complex filter grouping
- Publish to crates.io
Example Output
Use Cases
Scripting & Automation:
# Kill processes using >50% CPU
| |
# Alert if memory usage >80%
if [; then
fi
# Log metrics for analysis
Monitoring & Alerting:
- Track resource usage over time
- Trigger alerts on thresholds
- Export data for analysis
- Integration with monitoring systems
Development & Debugging:
- Find resource-intensive processes
- Monitor application behavior
- Track I/O and thread usage
- Verify processes are running
Practical Examples
Monitoring Specific Applications
# Watch Chrome memory usage in real-time
# Find all Electron apps (VS Code, Slack, etc.)
|
# Monitor Docker containers
Resource Analysis
# Find memory leaks (processes with high memory, many open files)
| \
# Identify I/O-heavy processes
|
# Find multi-threaded processes
|
System Health Checks
# Quick system overview
# Export system state for analysis
# Monitor system during load test
|
# Check if specific service is running
| && \
||
Performance Debugging
# Find processes causing high CPU during investigation
# Compare disk I/O before and after optimization
|
# Monitor resource usage with CSV for spreadsheet analysis
# Analyze in Excel/Google Sheets later
Automation & Alerting
# Alert on resource spikes (monitoring script)
while ; do
CPU=
if ; then
|
fi
done
# Log top 10 processes every hour (cron job)
# Kill runaway processes automatically
| \
| \
Design Goals
- Structured Output - JSON and CSV for easy parsing and automation
- Cross-Platform - Consistent behavior across operating systems
- Fast - Minimal overhead, efficient data collection
- Simple - Easy to use, clear syntax
- Reliable - Production-ready error handling
Comparison
| Feature | top/htop | ps | stop |
|---|---|---|---|
| JSON output | ❌ | ❌ | ✅ |
| CSV output | ❌ | ❌ | ✅ |
| Filtering | Limited | Complex | Simple syntax |
| Cross-platform | ⚠️ Varies | ⚠️ Varies | ✅ Consistent |
| Structured data | ❌ TUI | ❌ Text parsing | ✅ JSON/CSV |
| Watch mode | ✅ | ❌ | ✅ |
| One-shot | ❌ | ✅ | ✅ |
Development
# Run tests (52 tests: 16 unit + 19 edge case + 17 integration)
# Check code quality
# Build release
# Install locally
Implementation Details
Architecture:
- Type-safe filter module with comprehensive validation
- Parse-time error checking (not eval-time)
- Efficient data collection with minimal overhead
- Cross-platform system metrics via sysinfo
Testing:
- 52 tests: 16 unit + 19 edge case + 17 integration
- Continuous integration on Ubuntu and macOS
- All tests passing, zero warnings
- Performance: <30ms overhead, optimized for watch mode
Known Limitations
- User field: Shows UIDs (e.g., "501", "1000") instead of usernames on both macOS and Linux - sysinfo crate limitation
- Open files: Returns
nullfor privileged processes and kernel threads (expected behavior) - Network metrics: Per-process network metrics not available - sysinfo crate limitation
- Collection time: Includes mandatory 200ms sleep for accurate CPU readings
- Windows: Not yet tested (planned)
Roadmap
See ai/PLAN.md for detailed roadmap.
Completed (v0.0.1):
- ✅ Phases 1-4: Filter, sort, watch, CSV output, advanced metrics
- ✅ Thread count, disk I/O, open file descriptors
- ✅ Comprehensive testing and optimization
Next up:
- Field testing and real-world validation
- Windows support
- Parentheses for complex filter grouping
- Publish to crates.io (after field testing)
Contributing
Early stage project. Not yet accepting contributions - focusing on core implementation first.
License
MIT
Acknowledgments
Inspired by:
- top/htop - The classic monitoring tools
- ps - Process information standard
- rg/fd/sy - Modern CLI tools with clean output