a simple process monitor
Project description
denet: a streaming process monitor
Denet is a streaming process monitoring tool that provides detailed metrics on running processes, including CPU, memory, I/O, and thread usage. Built with a Rust core and Python bindings, it follows a Rust-first development approach while providing convenient Python access.
Features
- Lightweight, cross-platform process monitoring
- Adaptive sampling intervals that automatically adjust based on runtime
- Memory usage tracking (RSS, VMS)
- CPU usage monitoring
- I/O bytes read/written tracking
- Thread count monitoring
- Recursive child process tracking
- Command-line interface with colorized output
- JSON output option for data processing
Requirements
- Python 3.6+
- Rust (for development only)
- pixi (for development only)
Installation
pip install denet # Python package
cargo install denet # Rust binary
Usage
Command-Line Interface
# Basic monitoring with colored output
denet run sleep 5
# Output as JSON
denet --json run sleep 5 > metrics.json
# Write output to a file
denet --out metrics.log run sleep 5
# Custom sampling interval (in milliseconds)
denet --interval 500 run sleep 5
# Specify max sampling interval for adaptive mode
denet --max-interval 2000 run sleep 5
# Monitor existing process by PID
denet attach 1234
# Monitor just for 10 seconds
denet --duration 10 attach 1234
Python API
import json
import denet
# Create a monitor for a process
monitor = denet.ProcessMonitor(
cmd=["python", "-c", "import time; time.sleep(10)"],
base_interval_ms=100, # Start sampling every 100ms
max_interval_ms=1000 # Sample at most every 1000ms
)
# Option 1: Run the monitor until the process completes
# This will print JSON metrics to stdout
monitor.run()
# Option 2: Sample on demand
while monitor.is_running():
# Get metrics as JSON string
metrics_json = monitor.sample_once()
if metrics_json:
metrics = json.loads(metrics_json)
print(f"CPU: {metrics['cpu_usage']}%, Memory: {metrics['mem_rss_kb']/1024:.2f} MB")
Development
Denet follows a Rust-first development approach, with Python bindings as a secondary interface.
Setting Up the Development Environment
- Clone the repository
- Install pixi if you don't have it already: Pixi Installation Guide
- Set up the development environment:
pixi install
Development Workflow
- Make changes to Rust code in
src/ - Test with Cargo:
pixi run test-rust - Build and install Python bindings:
pixi run develop - Test Python bindings:
pixi run test
Running Tests
# Run Rust tests only (primary development testing)
pixi run test-rust
# Run Python tests only (after building with "develop")
pixi run test
# Run all tests together
pixi run test-all
Helper Scripts
The project includes scripts to help with development:
# Build and install the extension in the current Python environment
./scripts/build_and_install.sh
# Run tests in CI environment
./ci/run_tests.sh
Project Structure
denet/
├── src/ # Rust source code (primary development focus)
│ ├── lib.rs # Python binding interface
│ ├── bin/ # CLI executables
│ │ └── denet.rs # Command-line interface implementation
│ └── process_monitor.rs # Core implementation with Rust tests
├── tests/ # Python binding tests
│ └── cli/ # Command-line interface tests
├── ci/ # Continuous Integration scripts
├── scripts/ # Helper scripts for development
├── Cargo.toml # Rust dependencies and configuration
└── pyproject.toml # Python build configuration
License
GPL-3
Acknowledgements
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file denet-0.1.0.tar.gz.
File metadata
- Download URL: denet-0.1.0.tar.gz
- Upload date:
- Size: 59.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e97bf8fe844f92d4fff4d9f2d46a749f3bd3592d8d05ae04ee77e5f2971b0045
|
|
| MD5 |
10afab91df908d10246aff8553725fb9
|
|
| BLAKE2b-256 |
848ac4c9228cee0183a7df0550a9d008529058e96c9aa9fa1d6efc3ae38013cf
|
File details
Details for the file denet-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: denet-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 503.2 kB
- Tags: CPython 3.12, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96b30eb2975a604877ed111b093b00033db06adc024d4f108352018175d21292
|
|
| MD5 |
10862720d7dfbf556f300ec5e9c092c3
|
|
| BLAKE2b-256 |
2c015c70c20272436ad938284cf1b1e5716e25d36033909b1b3306162de35d76
|