diff --git a/enrich.py b/enrich.py index 0badc68..c1c6674 100755 --- a/enrich.py +++ b/enrich.py @@ -393,12 +393,9 @@ def analyze_pcap(pcapng_path, start_ts, end_ts, ap_bssid, ap_channel): continue ssid_hidden_status[ssid] = hidden_ssid - # Store all observed values - if ssid in ssid_encryption_status: - ssid_encryption_status[ssid].append(is_open) - else: - ssid_encryption_status[ssid] = [is_open] - + if ssid not in ssid_encryption_status: + ssid_encryption_status[ssid] = is_open + ssid_packet_counts[ssid] += 1 bssid = getattr(wlan, 'bssid', '').lower() @@ -437,7 +434,7 @@ def analyze_pcap(pcapng_path, start_ts, end_ts, ap_bssid, ap_channel): ssid_summary.append({ 'SSID': ssid, 'Hidden': ssid_hidden_status.get(ssid, False), - 'Open': all(ssid_encryption_status.get(ssid, [True])), + 'Open': ssid_encryption_status.get(ssid, True), 'BSSID_Count': len(bssids), 'BSSIDs': ";".join(sorted(bssids)), 'Avg_Signal': mean(signals) if signals else 0, diff --git a/runtest.sh b/runtest.sh index 7e3b0d3..d30fa21 100755 --- a/runtest.sh +++ b/runtest.sh @@ -71,36 +71,29 @@ run_iperf() { local tmp_err tmp_err=$(mktemp) - local tmp_json - tmp_json=$(mktemp) - local result - result=$(iperf3 "${args[@]}" -J >"$tmp_json" 2>"$tmp_err") + result=$(iperf3 "${args[@]}" 2>"$tmp_err" | jq -r ' + if .error then + "iperf3-error" + elif has("end") | not then + "no-end" + elif .end | has("sum_received") then + .end.sum_received.bits_per_second + elif .end | has("sum") then + .end.sum.bits_per_second + else + "unexpected-format" + end' || echo "execution-failed") - parsed=$(jq -r ' - if .error then - "iperf3-error" - elif has("end") | not then - "no-end" - elif .end | has("sum_received") then - .end.sum_received.bits_per_second - elif .end | has("sum") then - .end.sum.bits_per_second - else - "unexpected-format" - end' "$tmp_json" || echo "execution-failed") - - if [[ "$parsed" == "iperf3-error" || "$parsed" == "no-end" || "$parsed" == "unexpected-format" || "$parsed" == "execution-failed" ]]; then - timestamp=$(date -Iseconds) - echo "$timestamp,iperf $mode $direction to $target failed with '$parsed'" >>"$FAILURE_LOG" + if [[ "$result" == "iperf3-error" || "$result" == "no-end" || "$result" == "unexpected-format" || "$result" == "execution-failed" ]]; then + echo "$(date -Iseconds),iperf $mode $direction to $target failed with '$result'" >>"$FAILURE_LOG" echo "[stderr] $(cat "$tmp_err")" >>"$FAILURE_LOG" - echo "[json] $(cat "$tmp_json")" >>"$FAILURE_LOG" echo "0" else - echo "$parsed" + echo "$result" fi - rm -f "$tmp_err" "$tmp_json" + rm -f "$tmp_err" } # Start test email