@@ -21,10 +21,10 @@ func newNetwatchCollector() routerOSCollector {
21
21
}
22
22
23
23
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" }
26
26
c .descriptions = make (map [string ]* prometheus.Desc )
27
- for _ , p := range c .props [1 :] {
27
+ for _ , p := range c .props [3 :] {
28
28
c .descriptions [p ] = descriptionForPropertyName ("netwatch" , p , labelNames )
29
29
}
30
30
}
@@ -49,7 +49,7 @@ func (c *netwatchCollector) collect(ctx *collectorContext) error {
49
49
}
50
50
51
51
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 , "," ))
53
53
if err != nil {
54
54
log .WithFields (log.Fields {
55
55
"device" : ctx .device .Name ,
@@ -64,13 +64,14 @@ func (c *netwatchCollector) fetch(ctx *collectorContext) ([]*proto.Sentence, err
64
64
func (c * netwatchCollector ) collectForStat (re * proto.Sentence , ctx * collectorContext ) {
65
65
host := re .Map ["host" ]
66
66
comment := re .Map ["comment" ]
67
+ disabled := re .Map ["disabled" ]
67
68
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 )
70
71
}
71
72
}
72
73
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 ) {
74
75
desc := c .descriptions [property ]
75
76
if value := re .Map [property ]; value != "" {
76
77
var numericValue float64
@@ -90,6 +91,6 @@ func (c *netwatchCollector) collectMetricForProperty(property, host, comment str
90
91
"error" : fmt .Errorf ("unexpected netwatch status value" ),
91
92
}).Error ("error parsing netwatch metric value" )
92
93
}
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 )
94
95
}
95
96
}
0 commit comments