mirror of
				https://github.com/prometheus/node_exporter.git
				synced 2025-08-20 18:33:52 -07:00 
			
		
		
		
	Add wifi packet received and transmitted metrics
Signed-off-by: Bouke van der Bijl <i@bou.ke>
This commit is contained in:
		
							parent
							
								
									be19d537cd
								
							
						
					
					
						commit
						c8e98c4c3c
					
				| 
						 | 
					@ -3356,6 +3356,10 @@ node_wifi_station_receive_bits_per_second{device="wlan0",mac_address="aa:bb:cc:d
 | 
				
			||||||
# TYPE node_wifi_station_receive_bytes_total counter
 | 
					# TYPE node_wifi_station_receive_bytes_total counter
 | 
				
			||||||
node_wifi_station_receive_bytes_total{device="wlan0",mac_address="01:02:03:04:05:06"} 0
 | 
					node_wifi_station_receive_bytes_total{device="wlan0",mac_address="01:02:03:04:05:06"} 0
 | 
				
			||||||
node_wifi_station_receive_bytes_total{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} 0
 | 
					node_wifi_station_receive_bytes_total{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} 0
 | 
				
			||||||
 | 
					# HELP node_wifi_station_received_packets_total The total number of packets received by a station.
 | 
				
			||||||
 | 
					# TYPE node_wifi_station_received_packets_total counter
 | 
				
			||||||
 | 
					node_wifi_station_received_packets_total{device="wlan0",mac_address="01:02:03:04:05:06"} 0
 | 
				
			||||||
 | 
					node_wifi_station_received_packets_total{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} 0
 | 
				
			||||||
# HELP node_wifi_station_signal_dbm The current WiFi signal strength, in decibel-milliwatts (dBm).
 | 
					# HELP node_wifi_station_signal_dbm The current WiFi signal strength, in decibel-milliwatts (dBm).
 | 
				
			||||||
# TYPE node_wifi_station_signal_dbm gauge
 | 
					# TYPE node_wifi_station_signal_dbm gauge
 | 
				
			||||||
node_wifi_station_signal_dbm{device="wlan0",mac_address="01:02:03:04:05:06"} -26
 | 
					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:
 | 
				
			||||||
# TYPE node_wifi_station_transmit_retries_total counter
 | 
					# TYPE node_wifi_station_transmit_retries_total counter
 | 
				
			||||||
node_wifi_station_transmit_retries_total{device="wlan0",mac_address="01:02:03:04:05:06"} 20
 | 
					node_wifi_station_transmit_retries_total{device="wlan0",mac_address="01:02:03:04:05:06"} 20
 | 
				
			||||||
node_wifi_station_transmit_retries_total{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} 10
 | 
					node_wifi_station_transmit_retries_total{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} 10
 | 
				
			||||||
 | 
					# HELP node_wifi_station_transmitted_packets_total The total number of packets transmitted by a station.
 | 
				
			||||||
 | 
					# TYPE node_wifi_station_transmitted_packets_total counter
 | 
				
			||||||
 | 
					node_wifi_station_transmitted_packets_total{device="wlan0",mac_address="01:02:03:04:05:06"} 0
 | 
				
			||||||
 | 
					node_wifi_station_transmitted_packets_total{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} 0
 | 
				
			||||||
# HELP node_xfrm_acquire_error_packets_total State hasn’t been fully acquired before use
 | 
					# HELP node_xfrm_acquire_error_packets_total State hasn’t been fully acquired before use
 | 
				
			||||||
# TYPE node_xfrm_acquire_error_packets_total counter
 | 
					# TYPE node_xfrm_acquire_error_packets_total counter
 | 
				
			||||||
node_xfrm_acquire_error_packets_total 24532
 | 
					node_xfrm_acquire_error_packets_total 24532
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3378,6 +3378,10 @@ node_wifi_station_receive_bits_per_second{device="wlan0",mac_address="aa:bb:cc:d
 | 
				
			||||||
# TYPE node_wifi_station_receive_bytes_total counter
 | 
					# TYPE node_wifi_station_receive_bytes_total counter
 | 
				
			||||||
node_wifi_station_receive_bytes_total{device="wlan0",mac_address="01:02:03:04:05:06"} 0
 | 
					node_wifi_station_receive_bytes_total{device="wlan0",mac_address="01:02:03:04:05:06"} 0
 | 
				
			||||||
node_wifi_station_receive_bytes_total{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} 0
 | 
					node_wifi_station_receive_bytes_total{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} 0
 | 
				
			||||||
 | 
					# HELP node_wifi_station_received_packets_total The total number of packets received by a station.
 | 
				
			||||||
 | 
					# TYPE node_wifi_station_received_packets_total counter
 | 
				
			||||||
 | 
					node_wifi_station_received_packets_total{device="wlan0",mac_address="01:02:03:04:05:06"} 0
 | 
				
			||||||
 | 
					node_wifi_station_received_packets_total{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} 0
 | 
				
			||||||
# HELP node_wifi_station_signal_dbm The current WiFi signal strength, in decibel-milliwatts (dBm).
 | 
					# HELP node_wifi_station_signal_dbm The current WiFi signal strength, in decibel-milliwatts (dBm).
 | 
				
			||||||
# TYPE node_wifi_station_signal_dbm gauge
 | 
					# TYPE node_wifi_station_signal_dbm gauge
 | 
				
			||||||
node_wifi_station_signal_dbm{device="wlan0",mac_address="01:02:03:04:05:06"} -26
 | 
					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:
 | 
				
			||||||
# TYPE node_wifi_station_transmit_retries_total counter
 | 
					# TYPE node_wifi_station_transmit_retries_total counter
 | 
				
			||||||
node_wifi_station_transmit_retries_total{device="wlan0",mac_address="01:02:03:04:05:06"} 20
 | 
					node_wifi_station_transmit_retries_total{device="wlan0",mac_address="01:02:03:04:05:06"} 20
 | 
				
			||||||
node_wifi_station_transmit_retries_total{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} 10
 | 
					node_wifi_station_transmit_retries_total{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} 10
 | 
				
			||||||
 | 
					# HELP node_wifi_station_transmitted_packets_total The total number of packets transmitted by a station.
 | 
				
			||||||
 | 
					# TYPE node_wifi_station_transmitted_packets_total counter
 | 
				
			||||||
 | 
					node_wifi_station_transmitted_packets_total{device="wlan0",mac_address="01:02:03:04:05:06"} 0
 | 
				
			||||||
 | 
					node_wifi_station_transmitted_packets_total{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} 0
 | 
				
			||||||
# HELP node_xfrm_acquire_error_packets_total State hasn’t been fully acquired before use
 | 
					# HELP node_xfrm_acquire_error_packets_total State hasn’t been fully acquired before use
 | 
				
			||||||
# TYPE node_xfrm_acquire_error_packets_total counter
 | 
					# TYPE node_xfrm_acquire_error_packets_total counter
 | 
				
			||||||
node_xfrm_acquire_error_packets_total 24532
 | 
					node_xfrm_acquire_error_packets_total 24532
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -43,6 +43,8 @@ type wifiCollector struct {
 | 
				
			||||||
	stationTransmitRetriesTotal    *prometheus.Desc
 | 
						stationTransmitRetriesTotal    *prometheus.Desc
 | 
				
			||||||
	stationTransmitFailedTotal     *prometheus.Desc
 | 
						stationTransmitFailedTotal     *prometheus.Desc
 | 
				
			||||||
	stationBeaconLossTotal         *prometheus.Desc
 | 
						stationBeaconLossTotal         *prometheus.Desc
 | 
				
			||||||
 | 
						stationTransmittedPacketsTotal *prometheus.Desc
 | 
				
			||||||
 | 
						stationReceivedPacketsTotal    *prometheus.Desc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	logger *slog.Logger
 | 
						logger *slog.Logger
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -159,6 +161,20 @@ func NewWifiCollector(logger *slog.Logger) (Collector, error) {
 | 
				
			||||||
			labels,
 | 
								labels,
 | 
				
			||||||
			nil,
 | 
								nil,
 | 
				
			||||||
		),
 | 
							),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							stationTransmittedPacketsTotal: prometheus.NewDesc(
 | 
				
			||||||
 | 
								prometheus.BuildFQName(namespace, subsystem, "station_transmitted_packets_total"),
 | 
				
			||||||
 | 
								"The total number of packets transmitted by a station.",
 | 
				
			||||||
 | 
								labels,
 | 
				
			||||||
 | 
								nil,
 | 
				
			||||||
 | 
							),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							stationReceivedPacketsTotal: prometheus.NewDesc(
 | 
				
			||||||
 | 
								prometheus.BuildFQName(namespace, subsystem, "station_received_packets_total"),
 | 
				
			||||||
 | 
								"The total number of packets received by a station.",
 | 
				
			||||||
 | 
								labels,
 | 
				
			||||||
 | 
								nil,
 | 
				
			||||||
 | 
							),
 | 
				
			||||||
		logger: logger,
 | 
							logger: logger,
 | 
				
			||||||
	}, nil
 | 
						}, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -325,6 +341,22 @@ func (c *wifiCollector) updateStationStats(ch chan<- prometheus.Metric, device s
 | 
				
			||||||
		device,
 | 
							device,
 | 
				
			||||||
		info.HardwareAddr.String(),
 | 
							info.HardwareAddr.String(),
 | 
				
			||||||
	)
 | 
						)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						ch <- prometheus.MustNewConstMetric(
 | 
				
			||||||
 | 
							c.stationTransmittedPacketsTotal,
 | 
				
			||||||
 | 
							prometheus.CounterValue,
 | 
				
			||||||
 | 
							float64(info.TransmittedPackets),
 | 
				
			||||||
 | 
							device,
 | 
				
			||||||
 | 
							info.HardwareAddr.String(),
 | 
				
			||||||
 | 
						)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						ch <- prometheus.MustNewConstMetric(
 | 
				
			||||||
 | 
							c.stationReceivedPacketsTotal,
 | 
				
			||||||
 | 
							prometheus.CounterValue,
 | 
				
			||||||
 | 
							float64(info.ReceivedPackets),
 | 
				
			||||||
 | 
							device,
 | 
				
			||||||
 | 
							info.HardwareAddr.String(),
 | 
				
			||||||
 | 
						)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func mHzToHz(mHz int) float64 {
 | 
					func mHzToHz(mHz int) float64 {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue