Commit a1508fb0 authored by Vitaly Lipatov's avatar Vitaly Lipatov

route-health: merge v4 and v6 gateways into same health group

Instead of showing separate egw and egw.v6 groups in health JSON, merge v6 gateways into the corresponding v4 group for cleaner web UI display. Co-Authored-By: 's avatarClaude Opus 4.6 (1M context) <noreply@anthropic.com>
parent f6e9e280
...@@ -24,13 +24,18 @@ SHOW= ...@@ -24,13 +24,18 @@ SHOW=
[ "$1" = "--show" ] && SHOW=1 [ "$1" = "--show" ] && SHOW=1
# Collect group health data for JSON output # Collect group health data for JSON output
# v4 and v6 gateways are merged into the same group
JSON_ENTRIES="" JSON_ENTRIES=""
add_json_group() { add_json_group() {
local group="$1" proto="$2" gateways="$3" local group="$1" proto="$2" gateways="$3"
local key="${group}" # Check if group already exists in JSON_ENTRIES — append gateways
[ "$proto" = "v6" ] && key="${group}.v6" if echo "$JSON_ENTRIES" | grep -q "\"group\":\"$group\"" ; then
local entry="{\"group\":\"$key\",\"gateways\":[$gateways]}" # Append gateways to existing group (insert before closing ]})
JSON_ENTRIES="${JSON_ENTRIES:+$JSON_ENTRIES,}$entry" JSON_ENTRIES=$(echo "$JSON_ENTRIES" | sed "s|\"group\":\"$group\",\"gateways\":\[\\([^]]*\\)\]|\"group\":\"$group\",\"gateways\":[\1,$gateways]|")
else
local entry="{\"group\":\"$group\",\"gateways\":[$gateways]}"
JSON_ENTRIES="${JSON_ENTRIES:+$JSON_ENTRIES,}$entry"
fi
} }
# --- Query InfluxDB for packet loss, VPN status, and iperf3 bandwidth --- # --- Query InfluxDB for packet loss, VPN status, and iperf3 bandwidth ---
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment