Skip to content

Commit 4f62adb

Browse files
committed
Fix metrics for registered clients
1 parent bcce1fd commit 4f62adb

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

collector/wlanif_collector.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ import (
1111
)
1212

1313
type wlanIFCollector struct {
14-
props []string
15-
descriptions map[string]*prometheus.Desc
14+
props []string
15+
propsWifiwave2 []string
16+
descriptions map[string]*prometheus.Desc
1617
}
1718

1819
func newWlanIFCollector() routerOSCollector {
@@ -23,11 +24,15 @@ func newWlanIFCollector() routerOSCollector {
2324

2425
func (c *wlanIFCollector) init() {
2526
c.props = []string{"channel", "registered-clients", "noise-floor", "overall-tx-ccq"}
27+
// wifiwave2 has slightly different names
28+
c.propsWifiwave2 = []string{"channel", "registered-peers"}
2629
labelNames := []string{"name", "address", "interface", "channel"}
2730
c.descriptions = make(map[string]*prometheus.Desc)
2831
for _, p := range c.props {
2932
c.descriptions[p] = descriptionForPropertyName("wlan_interface", p, labelNames)
3033
}
34+
// add description for wifiwave2-specific properties to map to wireless ones
35+
c.descriptions["registered-peers"] = descriptionForPropertyName("wlan_interface", "registered-clients", labelNames)
3136
}
3237

3338
func (c *wlanIFCollector) describe(ch chan<- *prometheus.Desc) {
@@ -78,12 +83,15 @@ func (c *wlanIFCollector) fetchInterfaceNames(ctx *collectorContext) ([]string,
7883

7984
func (c *wlanIFCollector) collectForInterface(iface string, ctx *collectorContext) error {
8085
cmd := ""
86+
var props []string
8187
if ctx.device.Wifiwave2 {
8288
cmd = "/interface/wifiwave/monitor"
89+
props = c.propsWifiwave2
8390
} else {
8491
cmd = "/interface/wireless/monitor"
92+
props = c.props
8593
}
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, ","))
8795
if err != nil {
8896
log.WithFields(log.Fields{
8997
"interface": iface,
@@ -93,7 +101,7 @@ func (c *wlanIFCollector) collectForInterface(iface string, ctx *collectorContex
93101
return err
94102
}
95103

96-
for _, p := range c.props[1:] {
104+
for _, p := range props[1:] {
97105
// there's always going to be only one sentence in reply, as we
98106
// have to explicitly specify the interface
99107
c.collectMetricForProperty(p, iface, reply.Re[0], ctx)

collector/wlansta_collector.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ func (c *wlanSTACollector) fetch(ctx *collectorContext) ([]*proto.Sentence, erro
9696
"=.proplist=" + strings.Join(props, ","),
9797
}
9898
}
99-
log.Debugf("Running collector command: %s", cmd)
10099
reply, err := ctx.client.Run(cmd...)
101100
if err != nil {
102101
log.WithFields(log.Fields{

0 commit comments

Comments
 (0)