Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix disk usage data discrepancy on Darwin #167

Open
wants to merge 1 commit into
base: aws-cwa-release-1-23-0
Choose a base branch
from

Conversation

movence
Copy link

@movence movence commented Jan 9, 2025

There is an issue in scraping disk usage on macOS systems. The problem stems from gopsutil's reliance on unix.Statfs, which is not accurately retrieving disk usage data on macOS. While unix.Statfs is generally reliable on many Unix systems, it seems to be incompatible with macOS's specific filesystem (APFS) implementation or reporting mechanisms. This leads to inaccurate disk usage metrics (where all reported mount points have same used space values), impacting macOS customers' observability to their resources.

Why df and not diskutil?
df is preferred due to its universality across unix-like systems including Darwin and consistent/simple output format. While diskutil offers more detailed macOS-specific information, its limited platform support and potential for format changes make it less suitable.

Changes:

  • remove darwin from os build target in disk_unix which contains a function to retrieve disk usage
  • implement UsageWithContext in disk_darwin using df

Tested on mac1.metal test instance: (screenshot showing all mount points reporting identical values for disk_used metric then showing correct values with this fix)

  • disk_used
Screenshot 2025-01-09 at 3 17 43 PM - disk_used_percent Screenshot 2025-01-09 at 3 37 50 PM

@movence movence requested a review from jefchien January 9, 2025 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants