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.gomodule providing:BootTimeWithContext(): Calculates system boot timeUptimeWithContext(): Retrieves system uptime using ps commandParseUptime(): Parses ps etimes output into total minutes, handling multiple time formats
- Host Package: Refactored
host_aix.goto delegate uptime/boot time functions to common package - Tests: Added comprehensive unit tests in
common_aix_test.gocovering 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.