Skip to content

Commit b4a3d2d

Browse files
authored
Add wifi packet received and transmitted metrics (#3382)
Signed-off-by: Bouke van der Bijl <[email protected]>
1 parent 524b56c commit b4a3d2d

File tree

3 files changed

+58
-10
lines changed

3 files changed

+58
-10
lines changed

collector/fixtures/e2e-64k-page-output.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3412,6 +3412,10 @@ node_wifi_station_receive_bits_per_second{device="wlan0",mac_address="aa:bb:cc:d
34123412
# TYPE node_wifi_station_receive_bytes_total counter
34133413
node_wifi_station_receive_bytes_total{device="wlan0",mac_address="01:02:03:04:05:06"} 0
34143414
node_wifi_station_receive_bytes_total{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} 0
3415+
# HELP node_wifi_station_received_packets_total The total number of packets received by a station.
3416+
# TYPE node_wifi_station_received_packets_total counter
3417+
node_wifi_station_received_packets_total{device="wlan0",mac_address="01:02:03:04:05:06"} 0
3418+
node_wifi_station_received_packets_total{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} 0
34153419
# HELP node_wifi_station_signal_dbm The current WiFi signal strength, in decibel-milliwatts (dBm).
34163420
# TYPE node_wifi_station_signal_dbm gauge
34173421
node_wifi_station_signal_dbm{device="wlan0",mac_address="01:02:03:04:05:06"} -26
@@ -3432,6 +3436,10 @@ node_wifi_station_transmit_failed_total{device="wlan0",mac_address="aa:bb:cc:dd:
34323436
# TYPE node_wifi_station_transmit_retries_total counter
34333437
node_wifi_station_transmit_retries_total{device="wlan0",mac_address="01:02:03:04:05:06"} 20
34343438
node_wifi_station_transmit_retries_total{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} 10
3439+
# HELP node_wifi_station_transmitted_packets_total The total number of packets transmitted by a station.
3440+
# TYPE node_wifi_station_transmitted_packets_total counter
3441+
node_wifi_station_transmitted_packets_total{device="wlan0",mac_address="01:02:03:04:05:06"} 0
3442+
node_wifi_station_transmitted_packets_total{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} 0
34353443
# HELP node_xfrm_acquire_error_packets_total State hasn’t been fully acquired before use
34363444
# TYPE node_xfrm_acquire_error_packets_total counter
34373445
node_xfrm_acquire_error_packets_total 24532

collector/fixtures/e2e-output.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3434,6 +3434,10 @@ node_wifi_station_receive_bits_per_second{device="wlan0",mac_address="aa:bb:cc:d
34343434
# TYPE node_wifi_station_receive_bytes_total counter
34353435
node_wifi_station_receive_bytes_total{device="wlan0",mac_address="01:02:03:04:05:06"} 0
34363436
node_wifi_station_receive_bytes_total{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} 0
3437+
# HELP node_wifi_station_received_packets_total The total number of packets received by a station.
3438+
# TYPE node_wifi_station_received_packets_total counter
3439+
node_wifi_station_received_packets_total{device="wlan0",mac_address="01:02:03:04:05:06"} 0
3440+
node_wifi_station_received_packets_total{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} 0
34373441
# HELP node_wifi_station_signal_dbm The current WiFi signal strength, in decibel-milliwatts (dBm).
34383442
# TYPE node_wifi_station_signal_dbm gauge
34393443
node_wifi_station_signal_dbm{device="wlan0",mac_address="01:02:03:04:05:06"} -26
@@ -3454,6 +3458,10 @@ node_wifi_station_transmit_failed_total{device="wlan0",mac_address="aa:bb:cc:dd:
34543458
# TYPE node_wifi_station_transmit_retries_total counter
34553459
node_wifi_station_transmit_retries_total{device="wlan0",mac_address="01:02:03:04:05:06"} 20
34563460
node_wifi_station_transmit_retries_total{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} 10
3461+
# HELP node_wifi_station_transmitted_packets_total The total number of packets transmitted by a station.
3462+
# TYPE node_wifi_station_transmitted_packets_total counter
3463+
node_wifi_station_transmitted_packets_total{device="wlan0",mac_address="01:02:03:04:05:06"} 0
3464+
node_wifi_station_transmitted_packets_total{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} 0
34573465
# HELP node_xfrm_acquire_error_packets_total State hasn’t been fully acquired before use
34583466
# TYPE node_xfrm_acquire_error_packets_total counter
34593467
node_xfrm_acquire_error_packets_total 24532

collector/wifi_linux.go

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,18 @@ type wifiCollector struct {
3333
interfaceFrequencyHertz *prometheus.Desc
3434
stationInfo *prometheus.Desc
3535

36-
stationConnectedSecondsTotal *prometheus.Desc
37-
stationInactiveSeconds *prometheus.Desc
38-
stationReceiveBitsPerSecond *prometheus.Desc
39-
stationTransmitBitsPerSecond *prometheus.Desc
40-
stationReceiveBytesTotal *prometheus.Desc
41-
stationTransmitBytesTotal *prometheus.Desc
42-
stationSignalDBM *prometheus.Desc
43-
stationTransmitRetriesTotal *prometheus.Desc
44-
stationTransmitFailedTotal *prometheus.Desc
45-
stationBeaconLossTotal *prometheus.Desc
36+
stationConnectedSecondsTotal *prometheus.Desc
37+
stationInactiveSeconds *prometheus.Desc
38+
stationReceiveBitsPerSecond *prometheus.Desc
39+
stationTransmitBitsPerSecond *prometheus.Desc
40+
stationReceiveBytesTotal *prometheus.Desc
41+
stationTransmitBytesTotal *prometheus.Desc
42+
stationSignalDBM *prometheus.Desc
43+
stationTransmitRetriesTotal *prometheus.Desc
44+
stationTransmitFailedTotal *prometheus.Desc
45+
stationBeaconLossTotal *prometheus.Desc
46+
stationTransmittedPacketsTotal *prometheus.Desc
47+
stationReceivedPacketsTotal *prometheus.Desc
4648

4749
logger *slog.Logger
4850
}
@@ -159,6 +161,20 @@ func NewWifiCollector(logger *slog.Logger) (Collector, error) {
159161
labels,
160162
nil,
161163
),
164+
165+
stationTransmittedPacketsTotal: prometheus.NewDesc(
166+
prometheus.BuildFQName(namespace, subsystem, "station_transmitted_packets_total"),
167+
"The total number of packets transmitted by a station.",
168+
labels,
169+
nil,
170+
),
171+
172+
stationReceivedPacketsTotal: prometheus.NewDesc(
173+
prometheus.BuildFQName(namespace, subsystem, "station_received_packets_total"),
174+
"The total number of packets received by a station.",
175+
labels,
176+
nil,
177+
),
162178
logger: logger,
163179
}, nil
164180
}
@@ -325,6 +341,22 @@ func (c *wifiCollector) updateStationStats(ch chan<- prometheus.Metric, device s
325341
device,
326342
info.HardwareAddr.String(),
327343
)
344+
345+
ch <- prometheus.MustNewConstMetric(
346+
c.stationTransmittedPacketsTotal,
347+
prometheus.CounterValue,
348+
float64(info.TransmittedPackets),
349+
device,
350+
info.HardwareAddr.String(),
351+
)
352+
353+
ch <- prometheus.MustNewConstMetric(
354+
c.stationReceivedPacketsTotal,
355+
prometheus.CounterValue,
356+
float64(info.ReceivedPackets),
357+
device,
358+
info.HardwareAddr.String(),
359+
)
328360
}
329361

330362
func mHzToHz(mHz int) float64 {

0 commit comments

Comments
 (0)