# shirou/gopsutil architecture

> Architecture diagram of the GitHub repository shirou/gopsutil, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shirou/gopsutil
- Repository: https://github.com/shirou/gopsutil

## Overview

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: [`internal/common/common.go`](https://github.com/shirou/gopsutil/blob/master/internal/common/common.go) (Shared helpers), [`disk/disk.go`](https://github.com/shirou/gopsutil/blob/master/disk/disk.go) (Disk metrics), [`net/net.go`](https://github.com/shirou/gopsutil/blob/master/net/net.go) (Network metrics), [`host/host.go`](https://github.com/shirou/gopsutil/blob/master/host/host.go) (Host information)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_telemetry["System telemetry"]
  node_cpu["CPU metrics<br/>[cpu.go]"]
  node_memory["Memory metrics<br/>[mem.go]"]
  node_disk["Disk metrics<br/>[disk.go]"]
  node_network["Network metrics<br/>[net.go]"]
  node_host["Host information<br/>[host.go]"]
  node_load["Load averages<br/>[load.go]"]
  node_sensors["Hardware sensors<br/>[sensors.go]"]
end

subgraph group_process["Processes and containers"]
  node_processes["Process metrics<br/>[process.go]"]
  node_docker["Container metrics<br/>[docker.go]"]
  node_services["Windows services<br/>[winservices.go]"]
end

subgraph group_platform["Platform adaptation"]
  node_system["OS interfaces"]
end

subgraph group_settings["Configuration"]
  node_common["Shared helpers<br/>[common.go]"]
  node_env["Path overrides<br/>[env.go]"]
end

node_app(("Go application"))

node_app -->|"calls API"| node_cpu
node_app -->|"calls API"| node_memory
node_app -->|"calls API"| node_disk
node_app -->|"calls API"| node_network
node_app -->|"calls API"| node_host
node_app -->|"calls API"| node_load
node_app -->|"calls API"| node_sensors
node_app -->|"calls API"| node_processes
node_app -->|"calls API"| node_docker
node_app -->|"calls API"| node_services
node_cpu -->|"queries"| node_system
node_memory -->|"queries"| node_system
node_disk -->|"reads system data"| node_system
node_network -->|"reads system data"| node_system
node_host -->|"queries"| node_system
node_load -->|"queries"| node_system
node_sensors -->|"reads sensor data"| node_system
node_processes -->|"queries"| node_system
node_docker -->|"reads cgroups"| node_system
node_services -->|"queries services"| node_system
node_host -->|"uses helpers"| node_common
node_disk -->|"uses helpers"| node_common
node_network -->|"uses helpers"| node_common
node_sensors -->|"uses helpers"| node_common
node_common -->|"resolves overrides"| node_env

click node_cpu "https://github.com/shirou/gopsutil/blob/master/cpu/cpu.go"
click node_memory "https://github.com/shirou/gopsutil/blob/master/mem/mem.go"
click node_disk "https://github.com/shirou/gopsutil/blob/master/disk/disk.go"
click node_network "https://github.com/shirou/gopsutil/blob/master/net/net.go"
click node_host "https://github.com/shirou/gopsutil/blob/master/host/host.go"
click node_load "https://github.com/shirou/gopsutil/blob/master/load/load.go"
click node_sensors "https://github.com/shirou/gopsutil/blob/master/sensors/sensors.go"
click node_processes "https://github.com/shirou/gopsutil/blob/master/process/process.go"
click node_docker "https://github.com/shirou/gopsutil/blob/master/docker/docker.go"
click node_services "https://github.com/shirou/gopsutil/blob/master/winservices/winservices.go"
click node_common "https://github.com/shirou/gopsutil/blob/master/internal/common/common.go"
click node_env "https://github.com/shirou/gopsutil/blob/master/common/env.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cpu,node_memory,node_disk,node_network,node_host,node_load,node_sensors toneBlue
class node_processes,node_docker,node_services toneAmber
class node_system toneMint
class node_common,node_env toneRose
class node_app toneIndigo
```

## Components

### System telemetry

- [CPU metrics](https://github.com/shirou/gopsutil/blob/master/cpu/cpu.go): `cpu/cpu.go`
- [Memory metrics](https://github.com/shirou/gopsutil/blob/master/mem/mem.go): `mem/mem.go`
- [Disk metrics](https://github.com/shirou/gopsutil/blob/master/disk/disk.go): `disk/disk.go`
- [Network metrics](https://github.com/shirou/gopsutil/blob/master/net/net.go): `net/net.go`
- [Host information](https://github.com/shirou/gopsutil/blob/master/host/host.go): `host/host.go`
- [Load averages](https://github.com/shirou/gopsutil/blob/master/load/load.go): `load/load.go`
- [Hardware sensors](https://github.com/shirou/gopsutil/blob/master/sensors/sensors.go): `sensors/sensors.go`

### Processes and containers

- [Process metrics](https://github.com/shirou/gopsutil/blob/master/process/process.go): `process/process.go`
- [Container metrics](https://github.com/shirou/gopsutil/blob/master/docker/docker.go): `docker/docker.go`
- [Windows services](https://github.com/shirou/gopsutil/blob/master/winservices/winservices.go): `winservices/winservices.go`

### Platform adaptation

- **OS interfaces**

### Configuration

- [Shared helpers](https://github.com/shirou/gopsutil/blob/master/internal/common/common.go): `internal/common/common.go`
- [Path overrides](https://github.com/shirou/gopsutil/blob/master/common/env.go): `common/env.go`

### Other components

- **Go application**

## Connections

- 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
