Skip to main content
gopsutil

Welcome to gopsutil

gopsutil is a Go port of psutil, providing a cross-platform library to retrieve process and system utilization information including CPU, memory, disks, network, sensors, and processes.

Quick Start

Get started with gopsutil in minutes

API Reference

Explore the complete API documentation

Platform Support

View supported platforms and architectures

Examples

Learn with practical examples

Key Features

Cross-Platform

Works on Linux, Windows, macOS, FreeBSD, OpenBSD, and Solaris

Pure Go

Implemented without cgo, porting C structs to Go

Rich Metrics

CPU, memory, disk, network, process, and sensor information

Context Support

Full context.Context support for cancellation and timeouts

Supported Platforms

gopsutil supports a wide range of operating systems and architectures:
  • Linux: i386, amd64, arm, arm64
  • Windows: i386, amd64, arm, arm64
  • macOS: amd64 (Intel), arm64 (Apple Silicon)
  • FreeBSD: i386, amd64, arm, arm64
  • OpenBSD: i386, amd64, armv7, arm64, riscv64
  • Solaris: amd64 (SmartOS/Illumos)
Partial support is available for CPU on DragonFly BSD and host information on Linux RISC-V.

Why gopsutil?

All functionality is implemented in pure Go without requiring cgo. This means easier cross-compilation and no C toolchain dependencies.
Based on the proven psutil library with over 11,000+ GitHub stars and used in production by thousands of applications.
Regular monthly releases with Calendar Versioning (CalVer) ensuring you always get the latest platform support and bug fixes.
From basic CPU and memory stats to advanced features like Docker container monitoring and Windows services management.

Quick Example

Here’s a simple example to get you started:
package main

import (
    "fmt"
    "github.com/shirou/gopsutil/v4/mem"
)

func main() {
    v, _ := mem.VirtualMemory()

    // Almost every return value is a struct
    fmt.Printf("Total: %v, Free:%v, UsedPercent:%f%%\n", 
        v.Total, v.Free, v.UsedPercent)

    // Convert to JSON. String() is also implemented
    fmt.Println(v)
}
Output:
Total: 3179569152, Free:284233728, UsedPercent:84.508194%
{"total":3179569152,"available":492572672,"used":2895335424,"usedPercent":84.50819439828305,...}

What’s New in v4

gopsutil v4 introduces several improvements and breaking changes. See the v4 migration guide for details.
Key improvements in v4:
  • Platform-specific extended information via Ex structs
  • Enhanced error handling and consistency
  • Improved context support across all packages
  • Better caching mechanisms for performance

Next Steps

1

Install gopsutil

Follow the installation guide to add gopsutil to your project
2

Try the quickstart

Work through the quickstart guide to build your first monitoring application
3

Explore the API

Dive into the API reference to discover all available packages and functions

Build docs developers (and LLMs) love