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
- GPU monitoring with NVIDIA NVML support (optional)
- eBPF-based profiling on Linux: off-CPU time and syscall tracking (optional)
- 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)
- eBPF features: Linux kernel 5.5+,
clangat build time,CAP_BPF+CAP_PERFMONor root at runtime
Installation
# For GPU monitoring support (requires NVIDIA drivers and CUDA)
# For eBPF profiling support (Linux only, requires clang)
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)
# Monitor a GPU workload (requires --features gpu or denet[gpu])
# Enable eBPF profiling — off-CPU time and syscall tracking (Linux only, requires root or CAP_BPF)
# 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}
# GPU monitoring example (when GPU support is available)
=
# 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
# GPU monitoring in controlled execution
# GPU metrics are automatically included in samples when available
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.
GPU Monitoring
Denet provides comprehensive GPU monitoring for NVIDIA GPUs using the NVIDIA Management Library (NVML):
Features
- GPU Utilization: Real-time GPU compute utilization percentage
- Memory Monitoring: GPU memory usage, both total and per-process when available
- Temperature Tracking: GPU temperature monitoring
- Power Consumption: GPU power usage in watts
- Multi-GPU Support: Monitor all NVIDIA GPUs in the system
- Process-Specific: Track GPU memory usage per monitored process
- Graceful Fallback: Continues working without GPU support if NVML is unavailable
Requirements
- NVIDIA GPU with driver support
- NVIDIA CUDA toolkit or driver with NVML support
- Rust compilation with
--features gpuor Python installation withpip install denet[gpu]
Usage Examples
# Create monitor with GPU support
=
# Check GPU availability
# Get GPU summary
=
# Run monitoring
# Analyze GPU usage in samples
=
=
=
=
break
Command Line GPU Output
When GPU monitoring is enabled, the command line interface automatically includes GPU information:
# Example output with GPU monitoring
| | | |
GPU Data Structure
GPU metrics are included in the JSON output:
eBPF Profiling
Denet provides optional eBPF-based profiling on Linux for deeper insight into what processes are doing when they're not running on a CPU.
Features
- Off-CPU profiling: Captures every
sched_switchevent to measure how long threads are blocked — waiting for I/O, locks, or sleep. Useful for diagnosing latency in I/O-bound workloads. - Syscall tracking: Counts syscall frequency by category (file I/O, memory, network, …) and classifies process behaviour (I/O-bound, CPU-bound, etc.).
Requirements
- Linux kernel 5.5+
clangavailable at build timeCAP_BPF+CAP_PERFMONcapabilities, or root at runtime
Build
Usage
# Monitor an I/O-bound workload
# With JSON output
# Set capabilities on the binary to avoid running as root every time
Sample JSON output
Notes on stack traces
Stack symbolication uses /proc/{pid}/maps and addr2line. For best results:
- Build monitored programs with debug symbols (
-g) - JIT-compiled languages (Python, Java, Node.js) produce limited stack information
- See
docs/offcpu.mdfor troubleshooting and architecture details
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.
GPU Support Notes
- GPU monitoring requires NVIDIA GPUs and drivers
- NVML (NVIDIA Management Library) must be available on the system
- If GPU support is compiled in but no GPUs are detected, denet continues working normally
- GPU metrics are automatically included when available, no configuration needed
- Process-specific GPU memory tracking may not be available on all driver versions
License
GPL-3