Expand UPS telemetry, charts and raw diagnostics with power estimates
This commit is contained in:
29
history.go
29
history.go
@@ -28,6 +28,31 @@ func runHistoryCollector(collect func() (dashboardMetrics, error), store *Store)
|
||||
|
||||
func (s *Store) AddEntityMetrics(metrics dashboardMetrics) {
|
||||
ts := time.Now().Unix()
|
||||
u := metrics.UPS
|
||||
usable := func(v *float64) *float64 {
|
||||
if !u.Available || !u.CommunicationOK {
|
||||
return nil
|
||||
}
|
||||
return v
|
||||
}
|
||||
for _, item := range []struct {
|
||||
kind, name string
|
||||
value *float64
|
||||
}{
|
||||
{"ups-voltage", "Вход", u.InputVoltage}, {"ups-voltage", "Выход", u.OutputVoltage},
|
||||
{"ups-battery", "Батарея", u.BatteryVoltage}, {"ups-runtime", "Автономность", u.RuntimeSeconds},
|
||||
{"ups-frequency", "Частота", u.InputFrequency},
|
||||
} {
|
||||
s.AddEntityHistory(item.kind, item.name, ts, usable(item.value), nil)
|
||||
}
|
||||
var measured, estimated *float64
|
||||
if u.PowerEstimated {
|
||||
estimated = u.Power
|
||||
} else {
|
||||
measured = u.Power
|
||||
}
|
||||
s.AddEntityHistory("ups-power", "Измеренная", ts, usable(measured), nil)
|
||||
s.AddEntityHistory("ups-power", "Расчётная ≈", ts, usable(estimated), nil)
|
||||
for _, p := range metrics.ZFS.Pools {
|
||||
v := p.CapacityPercent
|
||||
s.AddEntityHistory("zfs", p.Name, ts, &v, nil)
|
||||
@@ -99,6 +124,10 @@ func historyPointFromMetrics(metrics dashboardMetrics) HistoryPoint {
|
||||
NetworkTransmit: metrics.Network.TransmitPerSec, UPSCharge: metrics.UPS.ChargePercent,
|
||||
UPSLoad: metrics.UPS.LoadPercent,
|
||||
}
|
||||
if !metrics.UPS.Available || !metrics.UPS.CommunicationOK {
|
||||
point.UPSCharge = nil
|
||||
point.UPSLoad = nil
|
||||
}
|
||||
if temperature := cpuTemperature(metrics.CPU.Temperatures); temperature != nil {
|
||||
point.CPUTemperature = *temperature
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user