gopsutil

A Go library that ports Python's psutil, giving programs a pure-Go way to read CPU, memory, disk, network, host, sensor, and process statistics across every major OS.

Library
Go
vv4.26.9
11,932 stars
BSD 3-Clause License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
91 /100 Excellent
Development Activity 96
Maintenance 84
Community 84
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
73 /100 Good
Architecture 88
Code Quality 85
Innovation 75
Learning Curve 45

gopsutil is a Go port of the popular Python psutil library, exposing operating-system and process metrics through a consistent, idiomatic Go API. It covers CPU usage and info, virtual/swap memory, disk usage and I/O counters, network interfaces and connections, host/platform identification, temperature and battery sensors, load averages, and detailed per-process introspection (CPU time, memory maps, open files, connections, environment, and more).

Everything is implemented without cgo, reading directly from /proc, /sys, sysctl, WMI, or other native OS interfaces depending on platform, which keeps builds simple and fully static. It supports Linux, macOS (Darwin), Windows, FreeBSD, OpenBSD, Solaris, and partial support for DragonFly BSD and AIX, with build-tag-gated files per architecture so each OS gets a native, tested implementation rather than a shared lowest-common-denominator shim.

The project has been actively maintained since 2014, uses CalVer-style tagging (vMAJOR.YY.MM) with monthly releases, and is a foundational dependency for a large swath of the Go observability and infrastructure ecosystem — used inside container runtimes, metrics agents, monitoring tools, and CLI system utilities.

What You Get

  • CPU package for per-core and aggregate usage percentages, times, and static CPU info (model, cache size, MHz)
  • mem package for virtual memory and swap statistics (total, available, used, cached, dirty, and OS-specific fields)
  • disk package for partition listing, usage percentages, and low-level I/O counters (reads, writes, bytes, time)
  • net package for interface addresses, IO counters, per-protocol connection listings, and socket-level details
  • host package for OS/platform identification, uptime, boot time, users, and temperature/sensor readings
  • process package for enumerating processes and querying CPU%, memory maps, open files, connections, and environment per PID
  • context-based configuration to override /proc, /sys, /etc paths for containerized or chrooted environments
  • optional in-package caching (since v3.24.1) to avoid redundant syscalls on repeated stat calls

Common Use Cases

  • Building a metrics/monitoring agent that reports host CPU, memory, disk, and network stats to a time-series backend
  • Adding a self-hosted system dashboard or health-check endpoint to a Go service without shelling out to top/ps
  • Writing container-aware tooling that reads host stats via HOST_PROC/HOST_SYS environment overrides
  • Implementing process supervisors or resource-limit enforcers that need live per-PID CPU/memory/file-descriptor data
  • Cross-platform CLI utilities (system-info tools, resource monitors) that need to run identically on Linux, macOS, and Windows

Under The Hood

Architecture gopsutil is organized as one Go package per statistic domain — cpu, mem, disk, net, host, load, sensors, process, plus docker and winservices extras — each exposing a small set of public functions (e.g. mem.VirtualMemory(), cpu.Percent()) that delegate to per-OS files selected at compile time via Go build tags (_linux.go, _darwin.go, _windows.go, _freebsd.go, etc.), with a _fallback.go for unsupported combinations. Shared plumbing — command invocation with timeouts, endian helpers, environment-variable-based path overrides (HOST_PROC, HOST_SYS, HOST_ETC), and warning aggregation — lives in internal/common, consumed by every domain package through an Invoker interface (common.Invoke{}) that call sites can swap out in tests. This keeps the public surface uniform across platforms while letting each OS’s implementation read from its own native source (/proc and /sys on Linux, sysctl on BSD/Darwin, WMI via yusufpapurcu/wmi on Windows) with no shared abstraction leaking platform quirks into callers.

Tech Stack The module targets Go 1.24 and declares zero required dependencies for its core logic beyond small platform helpers: golang.org/x/sys for raw syscalls, github.com/yusufpapurcu/wmi and github.com/go-ole/go-ole for Windows WMI queries, github.com/ebitengine/purego for cgo-free dynamic library calls on Darwin, github.com/tklauser/go-sysconf/numcpus for sysconf-derived values, and github.com/lufia/plan9stats/github.com/power-devops/perfstat for Plan9/AIX-specific stats. github.com/stretchr/testify and github.com/google/go-cmp are dev-only test dependencies. There is no build system beyond go build/go test, plus a Makefile and mktypes.sh for regenerating platform-specific struct bindings from C headers.

