@@ -11,8 +11,9 @@ import (
11
11
)
12
12
13
13
type wlanIFCollector struct {
14
- props []string
15
- descriptions map [string ]* prometheus.Desc
14
+ props []string
15
+ propsWifiwave2 []string
16
+ descriptions map [string ]* prometheus.Desc
16
17
}
17
18
18
19
func newWlanIFCollector () routerOSCollector {
@@ -23,11 +24,15 @@ func newWlanIFCollector() routerOSCollector {
23
24
24
25
func (c * wlanIFCollector ) init () {
25
26
c .props = []string {"channel" , "registered-clients" , "noise-floor" , "overall-tx-ccq" }
27
+ // wifiwave2 has slightly different names
28
+ c .propsWifiwave2 = []string {"channel" , "registered-peers" }
26
29
labelNames := []string {"name" , "address" , "interface" , "channel" }
27
30
c .descriptions = make (map [string ]* prometheus.Desc )
28
31
for _ , p := range c .props {
29
32
c .descriptions [p ] = descriptionForPropertyName ("wlan_interface" , p , labelNames )
30
33
}
34
+ // add description for wifiwave2-specific properties to map to wireless ones
35
+ c .descriptions ["registered-peers" ] = descriptionForPropertyName ("wlan_interface" , "registered-clients" , labelNames )
31
36
}
32
37
33
38
func (c * wlanIFCollector ) describe (ch chan <- * prometheus.Desc ) {
@@ -78,12 +83,15 @@ func (c *wlanIFCollector) fetchInterfaceNames(ctx *collectorContext) ([]string,
78
83
79
84
func (c * wlanIFCollector ) collectForInterface (iface string , ctx * collectorContext ) error {
80
85
cmd := ""
86
+ var props []string
81
87
if ctx .device .Wifiwave2 {
82
88
cmd = "/interface/wifiwave/monitor"
89
+ props = c .propsWifiwave2
83
90
} else {
84
91
cmd = "/interface/wireless/monitor"
92
+ props = c .props
85
93
}
86
- reply , err := ctx .client .Run (cmd , fmt .Sprintf ("=numbers=%s" , iface ), "=once=" , "=.proplist=" + strings .Join (c . props , "," ))
94
+ reply , err := ctx .client .Run (cmd , fmt .Sprintf ("=numbers=%s" , iface ), "=once=" , "=.proplist=" + strings .Join (props , "," ))
87
95
if err != nil {
88
96
log .WithFields (log.Fields {
89
97
"interface" : iface ,
@@ -93,7 +101,7 @@ func (c *wlanIFCollector) collectForInterface(iface string, ctx *collectorContex
93
101
return err
94
102
}
95
103
96
- for _ , p := range c . props [1 :] {
104
+ for _ , p := range props [1 :] {
97
105
// there's always going to be only one sentence in reply, as we
98
106
// have to explicitly specify the interface
99
107
c .collectMetricForProperty (p , iface , reply .Re [0 ], ctx )
0 commit comments