From 62f99f95f035b950b98402e992543ec738c85897 Mon Sep 17 00:00:00 2001 From: Nemikolh Date: Mon, 19 Nov 2018 18:15:54 +0000 Subject: [PATCH] Add receive/transmit bytes total metric (wifi collector). (#1150) Signed-off-by: Nemikolh --- CHANGELOG.md | 1 + collector/fixtures/e2e-64k-page-output.txt | 8 ++++++ collector/fixtures/e2e-output.txt | 8 ++++++ collector/wifi_linux.go | 32 ++++++++++++++++++++++ 4 files changed, 49 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 55214e5d..724f387e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ Darwin meminfo metrics have been renamed to match Prometheus conventions. #1060 * [FEATURE] Allow removal of rootfs prefix for run in docker #1058 * [ENHANCEMENT] Support for octal characters in mountpoints #954 * [ENHANCEMENT] Update wifi stats to support multiple stations #980 +* [ENHANCEMENT] Add transmit/receive bytes total for wifi stations #1150 * [ENHANCEMENT] Handle stuck NFS mounts #997 * [ENHANCEMENT] infiniband: Handle iWARP RDMA modules N/A #974 * [ENHANCEMENT] Update diskstats for linux kernel 4.19 #1109 diff --git a/collector/fixtures/e2e-64k-page-output.txt b/collector/fixtures/e2e-64k-page-output.txt index 91e27a4b..15bebafe 100644 --- a/collector/fixtures/e2e-64k-page-output.txt +++ b/collector/fixtures/e2e-64k-page-output.txt @@ -2451,6 +2451,10 @@ node_wifi_station_info{bssid="00:11:22:33:44:55",device="wlan0",mode="client",ss # TYPE node_wifi_station_receive_bits_per_second gauge node_wifi_station_receive_bits_per_second{device="wlan0",mac_address="01:02:03:04:05:06"} 2.56e+08 node_wifi_station_receive_bits_per_second{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} 1.28e+08 +# HELP node_wifi_station_receive_bytes_total The total number of bytes received by a WiFi station. +# 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="aa:bb:cc:dd:ee:ff"} 0 # HELP node_wifi_station_signal_dbm The current WiFi signal strength, in decibel-milliwatts (dBm). # TYPE node_wifi_station_signal_dbm gauge node_wifi_station_signal_dbm{device="wlan0",mac_address="01:02:03:04:05:06"} -26 @@ -2459,6 +2463,10 @@ node_wifi_station_signal_dbm{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} -52 # TYPE node_wifi_station_transmit_bits_per_second gauge node_wifi_station_transmit_bits_per_second{device="wlan0",mac_address="01:02:03:04:05:06"} 3.28e+08 node_wifi_station_transmit_bits_per_second{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} 1.64e+08 +# HELP node_wifi_station_transmit_bytes_total The total number of bytes transmitted by a WiFi station. +# TYPE node_wifi_station_transmit_bytes_total counter +node_wifi_station_transmit_bytes_total{device="wlan0",mac_address="01:02:03:04:05:06"} 0 +node_wifi_station_transmit_bytes_total{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} 0 # HELP node_wifi_station_transmit_failed_total The total number of times a station has failed to send a packet. # TYPE node_wifi_station_transmit_failed_total counter node_wifi_station_transmit_failed_total{device="wlan0",mac_address="01:02:03:04:05:06"} 4 diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt index 2f381124..3c4490a8 100644 --- a/collector/fixtures/e2e-output.txt +++ b/collector/fixtures/e2e-output.txt @@ -2451,6 +2451,10 @@ node_wifi_station_info{bssid="00:11:22:33:44:55",device="wlan0",mode="client",ss # TYPE node_wifi_station_receive_bits_per_second gauge node_wifi_station_receive_bits_per_second{device="wlan0",mac_address="01:02:03:04:05:06"} 2.56e+08 node_wifi_station_receive_bits_per_second{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} 1.28e+08 +# HELP node_wifi_station_receive_bytes_total The total number of bytes received by a WiFi station. +# 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="aa:bb:cc:dd:ee:ff"} 0 # HELP node_wifi_station_signal_dbm The current WiFi signal strength, in decibel-milliwatts (dBm). # TYPE node_wifi_station_signal_dbm gauge node_wifi_station_signal_dbm{device="wlan0",mac_address="01:02:03:04:05:06"} -26 @@ -2459,6 +2463,10 @@ node_wifi_station_signal_dbm{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} -52 # TYPE node_wifi_station_transmit_bits_per_second gauge node_wifi_station_transmit_bits_per_second{device="wlan0",mac_address="01:02:03:04:05:06"} 3.28e+08 node_wifi_station_transmit_bits_per_second{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} 1.64e+08 +# HELP node_wifi_station_transmit_bytes_total The total number of bytes transmitted by a WiFi station. +# TYPE node_wifi_station_transmit_bytes_total counter +node_wifi_station_transmit_bytes_total{device="wlan0",mac_address="01:02:03:04:05:06"} 0 +node_wifi_station_transmit_bytes_total{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} 0 # HELP node_wifi_station_transmit_failed_total The total number of times a station has failed to send a packet. # TYPE node_wifi_station_transmit_failed_total counter node_wifi_station_transmit_failed_total{device="wlan0",mac_address="01:02:03:04:05:06"} 4 diff --git a/collector/wifi_linux.go b/collector/wifi_linux.go index 099d97f3..b9830e48 100644 --- a/collector/wifi_linux.go +++ b/collector/wifi_linux.go @@ -34,6 +34,8 @@ type wifiCollector struct { stationInactiveSeconds *prometheus.Desc stationReceiveBitsPerSecond *prometheus.Desc stationTransmitBitsPerSecond *prometheus.Desc + stationReceiveBytesTotal *prometheus.Desc + stationTransmitBytesTotal *prometheus.Desc stationSignalDBM *prometheus.Desc stationTransmitRetriesTotal *prometheus.Desc stationTransmitFailedTotal *prometheus.Desc @@ -111,6 +113,20 @@ func NewWifiCollector() (Collector, error) { nil, ), + stationReceiveBytesTotal: prometheus.NewDesc( + prometheus.BuildFQName(namespace, subsystem, "station_receive_bytes_total"), + "The total number of bytes received by a WiFi station.", + labels, + nil, + ), + + stationTransmitBytesTotal: prometheus.NewDesc( + prometheus.BuildFQName(namespace, subsystem, "station_transmit_bytes_total"), + "The total number of bytes transmitted by a WiFi station.", + labels, + nil, + ), + stationSignalDBM: prometheus.NewDesc( prometheus.BuildFQName(namespace, subsystem, "station_signal_dbm"), "The current WiFi signal strength, in decibel-milliwatts (dBm).", @@ -256,6 +272,22 @@ func (c *wifiCollector) updateStationStats(ch chan<- prometheus.Metric, device s info.HardwareAddr.String(), ) + ch <- prometheus.MustNewConstMetric( + c.stationReceiveBytesTotal, + prometheus.CounterValue, + float64(info.ReceivedBytes), + device, + info.HardwareAddr.String(), + ) + + ch <- prometheus.MustNewConstMetric( + c.stationTransmitBytesTotal, + prometheus.CounterValue, + float64(info.TransmittedBytes), + device, + info.HardwareAddr.String(), + ) + ch <- prometheus.MustNewConstMetric( c.stationSignalDBM, prometheus.GaugeValue,