feat: Add AIX platform support to common package with uptime and boot time functions by Dylan-M · Pull Request #1979 · shirou/gopsutil

Description

This PR adds comprehensive AIX (ppc64) platform support to the gopsutil common package.

Part 1 of splitting #1969: Prerequisites

Changes

  • Labeler Configuration: Added AIX to the GitHub labeler for better issue/PR organization
  • Common Package: Implemented new common_aix.go module providing:
    • BootTimeWithContext(): Calculates system boot time
    • UptimeWithContext(): Retrieves system uptime using ps command
    • ParseUptime(): Parses ps etimes output into total minutes, handling multiple time formats
  • Host Package: Refactored host_aix.go to delegate uptime/boot time functions to common package
  • Tests: Added comprehensive unit tests in common_aix_test.go covering valid and invalid uptime parsing scenarios

Implementation Details

The AIX implementation uses ps -o etimes -p 1 to retrieve the elapsed time for PID 1, which supports the following formats:

  • DAYS-HOURS:MINUTES:SECONDS (e.g., "124-01:40:39")
  • HOURS:MINUTES:SECONDS (e.g., "15:03:02")
  • MINUTES:SECONDS (e.g., "01:02" on just-rebooted systems)

This approach is more robust than parsing the uptime command output and provides better accuracy for the AIX platform.