Skip to main content

Overview

gopsutil provides strong support for BSD-family operating systems and Solaris. Each BSD variant has different levels of support based on community contributions and system-specific APIs.

Supported Platforms

FreeBSD

Comprehensive support for i386, amd64, and arm architectures

OpenBSD

Wide architecture support including i386, amd64, armv7, arm64, and riscv64

Solaris

Support for amd64 on SmartOS/Illumos

DragonFly BSD

Limited support - CPU monitoring only

FreeBSD

Supported Architectures

  • i386: 32-bit Intel/AMD
  • amd64: 64-bit Intel/AMD
  • arm: ARM processors

Feature Support

Fully Supported

  • CPU: Times, count, percent, times_percent, info (detailed)
  • Memory: Virtual memory, swap memory
  • Disk: Partitions, usage, I/O counters
  • Network: I/O counters
  • System: Boot time, users, PIDs, PID exists, connections
  • Load: Load averages (1, 5, 15 minutes)

Process Information

  • Basic: pid, ppid, name, cmdline, status, cwd, exe
  • User/Group: uids, gids, username
  • Resources: memory_info, num_threads
  • Priority: nice
  • Relations: children
  • Control: send_signal, suspend, resume, terminate, kill

Not Supported

  • Temperature sensors
  • Network protocols
  • Process: create_time, terminal, io_counters, num_fds, cpu_times, open_files, threads, cpu_percent, memory_percent, parent, connections

Code Example

package main

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

func main() {
    // CPU info (fully supported on FreeBSD)
    info, _ := cpu.Info()
    fmt.Printf("CPU: %s\n", info[0].ModelName)
    
    // Load average
    avg, _ := load.Avg()
    fmt.Printf("Load: %.2f %.2f %.2f\n", avg.Load1, avg.Load5, avg.Load15)
    
    // Memory
    vmem, _ := mem.VirtualMemory()
    fmt.Printf("Memory: %.2f%% used\n", vmem.UsedPercent)
    
    // Swap
    swap, _ := mem.SwapMemory()
    fmt.Printf("Swap: %.2f%% used\n", swap.UsedPercent)
}

OpenBSD

Supported Architectures

  • i386: 32-bit Intel/AMD
  • amd64: 64-bit Intel/AMD
  • armv7: 32-bit ARM v7
  • arm64: 64-bit ARM
  • riscv64: 64-bit RISC-V
OpenBSD support was contributed by @mpfz0r. The wide architecture support, including riscv64, makes OpenBSD one of the most portable platforms for gopsutil.

Feature Support

Fully Supported

  • CPU: Times, count, percent, times_percent, info
  • Memory: Virtual memory, swap memory
  • Disk: Partitions, usage, I/O counters
  • Network: I/O counters
  • System: Boot time, users, PIDs, PID exists, connections
  • Load: Load averages

Process Information

  • Basic: pid, ppid, name, cmdline, status, cwd, exe
  • User/Group: uids, gids, username
  • Resources: memory_info, num_threads, cpu_percent
  • Priority: nice
  • Relations: parent, children, connections
  • Control: send_signal, suspend, resume, terminate, kill

Not Supported

  • Temperature sensors
  • Network protocols
  • Process: create_time, terminal, io_counters, num_fds, cpu_times, open_files, memory_percent, threads

Code Example

package main

import (
    "fmt"
    "github.com/shirou/gopsutil/v4/host"
    "github.com/shirou/gopsutil/v4/process"
    "runtime"
)

func main() {
    if runtime.GOOS != "openbsd" {
        return
    }
    
    // Host information
    info, _ := host.Info()
    fmt.Printf("Platform: %s %s\n", info.Platform, info.PlatformVersion)
    fmt.Printf("Architecture: %s\n", info.KernelArch)
    
    // Process monitoring works well on OpenBSD
    processes, _ := process.Processes()
    for _, p := range processes {
        name, _ := p.Name()
        cpuPercent, _ := p.CPUPercent()
        if cpuPercent > 5.0 {
            fmt.Printf("PID %d: %s (%.2f%% CPU)\n", p.Pid, name, cpuPercent)
        }
    }
}

Solaris

Supported Architecture

  • amd64: 64-bit Intel/AMD
Solaris support was developed and tested on SmartOS/Illumos. Thanks to @jen20 for the implementation!

Feature Support

Fully Supported

  • Network: I/O counters
  • Load: Load averages
  • Host: Hostname, platform, platform family
  • Sensors: Temperature sensors

Partially Supported

  • Memory: Virtual memory (marked as ‘b’ - almost works with some issues)

Not Supported

  • CPU: times, count, percent, times_percent
  • Memory: swap_memory
  • Disk: partitions, usage, I/O counters
  • System: boot_time, users, PIDs, connections
  • Network: protocols
  • All process information
Solaris support is limited compared to other platforms. It’s primarily useful for network monitoring and basic host information.

Code Example

package main

import (
    "fmt"
    "github.com/shirou/gopsutil/v4/host"
    "github.com/shirou/gopsutil/v4/load"
    "github.com/shirou/gopsutil/v4/net"
    "github.com/shirou/gopsutil/v4/sensors"
    "runtime"
)

