Documentation
¶
Overview ¶
Package diskhistory keeps a small time series of data dir free space and per-category Docker bytes, and forecasts when the disk fills.
Index ¶
Constants ¶
const ( DefaultWindowDays = 30 DefaultMinDays = 7 )
Defaults from the storage page spec: fit the last 30 days, and stay hidden until a week of data exists so the number is never a guess.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Categories ¶
type Categories struct {
Images, Containers, Volumes, BuildCache int64
}
Categories are the per-category byte totals taken from the Docker usage cache.
type Result ¶
Result is a days-until-full estimate and how many days of data it rests on.
func Forecast ¶
Forecast fits used bytes over the last DefaultWindowDays with least squares. It returns nil when under DefaultMinDays of data exists or usage is not growing.
func ForecastWith ¶
ForecastWith is Forecast with explicit window and minimum day counts.
type Sample ¶
type Sample struct {
At time.Time `json:"at"`
FreeBytes int64 `json:"free_bytes"`
TotalBytes int64 `json:"total_bytes"`
ImagesBytes int64 `json:"images_bytes"`
ContainersBytes int64 `json:"containers_bytes"`
VolumesBytes int64 `json:"volumes_bytes"`
BuildCacheBytes int64 `json:"build_cache_bytes"`
}
Sample is one recorded moment. Category fields are 0 when Docker usage was unavailable.
type Sampler ¶
type Sampler struct {
// contains filtered or unexported fields
}
Sampler records one sample per interval, plus one at boot when the last is stale.
func NewSampler ¶
func NewSampler(store *Store, src Source, settings Settings, poll time.Duration, logger *slog.Logger) *Sampler
NewSampler builds a sampler. poll is how often it re-checks the interval and prunes.
type Settings ¶
Settings reads the live tunables on every tick so a saved change applies without a restart.
type Source ¶
type Source struct {
Stat func() (free, total int64, err error)
Usage func(ctx context.Context) (Categories, error)
}
Source supplies live readings. Usage may be nil or fail; Stat is required.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store persists samples in the control plane database.
func (*Store) Insert ¶
Insert records one sample; a repeat of the same instant replaces the earlier row.