|
|
@ -55,7 +55,7 @@ type wifiStater interface {
|
|
|
|
BSS(ifi *wifi.Interface) (*wifi.BSS, error)
|
|
|
|
BSS(ifi *wifi.Interface) (*wifi.BSS, error)
|
|
|
|
Close() error
|
|
|
|
Close() error
|
|
|
|
Interfaces() ([]*wifi.Interface, 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.
|
|
|
|
// NewWifiCollector returns a new Collector exposing Wifi statistics.
|
|
|
@ -65,14 +65,14 @@ func NewWifiCollector() (Collector, error) {
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
var (
|
|
|
|
labels = []string{"device"}
|
|
|
|
labels = []string{"device", "mac_address"}
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
return &wifiCollector{
|
|
|
|
return &wifiCollector{
|
|
|
|
interfaceFrequencyHertz: prometheus.NewDesc(
|
|
|
|
interfaceFrequencyHertz: prometheus.NewDesc(
|
|
|
|
prometheus.BuildFQName(namespace, subsystem, "interface_frequency_hertz"),
|
|
|
|
prometheus.BuildFQName(namespace, subsystem, "interface_frequency_hertz"),
|
|
|
|
"The current frequency a WiFi interface is operating at, in hertz.",
|
|
|
|
"The current frequency a WiFi interface is operating at, in hertz.",
|
|
|
|
labels,
|
|
|
|
[]string{"device"},
|
|
|
|
nil,
|
|
|
|
nil,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
@ -193,10 +193,12 @@ func (c *wifiCollector) Update(ch chan<- prometheus.Metric) error {
|
|
|
|
ifi.Name, err)
|
|
|
|
ifi.Name, err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
info, err := stat.StationInfo(ifi)
|
|
|
|
stations, err := stat.StationInfo(ifi)
|
|
|
|
switch {
|
|
|
|
switch {
|
|
|
|
case err == nil:
|
|
|
|
case err == nil:
|
|
|
|
c.updateStationStats(ch, ifi.Name, info)
|
|
|
|
for _, station := range stations {
|
|
|
|
|
|
|
|
c.updateStationStats(ch, ifi.Name, station)
|
|
|
|
|
|
|
|
}
|
|
|
|
case os.IsNotExist(err):
|
|
|
|
case os.IsNotExist(err):
|
|
|
|
log.Debugf("station information not found for wifi device %q", ifi.Name)
|
|
|
|
log.Debugf("station information not found for wifi device %q", ifi.Name)
|
|
|
|
default:
|
|
|
|
default:
|
|
|
@ -227,6 +229,7 @@ func (c *wifiCollector) updateStationStats(ch chan<- prometheus.Metric, device s
|
|
|
|
prometheus.CounterValue,
|
|
|
|
prometheus.CounterValue,
|
|
|
|
info.Connected.Seconds(),
|
|
|
|
info.Connected.Seconds(),
|
|
|
|
device,
|
|
|
|
device,
|
|
|
|
|
|
|
|
info.HardwareAddr.String(),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
ch <- prometheus.MustNewConstMetric(
|
|
|
|
ch <- prometheus.MustNewConstMetric(
|
|
|
@ -234,6 +237,7 @@ func (c *wifiCollector) updateStationStats(ch chan<- prometheus.Metric, device s
|
|
|
|
prometheus.GaugeValue,
|
|
|
|
prometheus.GaugeValue,
|
|
|
|
info.Inactive.Seconds(),
|
|
|
|
info.Inactive.Seconds(),
|
|
|
|
device,
|
|
|
|
device,
|
|
|
|
|
|
|
|
info.HardwareAddr.String(),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
ch <- prometheus.MustNewConstMetric(
|
|
|
|
ch <- prometheus.MustNewConstMetric(
|
|
|
@ -241,6 +245,7 @@ func (c *wifiCollector) updateStationStats(ch chan<- prometheus.Metric, device s
|
|
|
|
prometheus.GaugeValue,
|
|
|
|
prometheus.GaugeValue,
|
|
|
|
float64(info.ReceiveBitrate),
|
|
|
|
float64(info.ReceiveBitrate),
|
|
|
|
device,
|
|
|
|
device,
|
|
|
|
|
|
|
|
info.HardwareAddr.String(),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
ch <- prometheus.MustNewConstMetric(
|
|
|
|
ch <- prometheus.MustNewConstMetric(
|
|
|
@ -248,6 +253,7 @@ func (c *wifiCollector) updateStationStats(ch chan<- prometheus.Metric, device s
|
|
|
|
prometheus.GaugeValue,
|
|
|
|
prometheus.GaugeValue,
|
|
|
|
float64(info.TransmitBitrate),
|
|
|
|
float64(info.TransmitBitrate),
|
|
|
|
device,
|
|
|
|
device,
|
|
|
|
|
|
|
|
info.HardwareAddr.String(),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
ch <- prometheus.MustNewConstMetric(
|
|
|
|
ch <- prometheus.MustNewConstMetric(
|
|
|
@ -255,6 +261,7 @@ func (c *wifiCollector) updateStationStats(ch chan<- prometheus.Metric, device s
|
|
|
|
prometheus.GaugeValue,
|
|
|
|
prometheus.GaugeValue,
|
|
|
|
float64(info.Signal),
|
|
|
|
float64(info.Signal),
|
|
|
|
device,
|
|
|
|
device,
|
|
|
|
|
|
|
|
info.HardwareAddr.String(),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
ch <- prometheus.MustNewConstMetric(
|
|
|
|
ch <- prometheus.MustNewConstMetric(
|
|
|
@ -262,6 +269,7 @@ func (c *wifiCollector) updateStationStats(ch chan<- prometheus.Metric, device s
|
|
|
|
prometheus.CounterValue,
|
|
|
|
prometheus.CounterValue,
|
|
|
|
float64(info.TransmitRetries),
|
|
|
|
float64(info.TransmitRetries),
|
|
|
|
device,
|
|
|
|
device,
|
|
|
|
|
|
|
|
info.HardwareAddr.String(),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
ch <- prometheus.MustNewConstMetric(
|
|
|
|
ch <- prometheus.MustNewConstMetric(
|
|
|
@ -269,6 +277,7 @@ func (c *wifiCollector) updateStationStats(ch chan<- prometheus.Metric, device s
|
|
|
|
prometheus.CounterValue,
|
|
|
|
prometheus.CounterValue,
|
|
|
|
float64(info.TransmitFailed),
|
|
|
|
float64(info.TransmitFailed),
|
|
|
|
device,
|
|
|
|
device,
|
|
|
|
|
|
|
|
info.HardwareAddr.String(),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
ch <- prometheus.MustNewConstMetric(
|
|
|
|
ch <- prometheus.MustNewConstMetric(
|
|
|
@ -276,6 +285,7 @@ func (c *wifiCollector) updateStationStats(ch chan<- prometheus.Metric, device s
|
|
|
|
prometheus.CounterValue,
|
|
|
|
prometheus.CounterValue,
|
|
|
|
float64(info.BeaconLoss),
|
|
|
|
float64(info.BeaconLoss),
|
|
|
|
device,
|
|
|
|
device,
|
|
|
|
|
|
|
|
info.HardwareAddr.String(),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -346,13 +356,13 @@ func (s *mockWifiStater) Interfaces() ([]*wifi.Interface, error) {
|
|
|
|
return ifis, nil
|
|
|
|
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")
|
|
|
|
p := filepath.Join(ifi.Name, "stationinfo.json")
|
|
|
|
|
|
|
|
|
|
|
|
var info wifi.StationInfo
|
|
|
|
var stations []*wifi.StationInfo
|
|
|
|
if err := s.unmarshalJSONFile(p, &info); err != nil {
|
|
|
|
if err := s.unmarshalJSONFile(p, &stations); err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return &info, nil
|
|
|
|
return stations, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|