func main() {
    if runtime.GOOS != "solaris" {
        return
    }
    
    // Host info
    info, _ := host.Info()
    fmt.Printf("%s on %s\n", info.Platform, info.PlatformFamily)
    
    // Network I/O (well supported)
    counters, _ := net.IOCounters(true)
    for _, counter := range counters {
        fmt.Printf("%s: %d bytes in, %d bytes out\n",
            counter.Name, counter.BytesRecv, counter.BytesSent)
    }
    
    // Load average
    avg, _ := load.Avg()
    fmt.Printf("Load: %.2f %.2f %.2f\n", avg.Load1, avg.Load5, avg.Load15)
    
    // Temperature sensors
    temps, _ := sensors.TemperaturesWithContext(ctx)
    for _, temp := range temps {
        fmt.Printf("%s: %.1f°C\n", temp.SensorKey, temp.Temperature)
    }
}

DragonFly BSD

Limited Support

DragonFly BSD support is very limited, with only CPU monitoring currently available.
Supported: CPU monitoring only (thanks to @gballet!) Not supported: All other features

Code Example

package main

import (
    "fmt"
    "github.com/shirou/gopsutil/v4/cpu"
    "runtime"
    "time"
)

func main() {
    if runtime.GOOS != "dragonfly" {
        return
    }
    
    // CPU monitoring is the only supported feature
    percent, err := cpu.Percent(time.Second, false)
    if err != nil {
        fmt.Printf("Error: %v\n", err)
        return
    }
    
    fmt.Printf("CPU Usage: %.2f%%\n", percent[0])
}

Host Information Details

BSD systems provide rich host information through host.Info():

FreeBSD Example

import "github.com/shirou/gopsutil/v4/host"

info, _ := host.Info()
// info.OS = "freebsd"
// info.Platform = "freebsd"
// info.PlatformFamily = "freebsd"
// info.PlatformVersion = "13.2-RELEASE"
// info.KernelVersion = "13.2-RELEASE"
// info.KernelArch = "amd64"

OpenBSD Example

info, _ := host.Info()
// info.OS = "openbsd"
// info.Platform = "openbsd"
// info.PlatformFamily = "openbsd"
// info.PlatformVersion = "7.4"
// info.KernelArch = "amd64" or "arm64" or "riscv64"

Solaris/Illumos Example

info, _ := host.Info()
// info.OS = "solaris"
// info.Platform = "SmartOS" or "Illumos"
// info.PlatformFamily = "solaris"

BSD-Specific Considerations

sysctl Interface

BSD systems use sysctl extensively for system information:
// gopsutil handles sysctl calls internally
// Example: Getting CPU info uses kern.cp_time, kern.clockrate, etc.
info, _ := cpu.Info()

kvm Interface

Some BSD features may require the kvm (kernel virtual memory) interface:
  • Process information uses kvm_getprocs
  • May require elevated privileges
  • Performance can vary

File Descriptor Limits

import "github.com/shirou/gopsutil/v4/process"

p, _ := process.NewProcess(pid)
// num_fds not supported on FreeBSD/OpenBSD
// Use system tools like fstat instead

Security Levels

BSD security levels may restrict certain operations:
// Some process operations may fail at higher security levels
p, err := process.NewProcess(pid)
if err != nil {
    log.Printf("Access denied (securelevel?): %v", err)
}

Performance Considerations

FreeBSD

  • CPU and memory monitoring are efficient
  • Network statistics are updated frequently
  • Process monitoring can be intensive with many processes

OpenBSD

  • Generally efficient across all supported features
  • RISC-V performance depends on hardware
  • Security features may add overhead

Solaris

  • Network monitoring is performant
  • Limited feature set reduces overhead
  • Virtual memory queries may be slow

Best Practices

Check Platform Support

import "runtime"

switch runtime.GOOS {
case "freebsd":
    // Use FreeBSD features
    avg, _ := load.Avg()
case "openbsd":
    // OpenBSD-specific code
    processes, _ := process.Processes()
case "solaris":
    // Limited to network and host info
    counters, _ := net.IOCounters(true)
case "dragonfly":
    // CPU monitoring only
    percent, _ := cpu.Percent(time.Second, false)
default:
    log.Printf("Unsupported OS: %s", runtime.GOOS)
}

Handle Unsupported Features

import "errors"

func getProcessIOCounters(p *process.Process) error {
    if runtime.GOOS == "freebsd" || runtime.GOOS == "openbsd" {
        return errors.New("io_counters not supported on BSD")
    }
    _, err := p.IOCounters()
    return err
}

Use Feature Detection

func hasLoadAverage() bool {
    switch runtime.GOOS {
    case "freebsd", "openbsd":
        return true
    case "solaris":
        return true
    default:
        return false
    }
}

Contributing BSD Support

BSD support relies heavily on community contributions. If you use gopsutil on a BSD system, consider contributing improvements!

Areas for Improvement

  • DragonFly BSD: Memory, disk, and network support
  • Solaris: CPU and process information
  • FreeBSD: Process I/O counters and file descriptors
  • All platforms: Temperature sensor support (except Solaris)

How to Contribute

  1. Fork the repository
  2. Implement missing features for your BSD platform
  3. Test thoroughly on your target OS/architecture
  4. Submit a pull request
See the gopsutil GitHub repository for more information on contributing.

Platform Overview

Compare BSD support with other platforms

Cross-Platform Development

Learn how to write cross-platform code

Build docs developers (and LLMs) love