Skip to content

Commit 4118319

Browse files
committed
Add packet received and transmitted metrics
Signed-off-by: Bouke van der Bijl <[email protected]>
1 parent be19d53 commit 4118319

File tree

1 file changed

+42
-10
lines changed

1 file changed

+42
-10
lines changed

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)