Signed-off-by: neiledgar <neil.edgar@btinternet.com>
This commit is contained in:
parent
9b97f44a70
commit
7e4d9bd150
9 changed files with 122 additions and 69 deletions
|
|
@ -2307,31 +2307,39 @@ node_wifi_interface_frequency_hertz{device="wlan0"} 2.412e+09
|
|||
node_wifi_interface_frequency_hertz{device="wlan1"} 2.412e+09
|
||||
# HELP node_wifi_station_beacon_loss_total The total number of times a station has detected a beacon loss.
|
||||
# TYPE node_wifi_station_beacon_loss_total counter
|
||||
node_wifi_station_beacon_loss_total{device="wlan0"} 1
|
||||
node_wifi_station_beacon_loss_total{device="wlan0",mac_address="01:02:03:04:05:06"} 2
|
||||
node_wifi_station_beacon_loss_total{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} 1
|
||||
# HELP node_wifi_station_connected_seconds_total The total number of seconds a station has been connected to an access point.
|
||||
# TYPE node_wifi_station_connected_seconds_total counter
|
||||
node_wifi_station_connected_seconds_total{device="wlan0"} 30
|
||||
node_wifi_station_connected_seconds_total{device="wlan0",mac_address="01:02:03:04:05:06"} 60
|
||||
node_wifi_station_connected_seconds_total{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} 30
|
||||
# HELP node_wifi_station_inactive_seconds The number of seconds since any wireless activity has occurred on a station.
|
||||
# TYPE node_wifi_station_inactive_seconds gauge
|
||||
node_wifi_station_inactive_seconds{device="wlan0"} 0.4
|
||||
node_wifi_station_inactive_seconds{device="wlan0",mac_address="01:02:03:04:05:06"} 0.8
|
||||
node_wifi_station_inactive_seconds{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} 0.4
|
||||
# HELP node_wifi_station_info Labeled WiFi interface station information as provided by the operating system.
|
||||
# TYPE node_wifi_station_info gauge
|
||||
node_wifi_station_info{bssid="00:11:22:33:44:55",device="wlan0",mode="client",ssid="Example"} 1
|
||||
# HELP node_wifi_station_receive_bits_per_second The current WiFi receive bitrate of a station, in bits per second.
|
||||
# TYPE node_wifi_station_receive_bits_per_second gauge
|
||||
node_wifi_station_receive_bits_per_second{device="wlan0"} 1.28e+08
|
||||
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_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"} -52
|
||||
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="aa:bb:cc:dd:ee:ff"} -52
|
||||
# HELP node_wifi_station_transmit_bits_per_second The current WiFi transmit bitrate of a station, in bits per second.
|
||||
# TYPE node_wifi_station_transmit_bits_per_second gauge
|
||||
node_wifi_station_transmit_bits_per_second{device="wlan0"} 1.64e+08
|
||||
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_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"} 2
|
||||
node_wifi_station_transmit_failed_total{device="wlan0",mac_address="01:02:03:04:05:06"} 4
|
||||
node_wifi_station_transmit_failed_total{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} 2
|
||||
# HELP node_wifi_station_transmit_retries_total The total number of times a station has had to retry while sending a packet.
|
||||
# TYPE node_wifi_station_transmit_retries_total counter
|
||||
node_wifi_station_transmit_retries_total{device="wlan0"} 10
|
||||
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
|
||||
# HELP node_xfs_allocation_btree_compares_total Number of allocation B-tree compares for a filesystem.
|
||||
# TYPE node_xfs_allocation_btree_compares_total counter
|
||||
node_xfs_allocation_btree_compares_total{device="sda1"} 0
|
||||
|
|
|
|||
|
|
@ -2307,31 +2307,39 @@ node_wifi_interface_frequency_hertz{device="wlan0"} 2.412e+09
|
|||
node_wifi_interface_frequency_hertz{device="wlan1"} 2.412e+09
|
||||
# HELP node_wifi_station_beacon_loss_total The total number of times a station has detected a beacon loss.
|
||||
# TYPE node_wifi_station_beacon_loss_total counter
|
||||
node_wifi_station_beacon_loss_total{device="wlan0"} 1
|
||||
node_wifi_station_beacon_loss_total{device="wlan0",mac_address="01:02:03:04:05:06"} 2
|
||||
node_wifi_station_beacon_loss_total{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} 1
|
||||
# HELP node_wifi_station_connected_seconds_total The total number of seconds a station has been connected to an access point.
|
||||
# TYPE node_wifi_station_connected_seconds_total counter
|
||||
node_wifi_station_connected_seconds_total{device="wlan0"} 30
|
||||
node_wifi_station_connected_seconds_total{device="wlan0",mac_address="01:02:03:04:05:06"} 60
|
||||
node_wifi_station_connected_seconds_total{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} 30
|
||||
# HELP node_wifi_station_inactive_seconds The number of seconds since any wireless activity has occurred on a station.
|
||||
# TYPE node_wifi_station_inactive_seconds gauge
|
||||
node_wifi_station_inactive_seconds{device="wlan0"} 0.4
|
||||
node_wifi_station_inactive_seconds{device="wlan0",mac_address="01:02:03:04:05:06"} 0.8
|
||||
node_wifi_station_inactive_seconds{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} 0.4
|
||||
# HELP node_wifi_station_info Labeled WiFi interface station information as provided by the operating system.
|
||||
# TYPE node_wifi_station_info gauge
|
||||
node_wifi_station_info{bssid="00:11:22:33:44:55",device="wlan0",mode="client",ssid="Example"} 1
|
||||
# HELP node_wifi_station_receive_bits_per_second The current WiFi receive bitrate of a station, in bits per second.
|
||||
# TYPE node_wifi_station_receive_bits_per_second gauge
|
||||
node_wifi_station_receive_bits_per_second{device="wlan0"} 1.28e+08
|
||||
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_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"} -52
|
||||
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="aa:bb:cc:dd:ee:ff"} -52
|
||||
# HELP node_wifi_station_transmit_bits_per_second The current WiFi transmit bitrate of a station, in bits per second.
|
||||
# TYPE node_wifi_station_transmit_bits_per_second gauge
|
||||
node_wifi_station_transmit_bits_per_second{device="wlan0"} 1.64e+08
|
||||
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_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"} 2
|
||||
node_wifi_station_transmit_failed_total{device="wlan0",mac_address="01:02:03:04:05:06"} 4
|
||||
node_wifi_station_transmit_failed_total{device="wlan0",mac_address="aa:bb:cc:dd:ee:ff"} 2
|
||||
# HELP node_wifi_station_transmit_retries_total The total number of times a station has had to retry while sending a packet.
|
||||
# TYPE node_wifi_station_transmit_retries_total counter
|
||||
node_wifi_station_transmit_retries_total{device="wlan0"} 10
|
||||
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
|
||||
# HELP node_xfs_allocation_btree_compares_total Number of allocation B-tree compares for a filesystem.
|
||||
# TYPE node_xfs_allocation_btree_compares_total counter
|
||||
node_xfs_allocation_btree_compares_total{device="sda1"} 0
|
||||
|
|
|
|||
|
|
@ -1,10 +1,25 @@
|
|||
{
|
||||
"connected": 30000000000,
|
||||
"inactive": 400000000,
|
||||
"receivebitrate": 128000000,
|
||||
"transmitbitrate": 164000000,
|
||||
"signal": -52,
|
||||
"transmitretries": 10,
|
||||
"transmitfailed": 2,
|
||||
"beaconloss": 1
|
||||
}
|
||||
[
|
||||
{
|
||||
"hardwareaddr": "qrvM3e7/",
|
||||
"connected": 30000000000,
|
||||
"inactive": 400000000,
|
||||
"receivebitrate": 128000000,
|
||||
"transmitbitrate": 164000000,
|
||||
"signal": -52,
|
||||
"transmitretries": 10,
|
||||
"transmitfailed": 2,
|
||||
"beaconloss": 1
|
||||
},
|
||||
{
|
||||
"hardwareaddr": "AQIDBAUG",
|
||||
"connected": 60000000000,
|
||||
"inactive": 800000000,
|
||||
"receivebitrate": 256000000,
|
||||
"transmitbitrate": 328000000,
|
||||
"signal": -26,
|
||||
"transmitretries": 20,
|
||||
"transmitfailed": 4,
|
||||
"beaconloss": 2
|
||||
}
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ type wifiStater interface {
|
|||
BSS(ifi *wifi.Interface) (*wifi.BSS, error)
|
||||
Close() error
|
||||
Interfaces() ([]*wifi.Interface, error)
|
||||
StationInfo(ifi *wifi.Interface) (*wifi.StationInfo, error)
|
||||
StationInfo(ifi *wifi.Interface) ([]*wifi.StationInfo, error)
|
||||
}
|
||||
|
||||
// NewWifiCollector returns a new Collector exposing Wifi statistics.
|
||||
|
|
@ -65,14 +65,14 @@ func NewWifiCollector() (Collector, error) {
|
|||
)
|
||||
|
||||
var (
|
||||
labels = []string{"device"}
|
||||
labels = []string{"device", "mac_address"}
|
||||
)
|
||||
|
||||
return &wifiCollector{
|
||||
interfaceFrequencyHertz: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(namespace, subsystem, "interface_frequency_hertz"),
|
||||
"The current frequency a WiFi interface is operating at, in hertz.",
|
||||
labels,
|
||||
[]string{"device"},
|
||||
nil,
|
||||
),
|
||||
|
||||
|
|
@ -193,10 +193,12 @@ func (c *wifiCollector) Update(ch chan<- prometheus.Metric) error {
|
|||
ifi.Name, err)
|
||||
}
|
||||
|
||||
info, err := stat.StationInfo(ifi)
|
||||
stations, err := stat.StationInfo(ifi)
|
||||
switch {
|
||||
case err == nil:
|
||||
c.updateStationStats(ch, ifi.Name, info)
|
||||
for _, station := range stations {
|
||||
c.updateStationStats(ch, ifi.Name, station)
|
||||
}
|
||||
case os.IsNotExist(err):
|
||||
log.Debugf("station information not found for wifi device %q", ifi.Name)
|
||||
default:
|
||||
|
|
@ -227,6 +229,7 @@ func (c *wifiCollector) updateStationStats(ch chan<- prometheus.Metric, device s
|
|||
prometheus.CounterValue,
|
||||
info.Connected.Seconds(),
|
||||
device,
|
||||
info.HardwareAddr.String(),
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
|
|
@ -234,6 +237,7 @@ func (c *wifiCollector) updateStationStats(ch chan<- prometheus.Metric, device s
|
|||
prometheus.GaugeValue,
|
||||
info.Inactive.Seconds(),
|
||||
device,
|
||||
info.HardwareAddr.String(),
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
|
|
@ -241,6 +245,7 @@ func (c *wifiCollector) updateStationStats(ch chan<- prometheus.Metric, device s
|
|||
prometheus.GaugeValue,
|
||||
float64(info.ReceiveBitrate),
|
||||
device,
|
||||
info.HardwareAddr.String(),
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
|
|
@ -248,6 +253,7 @@ func (c *wifiCollector) updateStationStats(ch chan<- prometheus.Metric, device s
|
|||
prometheus.GaugeValue,
|
||||
float64(info.TransmitBitrate),
|
||||
device,
|
||||
info.HardwareAddr.String(),
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
|
|
@ -255,6 +261,7 @@ func (c *wifiCollector) updateStationStats(ch chan<- prometheus.Metric, device s
|
|||
prometheus.GaugeValue,
|
||||
float64(info.Signal),
|
||||
device,
|
||||
info.HardwareAddr.String(),
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
|
|
@ -262,6 +269,7 @@ func (c *wifiCollector) updateStationStats(ch chan<- prometheus.Metric, device s
|
|||
prometheus.CounterValue,
|
||||
float64(info.TransmitRetries),
|
||||
device,
|
||||
info.HardwareAddr.String(),
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
|
|
@ -269,6 +277,7 @@ func (c *wifiCollector) updateStationStats(ch chan<- prometheus.Metric, device s
|
|||
prometheus.CounterValue,
|
||||
float64(info.TransmitFailed),
|
||||
device,
|
||||
info.HardwareAddr.String(),
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
|
|
@ -276,6 +285,7 @@ func (c *wifiCollector) updateStationStats(ch chan<- prometheus.Metric, device s
|
|||
prometheus.CounterValue,
|
||||
float64(info.BeaconLoss),
|
||||
device,
|
||||
info.HardwareAddr.String(),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -346,13 +356,13 @@ func (s *mockWifiStater) Interfaces() ([]*wifi.Interface, error) {
|
|||
return ifis, nil
|
||||
}
|
||||
|
||||
func (s *mockWifiStater) StationInfo(ifi *wifi.Interface) (*wifi.StationInfo, error) {
|
||||
func (s *mockWifiStater) StationInfo(ifi *wifi.Interface) ([]*wifi.StationInfo, error) {
|
||||
p := filepath.Join(ifi.Name, "stationinfo.json")
|
||||
|
||||
var info wifi.StationInfo
|
||||
if err := s.unmarshalJSONFile(p, &info); err != nil {
|
||||
var stations []*wifi.StationInfo
|
||||
if err := s.unmarshalJSONFile(p, &stations); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
return stations, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue