1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-21 18:41:03 +00:00

fronius: support jq builds without math library

"round" is part of jq's math support. Some distros (rhel8) don't enable it.
Fortunately round can be emulated with "floor" which is always present in
modern jq.
This commit is contained in:
Kim B. Heino 2021-10-14 15:01:44 +03:00 committed by Lars Kruse
parent 6408924066
commit 520c436ca1

View file

@ -31,7 +31,7 @@ to have a better chance of getting the config data out nonetheless.
=head1 CAVEAT
Only tested on a Fronius Primo.
Only tested on a Fronius Primo and Fronius Symo.
=head1 AUTHOR
@ -180,6 +180,7 @@ check_deps() {
for CMD in curl jq recode; do
if ! command -v "${CMD}" >/dev/null; then
echo "no (${CMD} not found)"
exit 0
fi
done
}
@ -261,11 +262,12 @@ inverter\(.key).draw AREASTACK
}
get_data() {
cached 0 get_power_flow_realtime_data | jq -r '.Body.Data.Inverters
cached 0 get_power_flow_realtime_data | jq -r 'def roundit: . + 0.5 | floor;
.Body.Data.Inverters
| to_entries[]
| @text "
inverter\(.key).value \(.value.E_Year | round)
inverter\(.key).extinfo Immediate output: \(.value.P) W; Daily total: \(.value.E_Day | round) Wh; Yearly total: \(.value.E_Year / 1000 | round) kWh
inverter\(.key).value \(.value.E_Year | roundit)
inverter\(.key).extinfo Immediate output: \(.value.P) W; Daily total: \(.value.E_Day | roundit) Wh; Yearly total: \(.value.E_Year / 1000 | roundit) kWh
"'
}