denet: a streaming process monitor
denet /de.net/ v. 1. Turkish: to monitor, to supervise, to audit. 2. to track metrics of a running process.
Denet is a streaming process monitoring tool that provides detailed metrics on running processes, including CPU, memory, I/O, and thread usage. Built with Rust, with Python bindings.
Features
-
Lightweight, cross-platform process monitoring
-
Adaptive sampling intervals that automatically adjust based on runtime
-
Memory usage tracking (RSS, VMS)
-
CPU usage monitoring with accurate multi-core support
-
I/O bytes read/written tracking
-
Thread count monitoring
-
Recursive child process tracking
-
Command-line interface with colorized output
-
Multiple output formats (JSON, JSONL, CSV)
-
In-memory sample collection for Python API
-
Analysis utilities for metrics aggregation, peak detection, and resource utilization
-
Process metadata preserved in output files (pid, command, executable path)
Requirements
- Python 3.6+ (Python 3.12 recommended for best performance)
- Rust (for development)
- pixi (for development only)
Installation
Usage
Understanding CPU Utilization
CPU usage is reported in a top-compatible format where 100% represents one fully utilized CPU core:
- 100% = one core fully utilized
- 400% = four cores fully utilized
- Child processes are tracked separately and aggregated for total resource usage
- Process trees are monitored by default, tracking all child processes spawned by the main process
This is consistent with standard tools like top and htop. For example, a process using 3 CPU cores at full capacity will show 300% CPU usage, regardless of how many cores your system has.
Command-Line Interface
# Basic monitoring with colored output
# Output as JSON (actually JSONL format with metadata on first line)
# Write output to a file
# Custom sampling interval (in milliseconds)
# Specify max sampling interval for adaptive mode
# Monitor existing process by PID
# Monitor just for 10 seconds
# Quiet mode (suppress process output)
# Monitor a CPU-intensive workload (shows aggregated metrics for all children)
# Disable child process monitoring (only track the parent process)
Python API
Basic Usage
# Create a monitor for a process
=
# Let the monitor run automatically until the process completes
# Samples are collected at the specified sampling rate in the background
# Access all collected samples after process completion
=
# Get summary statistics
=
=
# Save samples to different formats
# Default JSONL
# JSON array format
# CSV format
# JSONL files include a metadata line at the beginning with process info
# {"pid": 1234, "cmd": ["python"], "executable": "/usr/bin/python", "t0_ms": 1625184000000}
# For more controlled execution with monitoring, use execute_with_monitoring:
# Execute a command with monitoring and capture the result
, =
# Access collected metrics after execution
=
# Generate and print summary
=
=
# Save samples to a file (includes metadata line in JSONL format)
# First line contains process metadata
Adaptive Sampling
Denet uses an intelligent adaptive sampling strategy to balance detail and efficiency:
- First second: Samples at the base interval rate (fast sampling for short processes)
- 1-10 seconds: Gradually increases from base to max interval
- After 10 seconds: Uses the maximum interval rate
This approach ensures high-resolution data for short-lived processes while reducing overhead for long-running ones.
Analysis Utilities
The Python API includes utilities for analyzing metrics:
# Load metrics from a file (automatically skips metadata line)
=
# If you want to include the metadata in the results
=
# Access the executable path from metadata
= # First item is metadata when include_metadata=True
# Direct command execution with monitoring
, =
# Execute with metadata written to output file
, =
# execute_with_monitoring also accepts subprocess.run arguments:
, =
# Aggregate metrics to reduce data size
=
# Find peaks in resource usage
=
# Get comprehensive resource utilization statistics
=
# Convert between formats
=
# Save metrics with custom options
# Analyze process tree patterns
=
# Example: Analyze CPU usage from multi-process workload
# See scripts/analyze_cpu.py for detailed CPU analysis example
Development
For detailed developer documentation, including project structure, development workflow, testing, and release process, see Developer Documentation.
License
GPL-3