How shirou/gopsutil works
gopsutil is a cross-platform Go library that exposes structured operating-system and process telemetry. The principal workflow is an application calling a domain package, which gathers and normalizes platform-specific data for return. The graph preserves the documented CPU, memory, disk, network, host, load, sensor, process, container, and Windows-service capabilities. Platform implementations are selected across the listed source files; sampled excerpts do not establish every platform-specific call path, so those links are not expanded.
Main entry points: common.go Shared helpers · disk.go Disk metrics · net.go Network metrics · host.go Host information
Components 14
System telemetry
- CPU metrics
cpu/cpu.go - Memory metrics
mem/mem.go - Disk metrics
disk/disk.go - Network metrics
net/net.go - Host information
host/host.go - Load averages
load/load.go - Hardware sensors
sensors/sensors.go
Processes and containers
- Process metrics
process/process.go - Container metrics
docker/docker.go - Windows services
winservices/winservices.go
Platform adaptation
- OS interfaces
Configuration
- Shared helpers
internal/common/common.go - Path overrides
common/env.go
Other components
- Go application
Connections 25
- Go application → CPU metrics: calls API
- Go application → Memory metrics: calls API
- Go application → Disk metrics: calls API
- Go application → Network metrics: calls API
- Go application → Host information: calls API
- Go application → Load averages: calls API
- Go application → Hardware sensors: calls API
- Go application → Process metrics: calls API
- Go application → Container metrics: calls API
- Go application → Windows services: calls API
- CPU metrics → OS interfaces: queries
- Memory metrics → OS interfaces: queries
- Disk metrics → OS interfaces: reads system data
- Network metrics → OS interfaces: reads system data
- Host information → OS interfaces: queries
- Load averages → OS interfaces: queries
- Hardware sensors → OS interfaces: reads sensor data
- Process metrics → OS interfaces: queries
- Container metrics → OS interfaces: reads cgroups
- Windows services → OS interfaces: queries services
- Host information → Shared helpers: uses helpers
- Disk metrics → Shared helpers: uses helpers
- Network metrics → Shared helpers: uses helpers
- Hardware sensors → Shared helpers: uses helpers
- Shared helpers → Path overrides: resolves overrides