sanity checks
This commit is contained in:
parent
399a371e7b
commit
98f2a24f8a
1 changed files with 12 additions and 0 deletions
12
exporter.go
12
exporter.go
|
@ -164,6 +164,18 @@ func mainImpl() error {
|
|||
if err != nil {
|
||||
return fmt.Errorf("sensor reading error: %v", err)
|
||||
}
|
||||
|
||||
// sanity check sensor outputs:
|
||||
// current = shunt / resistor, but resistor is fixed,
|
||||
// so if current == 0 if and only if shunt == 0
|
||||
if (p.Current == 0) != (p.Shunt == 0) {
|
||||
return fmt.Errorf("current = %v but shunt = %v", p.Current, p.Shunt)
|
||||
}
|
||||
// power = current * voltage, similar logic
|
||||
if (p.Power == 0) != (p.Current == 0 || p.Voltage == 0) {
|
||||
return fmt.Errorf("power = %v but current = %v and voltage = %v", p.Power, p.Current, p.Voltage)
|
||||
}
|
||||
|
||||
busVolts := float64(p.Voltage) / float64(physic.Volt)
|
||||
busVoltageHist.Observe(busVolts)
|
||||
busVoltageSumm.Observe(busVolts)
|
||||
|
|
Loading…
Reference in a new issue