psutil
Cross-platform Python library for accessing system and process information. psutil provides CPU usage, memory stats, disk I/O, network connections, and process management (list, kill, inspect) through a unified Python API that works on Linux, macOS, and Windows. Used in monitoring agents, resource-aware task schedulers, and system health checks.
Score Breakdown
⚙ Agent Friendliness
🔒 Security
Local execution only. Process inspection capabilities could leak sensitive info (command lines with passwords) — ensure agents using psutil don't log raw process command lines.
⚡ Reliability
Best When
You need simple, cross-platform system resource inspection in a Python script or agent without external monitoring infrastructure.
Avoid When
You need distributed fleet monitoring, container-aware cgroup metrics, or time-series metric collection — use proper observability infrastructure.
Use Cases
- • Build agent health checks that verify system resource availability before starting compute-intensive tasks — check CPU, memory, and disk usage
- • Monitor agent process resource consumption (CPU%, memory RSS) and implement auto-scaling or throttling based on psutil metrics
- • Enumerate running processes to detect required services (databases, queues) are up before agent workflows begin
- • Collect system telemetry for agent observability dashboards — CPU per-core, network bytes sent/received, disk read/write rates
- • Implement graceful degradation in agent pipelines by monitoring available memory and reducing batch size when resources are constrained
Not For
- • Distributed system monitoring across multiple hosts — use Prometheus node_exporter or Datadog agent for fleet monitoring; psutil is single-host only
- • Container-aware resource monitoring — psutil reads host metrics in containers, not container-scoped cgroup limits; use docker stats API for container resource usage
- • Long-term metrics storage and alerting — psutil is a point-in-time snapshot library; use Prometheus/Grafana for time-series monitoring
Interface
Authentication
No authentication — local Python library. Elevated privileges required for some operations (process memory maps, other users' processes).
Pricing
psutil is open source and free.
Agent Metadata
Known Gotchas
- ⚠ psutil.process_iter() can raise NoSuchProcess mid-iteration as processes die — always wrap in try/except NoSuchProcess when iterating
- ⚠ In Docker containers, psutil reads host system metrics (all CPUs, all memory) not container cgroup limits — cpu_count() returns host CPU count, not container CPU quota
- ⚠ CPU percent on first call always returns 0.0 — must call twice with an interval or use per_cpu=True with a sleep between calls to get meaningful readings
- ⚠ Memory info types vary by OS — 'rss' is reliable cross-platform; 'vms', 'shared', 'text' are platform-specific and may be 0 on some systems
- ⚠ Process.connections() requires elevated privileges on macOS for processes owned by other users — use try/except AccessDenied in agents running as non-root
- ⚠ Disk I/O counters (disk_io_counters) may be None on some virtual machines and container environments — always check for None before using
Alternatives
Full Evaluation Report
Detailed scoring breakdown, competitive positioning, security analysis, and improvement recommendations for psutil.
Scores are editorial opinions as of 2026-03-06.