Skip to content

Commit 0817817

Browse files
committed
Add packet received and transmitted metrics
Signed-off-by: Bouke van der Bijl <i@bou.ke>
1 parent be19d53 commit 0817817

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
@@ -3356,6 +3356,10 @@ node_wifi_station_receive_bits_per_second{device="wlan0",mac_address="aa:bb:cc:d
33563356
# TYPE node_wifi_station_receive_bytes_total counter
33573357
node_wifi_station_receive_bytes_total{device="wlan0",mac_address="01:02:03:04:05:06"} 0
33583358
node_wifi_station_receive_bytes_total{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} 0
3359+
# HELP node_wifi_station_received_packets_total The total number of packets received by a station.
3360+
# TYPE node_wifi_station_received_packets_total counter
3361+
node_wifi_station_received_packets_total{device="wlan0",mac_address="01:02:03:04:05:06"} 0
3362+
node_wifi_station_received_packets_total{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} 0
33593363
# HELP node_wifi_station_signal_dbm The current WiFi signal strength, in decibel-milliwatts (dBm).
33603364
# TYPE node_wifi_station_signal_dbm gauge
33613365
node_wifi_station_signal_dbm{device="wlan0",mac_address="01:02:03:04:05:06"} -26
@@ -3376,6 +3380,10 @@ node_wifi_station_transmit_failed_total{device="wlan0",mac_address="aa:bb:cc:dd:
33763380
# TYPE node_wifi_station_transmit_retries_total counter
33773381
node_wifi_station_transmit_retries_total{device="wlan0",mac_address="01:02:03:04:05:06"} 20
33783382
node_wifi_station_transmit_retries_total{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} 10
3383+
# HELP node_wifi_station_transmitted_packets_total The total number of packets transmitted by a station.
3384+
# TYPE node_wifi_station_transmitted_packets_total counter
3385+
node_wifi_station_transmitted_packets_total{device="wlan0",mac_address="01:02:03:04:05:06"} 0
3386+
node_wifi_station_transmitted_packets_total{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} 0
33793387
# HELP node_xfrm_acquire_error_packets_total State hasn’t been fully acquired before use
33803388
# TYPE node_xfrm_acquire_error_packets_total counter
33813389
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
@@ -3378,6 +3378,10 @@ node_wifi_station_receive_bits_per_second{device="wlan0",mac_address="aa:bb:cc:d
33783378
# TYPE node_wifi_station_receive_bytes_total counter
33793379
node_wifi_station_receive_bytes_total{device="wlan0",mac_address="01:02:03:04:05:06"} 0
33803380
node_wifi_station_receive_bytes_total{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} 0
3381+
# HELP node_wifi_station_received_packets_total The total number of packets received by a station.
3382+
# TYPE node_wifi_station_received_packets_total counter
3383+
node_wifi_station_received_packets_total{device="wlan0",mac_address="01:02:03:04:05:06"} 0
3384+
node_wifi_station_received_packets_total{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} 0
33813385
# HELP node_wifi_station_signal_dbm The current WiFi signal strength, in decibel-milliwatts (dBm).
33823386
# TYPE node_wifi_station_signal_dbm gauge
33833387
node_wifi_station_signal_dbm{device="wlan0",mac_address="01:02:03:04:05:06"} -26
@@ -3398,6 +3402,10 @@ node_wifi_station_transmit_failed_total{device="wlan0",mac_address="aa:bb:cc:dd:
33983402
# TYPE node_wifi_station_transmit_retries_total counter
33993403
node_wifi_station_transmit_retries_total{device="wlan0",mac_address="01:02:03:04:05:06"} 20
34003404
node_wifi_station_transmit_retries_total{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} 10
3405+
# HELP node_wifi_station_transmitted_packets_total The total number of packets transmitted by a station.
3406+
# TYPE node_wifi_station_transmitted_packets_total counter
3407+
node_wifi_station_transmitted_packets_total{device="wlan0",mac_address="01:02:03:04:05:06"} 0
3408+
node_wifi_station_transmitted_packets_total{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} 0
34013409
# HELP node_xfrm_acquire_error_packets_total State hasn’t been fully acquired before use
34023410
# TYPE node_xfrm_acquire_error_packets_total counter
34033411
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)