Skip to content

Commit

Permalink
add total / remining storage to HostMetrics
Browse files Browse the repository at this point in the history
  • Loading branch information
chris124567 committed Dec 12, 2024
1 parent 9307437 commit 9705b81
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
13 changes: 10 additions & 3 deletions explorer/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
3 changes: 3 additions & 0 deletions persist/sqlite/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9705b81

Please sign in to comment.