feat: add directory-level disk usage stats
- Dominant language
- Go
- Stars
- 12
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
## Summary
Currently, `clistat` only supports disk usage at the block device/filesystem level via `syscall.Statfs`. This reports total filesystem usage, which isn't ideal in Docker containers where multiple directories share the same underlying filesystem but you want to track usage of specific directories (e.g., `/home` or `/var/lib/docker`).
## Problem
In containerized environments:
- The current `Disk()` function shows the entire host filesystem usage
- Users need visibility into actual disk usage of specific directories within the container
- This is particularly important for Docker-in-Docker setups where `/home` and `/var/lib/docker` need separate tracking
## Proposed Solution
Add a new function (e.g., `DiskUsage` or `DirectoryUsage`) that calculates the actual disk usage of a directory tree, similar to `du -sh`.
Considerations:
- Performance: `du`-style operations can be expensive for large directory trees with many small files (e.g., node_modules). May need to consider:
- Caching strategies
- Configurable depth limits
- Recommended refresh intervals (current workaround uses 1h intervals)
- Should complement, not replace, the existing `Disk()` function which is still useful for filesystem-level stats
## Use Case
This would enable accurate disk usage monitoring in agent metadata for containerized workspaces, showing real directory usage instead of host filesystem totals.
---
Created on behalf of @matifali
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.