Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update ambient temperature calculation for power dashboard #2259

Merged
merged 2 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/collectors/rest/plugins/sensor/sensor.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func New(p *plugin.AbstractPlugin) plugin.Plugin {
return &Sensor{AbstractPlugin: p}
}

var ambientRegex = regexp.MustCompile(`^(Ambient Temp|Ambient Temp \d|PSU\d AmbTemp|PSU\d Inlet|PSU\d Inlet Temp|In Flow Temp|Front Temp|System Inlet|Bat Ambient \d|Riser Inlet Temp)$`)
var ambientRegex = regexp.MustCompile(`^(Ambient Temp|Ambient Temp \d|PSU\d AmbTemp|PSU\d Inlet|PSU\d Inlet Temp|In Flow Temp|Front Temp|Bat_Ambient \d|Riser Inlet Temp)$`)
var powerInRegex = regexp.MustCompile(`^PSU\d (InPwr Monitor|InPower|PIN|Power In)$`)
var voltageRegex = regexp.MustCompile(`^PSU\d (\d+V|InVoltage|VIN|AC In Volt)$`)
var currentRegex = regexp.MustCompile(`^PSU\d (\d+V Curr|Curr|InCurrent|Curr IIN|AC In Curr)$`)
Expand Down
2 changes: 1 addition & 1 deletion cmd/collectors/zapi/plugins/sensor/sensor.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func New(p *plugin.AbstractPlugin) plugin.Plugin {
return &Sensor{AbstractPlugin: p}
}

var ambientRegex = regexp.MustCompile(`^(Ambient Temp|Ambient Temp \d|PSU\d AmbTemp|PSU\d Inlet|PSU\d Inlet Temp|In Flow Temp|Front Temp|System Inlet|Bat Ambient \d|Riser Inlet Temp)$`)
var ambientRegex = regexp.MustCompile(`^(Ambient Temp|Ambient Temp \d|PSU\d AmbTemp|PSU\d Inlet|PSU\d Inlet Temp|In Flow Temp|Front Temp|Bat_Ambient \d|Riser Inlet Temp)$`)
var powerInRegex = regexp.MustCompile(`^PSU\d (InPwr Monitor|InPower|PIN|Power In)$`)
var voltageRegex = regexp.MustCompile(`^PSU\d (\d+V|InVoltage|VIN|AC In Volt)$`)
var currentRegex = regexp.MustCompile(`^PSU\d (\d+V Curr|Curr|InCurrent|Curr IIN|AC In Curr)$`)
Expand Down
43 changes: 22 additions & 21 deletions cmd/collectors/zapi/plugins/sensor/sensor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,28 +89,29 @@ func init() {
// Verified temperature sensor values by parsing, pivoting, etc. externally via dasel, jq, miller

// average_ambient_temperature is
// cat cmd/collectors/zapi/plugins/sensor/testdata/sensor.xml | dasel -r xml -w json | jq -r '.root."attributes-list"."environment-sensors-info"[] | select(."sensor-type" | test("thermal")) | {node: (."node-name"), name: (."sensor-name"), value: (."threshold-sensor-value")} | [.node, .name, .value] | @csv' | rg "Ambient Temp|Ambient Temp \d|PSU\d AmbTemp|PSU\d Inlet|PSU\d Inlet Temp|In Flow Temp|Front Temp|System Inlet|Bat Ambient \d|Riser Inlet Temp" | rg -v "Fake" | mlr --csv --implicit-csv-header label node,name,value then stats1 -a min,mean,max -f value -g node | mlr --csv --opprint --barred cat

// +------------+-----------+--------------------+-----------+
// | node | value_min | value_mean | value_max |
// +------------+-----------+--------------------+-----------+
// | cdot-k3-05 | 21 | 21.666666666666668 | 23 |
// | cdot-k3-06 | 21 | 22 | 24 |
// | cdot-k3-07 | 21 | 21.666666666666668 | 23 |
// | cdot-k3-08 | 21 | 22.333333333333332 | 24 |
// +------------+-----------+--------------------+-----------+
// cat cmd/collectors/zapi/plugins/sensor/testdata/sensor.xml | dasel -r xml -w json | jq -r '.root."attributes-list"."environment-sensors-info"[] | select(."sensor-type" | test("thermal")) | {node: (."node-name"), name: (."sensor-name"), value: (."threshold-sensor-value")} | [.node, .name, .value] | @csv' | rg "Ambient Temp|Ambient Temp \d|PSU\d AmbTemp|PSU\d Inlet|PSU\d Inlet Temp|In Flow Temp|Front Temp|Bat Ambient \d|Riser Inlet Temp" | rg -v "Fake" | mlr --csv --implicit-csv-header label node,name,value then stats1 -a min,mean,max -f value -g node | mlr --csv --opprint --barred cat

//+------------+-----------+------------+-----------+
//| node | value_min | value_mean | value_max |
//+------------+-----------+------------+-----------+
//| cdot-k3-05 | 21 | 22 | 23 |
//| cdot-k3-06 | 21 | 22.5 | 24 |
//| cdot-k3-07 | 21 | 22 | 23 |
//| cdot-k3-08 | 21 | 22.5 | 24 |
//+------------+-----------+------------+-----------+

//
// average_temperature [min, avg, max] is calculated like so
// cat cmd/collectors/zapi/plugins/sensor/testdata/sensor.xml | dasel -r xml -w json | jq -r '.root."attributes-list"."environment-sensors-info"[] | select(."sensor-type" | test("thermal")) | {node: (."node-name"), name: (."sensor-name"), value: (."threshold-sensor-value")} | [.node, .name, .value] | @csv' | rg -v "Ambient Temp|Ambient Temp \d|PSU\d AmbTemp|PSU\d Inlet|PSU\d Inlet Temp|In Flow Temp|Front Temp|System Inlet|Bat Ambient \d|Riser Inlet Temp" | rg -v "Fake" | mlr --csv --implicit-csv-header label node,name,value then stats1 -a min,mean,max -f value -g node | mlr --csv --opprint --barred cat
// cat cmd/collectors/zapi/plugins/sensor/testdata/sensor.xml | dasel -r xml -w json | jq -r '.root."attributes-list"."environment-sensors-info"[] | select(."sensor-type" | test("thermal")) | {node: (."node-name"), name: (."sensor-name"), value: (."threshold-sensor-value")} | [.node, .name, .value] | @csv' | rg -v "Ambient Temp|Ambient Temp \d|PSU\d AmbTemp|PSU\d Inlet|PSU\d Inlet Temp|In Flow Temp|Front Temp|Bat Ambient \d|Riser Inlet Temp" | rg -v "Fake" | mlr --csv --implicit-csv-header label node,name,value then stats1 -a min,mean,max -f value -g node | mlr --csv --opprint --barred cat

// +------------+-----------+------------+-----------+
// | node | value_min | value_mean | value_max |
// +------------+-----------+------------+-----------+
// | cdot-k3-05 | 19 | 27.1875 | 36 |
// | cdot-k3-06 | 19 | 26.6875 | 35 |
// | cdot-k3-07 | 19 | 26.6875 | 35 |
// | cdot-k3-08 | 20 | 27.5 | 36 |
// +------------+-----------+------------+-----------+
//+------------+-----------+--------------------+-----------+
//| node | value_min | value_mean | value_max |
//+------------+-----------+--------------------+-----------+
//| cdot-k3-05 | 19 | 26.823529411764707 | 36 |
//| cdot-k3-06 | 19 | 26.352941176470587 | 35 |
//| cdot-k3-07 | 19 | 26.352941176470587 | 35 |
//| cdot-k3-08 | 20 | 27.176470588235293 | 36 |
//+------------+-----------+--------------------+-----------+

func TestSensor_Run(t *testing.T) {

Expand All @@ -120,12 +121,12 @@ func TestSensor_Run(t *testing.T) {
omat, _ := sensor.Run(dataMap)

expected := map[string]map[string]float64{
"average_ambient_temperature": {"cdot-k3-05": 21.666666666666668, "cdot-k3-06": 22, "cdot-k3-07": 21.666666666666668, "cdot-k3-08": 22.333333333333332},
"average_ambient_temperature": {"cdot-k3-05": 22, "cdot-k3-06": 22.5, "cdot-k3-07": 22, "cdot-k3-08": 22.5},
"average_fan_speed": {"cdot-k3-05": 7030, "cdot-k3-06": 7050, "cdot-k3-07": 7040, "cdot-k3-08": 7050},
"max_fan_speed": {"cdot-k3-05": 7700, "cdot-k3-06": 7700, "cdot-k3-07": 7700, "cdot-k3-08": 7700},
"min_fan_speed": {"cdot-k3-05": 4600, "cdot-k3-06": 4500, "cdot-k3-07": 4600, "cdot-k3-08": 4500},
"power": {"cdot-k3-05": 383.4, "cdot-k3-06": 347.9, "cdot-k3-07": 340.8, "cdot-k3-08": 362.1},
"average_temperature": {"cdot-k3-05": 27.1875, "cdot-k3-06": 26.6875, "cdot-k3-07": 26.6875, "cdot-k3-08": 27.5},
"average_temperature": {"cdot-k3-05": 26.823529411764707, "cdot-k3-06": 26.352941176470587, "cdot-k3-07": 26.352941176470587, "cdot-k3-08": 27.176470588235293},
"max_temperature": {"cdot-k3-05": 36, "cdot-k3-06": 35, "cdot-k3-07": 35, "cdot-k3-08": 36},
"min_ambient_temperature": {"cdot-k3-05": 21, "cdot-k3-06": 21, "cdot-k3-07": 21, "cdot-k3-08": 21},
"min_temperature": {"cdot-k3-05": 19, "cdot-k3-06": 19, "cdot-k3-07": 19, "cdot-k3-08": 20},
Expand Down
Loading