Skip to content

Commit db941d7

Browse files
committed
Merge commit 'b237d44' (nshttpd#150)
2 parents aa7c013 + b237d44 commit db941d7

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

collector/netwatch_collector.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ func newNetwatchCollector() routerOSCollector {
2121
}
2222

2323
func (c *netwatchCollector) init() {
24-
c.props = []string{"host", "comment", "status"}
25-
labelNames := []string{"name", "address", "host", "comment"}
24+
c.props = []string{"host", "comment", "disabled", "status"}
25+
labelNames := []string{"name", "address", "host", "comment", "disabled"}
2626
c.descriptions = make(map[string]*prometheus.Desc)
27-
for _, p := range c.props[1:] {
27+
for _, p := range c.props[3:] {
2828
c.descriptions[p] = descriptionForPropertyName("netwatch", p, labelNames)
2929
}
3030
}
@@ -49,7 +49,7 @@ func (c *netwatchCollector) collect(ctx *collectorContext) error {
4949
}
5050

5151
func (c *netwatchCollector) fetch(ctx *collectorContext) ([]*proto.Sentence, error) {
52-
reply, err := ctx.client.Run("/tool/netwatch/print", "?disabled=false", "=.proplist="+strings.Join(c.props, ","))
52+
reply, err := ctx.client.Run("/tool/netwatch/print", "=.proplist="+strings.Join(c.props, ","))
5353
if err != nil {
5454
log.WithFields(log.Fields{
5555
"device": ctx.device.Name,
@@ -64,13 +64,14 @@ func (c *netwatchCollector) fetch(ctx *collectorContext) ([]*proto.Sentence, err
6464
func (c *netwatchCollector) collectForStat(re *proto.Sentence, ctx *collectorContext) {
6565
host := re.Map["host"]
6666
comment := re.Map["comment"]
67+
disabled := re.Map["disabled"]
6768

68-
for _, p := range c.props[2:] {
69-
c.collectMetricForProperty(p, host, comment, re, ctx)
69+
for _, p := range c.props[3:] {
70+
c.collectMetricForProperty(p, host, comment, disabled, re, ctx)
7071
}
7172
}
7273

73-
func (c *netwatchCollector) collectMetricForProperty(property, host, comment string, re *proto.Sentence, ctx *collectorContext) {
74+
func (c *netwatchCollector) collectMetricForProperty(property, host, comment, disabled string, re *proto.Sentence, ctx *collectorContext) {
7475
desc := c.descriptions[property]
7576
if value := re.Map[property]; value != "" {
7677
var numericValue float64
@@ -90,6 +91,6 @@ func (c *netwatchCollector) collectMetricForProperty(property, host, comment str
9091
"error": fmt.Errorf("unexpected netwatch status value"),
9192
}).Error("error parsing netwatch metric value")
9293
}
93-
ctx.ch <- prometheus.MustNewConstMetric(desc, prometheus.CounterValue, numericValue, ctx.device.Name, ctx.device.Address, host, comment)
94+
ctx.ch <- prometheus.MustNewConstMetric(desc, prometheus.CounterValue, numericValue, ctx.device.Name, ctx.device.Address, host, comment, disabled)
9495
}
9596
}

0 commit comments

Comments
 (0)