]> git.ipfire.org Git - oddments/collecty.git/commitdiff
sources: hostapd: Migrate to new metrics submission
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 22 Oct 2025 17:50:29 +0000 (17:50 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 22 Oct 2025 17:50:29 +0000 (17:50 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/daemon/sources/hostapd.c

index 9601f981c0c5f99b3b804e8c2530d70a0ac566a1..451b577294e07c831e7cd3a499f1c87c144e261b 100644 (file)
@@ -98,13 +98,24 @@ static int hostapd_submit_station(td_ctx* ctx, hostapd_station* station) {
        }
 
        // Submit the station
-       return td_source_submit(station->source, address,
-               "%lu:%lu:%ld:%ld:%lu:%lu:%lu:%lu:%lu:%lu:%lu:%lu:%lu:%lu:%lu:%lu",
-               station->connected_time, station->inactive_msec,
-               station->signal, station->last_ack_signal,
-               station->rx_packets, station->tx_packets, station->rx_bytes, station->tx_bytes,
-               station->rx_rate * 100 * 1024, station->rx_mcs, station->rx_vhtmcs, station->rx_vhtnss,
-               station->tx_rate * 100 * 1024, station->tx_mcs, station->tx_vhtmcs, station->tx_vhtnss);
+       return td_source_submit_values(station->source, address, VALUES(
+               VALUE_UINT64("connected_time",  &station->connected_time),
+               VALUE_UINT64("inactive_msec",   &station->inactive_msec),
+               VALUE_INT64 ("signal",          &station->signal),
+               VALUE_INT64 ("last_ack_signal", &station->last_ack_signal),
+               VALUE_UINT64("rx_packets",      &station->rx_packets),
+               VALUE_UINT64("tx_packets",      &station->tx_packets),
+               VALUE_UINT64("rx_bytes",        &station->rx_bytes),
+               VALUE_UINT64("tx_bytes",        &station->tx_bytes),
+               VALUE_UINT64("rx_rate",         &station->rx_rate),
+               VALUE_UINT64("rx_mcs",          &station->rx_mcs),
+               VALUE_UINT64("rx_vhtmcs",       &station->rx_vhtmcs),
+               VALUE_UINT64("rx_vhtnss",       &station->rx_vhtnss),
+               VALUE_UINT64("tx_rate",         &station->tx_rate),
+               VALUE_UINT64("tx_mcs",          &station->tx_mcs),
+               VALUE_UINT64("tx_vhtmcs",       &station->tx_vhtmcs),
+               VALUE_UINT64("tx_vhtnss",       &station->tx_vhtnss)
+       ));
 }
 
 static int hostapd_parse(td_ctx* ctx, td_file* stdout, unsigned long lineno,
@@ -171,6 +182,10 @@ static int hostapd_parse(td_ctx* ctx, td_file* stdout, unsigned long lineno,
                { NULL },
        };
 
+       // Convert the RX/TX rate to bit/s
+       station->rx_rate *= 100 * 1024;
+       station->tx_rate *= 100 * 1024;
+
        //  Try parsing the line
        return td_file_parse_line(stdout, parser, line, length);
 }