Code Quality Testing uses the standard go test runner with testify assertions; the repository ships 43 _test.go files covering most domain packages per platform, including OS-specific test variants (e.g. cpu_darwin_test.go, host_aix_test.go) and a dedicated internal/common/psutiltest helper package. Code style is enforced via a repository-level .golangci.yml linter configuration run in CI (.github/workflows/lint.yml), and build_test.yml/test_freebsd.yml run compilation and tests across the full matrix of supported OS/architecture combinations, plus a dedicated SBOM-generation workflow. Struct fields carry consistent json tags and extensive godoc comments explaining platform-specific meanings (e.g. distinguishing Linux Cached from FreeBSD Laundry), and errors are returned explicitly rather than swallowed, with a shared ErrNotImplementedError/ErrTimeout pair for platform gaps and command timeouts.

What Makes It Unique gopsutil’s core technical bet is doing all of this without cgo: rather than shelling out to system utilities or linking against native C libraries, it parses /proc//sys directly on Linux, calls sysctl via purego on Darwin/BSD without cgo, and issues WMI queries on Windows — keeping consumers’ Go binaries statically linked and simple to cross-compile. Combined with its environment-variable path-override mechanism (HOST_PROC, HOST_SYS, etc.), this makes it a common building block inside containerized monitoring agents that need to observe the host from inside a container, a use case most single-OS or cgo-dependent stats libraries can’t support as cleanly.

Used by 23 apps in this directory

Go
73%
GPL 3.0

1Panel

Devops · Hosting Control Panel · Monitoring

37,137

The only open-source VPS control panel with native AI agent runtime — deploy websites, Docker stacks, and local LLMs from one web interface.

View details
91
Repo Health
76
Technical
67
Dependency
Built with
Go 73%
Vue 27%
Updated today
Go
82%
AGPL 3.0

Beta9

AI Development · Automation · Data Engineering

1,808

Run AI workloads at scale with a Pythonic serverless runtime that handles GPU inference, background jobs, and sandboxes with zero infrastructure overhead.

View details
85
Repo Health
78
Technical
66
Dependency
Built with
Go 82%
Python 17%
Updated yesterday
Go
90%
Apache 2.0

CasaOS

File Storage · Hosting Control Panel

37,294

Your simple, elegant personal cloud OS for home data and apps

View details
62
Repo Health
71
Technical
65
Dependency
Built with
Go 90%
Updated 1 weeks ago
Go
75%
AGPL 3.0

Coder

Code Editors · Developer Tools · Devops

16,920

Self-hosted cloud development environments and AI coding agents — defined in Terraform, connected via WireGuard, automatically shut down when idle.

View details
91
Repo Health
90
Technical
66
Dependency
Built with
Go 75%
TypeScript 23%
Updated today
Go
49%
Other

Cosmos-Server

Authentication · Security

6,179

All-in-one self-hosted home server with SmartShield anti-DDoS, Nebula mesh VPN, automatic HTTPS, and a 250-app marketplace — all secured behind a unified auth layer.

View details
85
Repo Health
59
Technical
64
Dependency
Built with
Go 49%
JavaScript 48%
Updated yesterday
TypeScript
98%
Other

Dokploy

Devops · Hosting Control Panel · Security

37,734

Self-hosted PaaS that deploys apps and databases on your own VPS using Docker, Traefik, and multi-build-system orchestration

View details
88
Repo Health
76
Technical
64
Dependency
Built with
TypeScript 98%
Updated 2 days ago
Go
80%
Apache 2.0

Dolt

Data Engineering · Databases · Developer Tools

24,610

The SQL database you can branch, merge, diff, and clone — Git for your data, MySQL-compatible and ready for multi-agent AI workflows.

View details
91
Repo Health
9
Technical
65
Dependency
Built with
Go 80%
Shell 19%
Updated today
TypeScript
71%
Other

highlight.io

Analytics · Developer Tools · Monitoring

9,384

Open-source full-stack monitoring that unifies session replay, error tracking, logging, and distributed tracing so you can stop context-switching between tools.

View details
71
Repo Health
78
Technical
65
Dependency
Built with
TypeScript 71%
Go 16%
Updated 1 weeks ago
Go
99%
AGPL 3.0

MinIO

File Storage

61,332

High-performance, S3-compatible object storage built for AI/ML and analytics workloads — run it anywhere from a laptop to a petabyte-scale cluster.

View details
59
Repo Health
85
Technical
65
Dependency
Built with
Go 99%
Updated 5 months ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers