Overview
Linux has the most complete and mature support in gopsutil, with nearly all features fully implemented. The library supports multiple architectures and provides extensive system monitoring capabilities.Supported Architectures
i386
32-bit Intel/AMD processors
amd64
64-bit Intel/AMD processors (most common)
arm
ARM processors including Raspberry Pi
RISC-V
Partial support - host information only
Feature Support
Fully Supported Features
Linux provides complete support for the following features:CPU Metrics
cpu.Times()- CPU time statistics (user, system, idle, etc.)cpu.Count()- Number of logical and physical CPUscpu.Percent()- CPU utilization percentagecpu.TimesPercent()- Per-CPU time percentagescpu.Info()- Detailed CPU information including:- VendorID (e.g., “GenuineIntel”)
- Family, Model, Stepping
- PhysicalID and CoreID
- ModelName (e.g., “Intel(R) Core(TM) i7-2640M CPU @ 2.80GHz”)
- CPU frequency (MHz)
- Cache size
- CPU flags
- Microcode version
Memory Metrics
mem.VirtualMemory()- Physical memory statisticsmem.SwapMemory()- Swap memory information- Platform-specific extended information via
ExLinux(see below)
Disk Metrics
disk.Partitions()- List all disk partitionsdisk.Usage()- Disk usage statistics per partitiondisk.IOCounters()- I/O statistics with device mapper label support
Network Metrics
net.IOCounters()- Network interface statisticsnet.Connections()- Active network connectionsnet.Interfaces()- Network interface informationnet.ProtoCounters()- Protocol-level statistics (IP, TCP, UDP, etc.)- Sourced from
/proc/net/snmp - Linux-only feature
- Sourced from
System Information
host.Info()- Comprehensive host information:- Hostname
- Uptime
- Number of processes
- OS (“linux”)
- Platform (e.g., “ubuntu”, “arch”, “rhel”)
- PlatformFamily (e.g., “debian”, “rhel”)
- PlatformVersion
- VirtualizationSystem (e.g., “kvm”, “docker”, “lxc”)
- VirtualizationRole (“guest” or “host”)
host.BootTime()- System boot time (Unix timestamp)host.Users()- Currently logged-in usersload.Avg()- System load averages (1, 5, 15 minutes)
Process Information
Linux has the most complete process monitoring support:- Basic: pid, ppid, name, cmdline, create_time, status, cwd, exe
- User/Group: uids, gids, username
- Resources: memory_info, memory_maps, memory_percent, cpu_times, cpu_percent
- I/O: io_counters, open_files, num_fds
- Context: terminal, nice, num_ctx_switches, rlimit
- Threads: num_threads, threads
- Relations: parent, children, connections
- Signals: send_signal, suspend, resume, terminate, kill
- Stats: page_faults
Linux-Exclusive Features
These features are only available on Linux:Docker/Container Support
Netfilter Connection Tracking
Network Protocol Statistics
Device Mapper Labels
Platform-Specific Information (ExLinux)
Linux provides extended memory information through theExLinux struct:
See the Platform-Specific Information page for more details on Ex structs.
Environment Variables
Linux support includes flexible path configuration via environment variables:| Variable | Default | Description |
|---|---|---|
HOST_PROC | /proc | Process information filesystem |
HOST_SYS | /sys | System information filesystem |
HOST_ETC | /etc | Configuration files |
HOST_VAR | /var | Variable data |
HOST_RUN | /run | Runtime data |
HOST_DEV | /dev | Device files |
HOST_ROOT | / | Root filesystem |
HOST_PROC_MOUNTINFO | /proc/N/mountinfo | Mount information |
Using Environment Variables
Using Context (v3.23.6+)
Priority order: Context values → Environment variables → Default paths
Known Limitations
Temperature Sensors
- Appropriate kernel modules loaded (e.g.,
coretemp,k10temp) - Read permissions for
/sys/class/hwmon/ - May not work in containers without proper device access
Container Environments
When running inside containers:- Some
/procmetrics may be virtualized or unavailable - Host system information may not be accessible
- Disk partition information may be limited
- Consider mounting host paths if full system monitoring is needed
RISC-V Support
RISC-V architecture support is currently limited to:- Host information via
host.Info() - Other features are not yet implemented
Performance Considerations
Boot Time Caching
Best Practices
Error Handling
Context Usage
Monitoring Multiple Metrics
Related Resources
Platform Overview
Compare Linux support with other platforms
Platform-Specific
Learn about ExLinux structs