diff --git a/explorer/types.go b/explorer/types.go index eec17fa..2a6479c 100644 --- a/explorer/types.go +++ b/explorer/types.go @@ -357,7 +357,14 @@ func (h Host) IsV2() bool { // HostMetrics represents averages of scanned information from hosts. type HostMetrics struct { - ActiveHosts uint64 `json:"activeHosts"` - Settings rhpv2.HostSettings `json:"settings"` - PriceTable rhpv3.HostPriceTable `json:"priceTable"` + // Number of hosts that were up as of there last scan + ActiveHosts uint64 `json:"activeHosts"` + // Total storage of all active hosts, in bytes + TotalStorage uint64 `json:"totalStorage"` + // Remaining storage of all active hosts, in bytes (storage utilization is + // equal to TotalStorage - RemainingStorage) + RemainingStorage uint64 `json:"remainingStorage"` + + Settings rhpv2.HostSettings `json:"settings"` + PriceTable rhpv3.HostPriceTable `json:"priceTable"` } diff --git a/persist/sqlite/metrics.go b/persist/sqlite/metrics.go index 48074f6..698954d 100644 --- a/persist/sqlite/metrics.go +++ b/persist/sqlite/metrics.go @@ -36,6 +36,9 @@ func (s *Store) HostMetrics() (result explorer.HostMetrics, err error) { return fmt.Errorf("failed to scan host: %w", err) } + result.TotalStorage += host.Settings.TotalStorage + result.RemainingStorage += host.Settings.RemainingStorage + result.Settings.MaxDownloadBatchSize += host.Settings.MaxDownloadBatchSize result.Settings.MaxDuration += host.Settings.MaxDuration result.Settings.MaxReviseBatchSize += host.Settings.MaxReviseBatchSize