mirror of
https://github.com/nshttpd/mikrotik-exporter.git
synced 2025-01-22 20:51:34 +01:00
Merge pull request #104 from oGi4i/feature/fix_firmware
Fixed firmware collector for multiple devices with same packages
This commit is contained in:
commit
b60ab4f8ea
@ -19,7 +19,7 @@ func newFirmwareCollector() routerOSCollector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *firmwareCollector) init() {
|
func (c *firmwareCollector) init() {
|
||||||
labelNames := []string{"name", "disabled", "version", "build_time"}
|
labelNames := []string{"devicename", "name", "disabled", "version", "build_time"}
|
||||||
c.description = description("system", "package", "system packages version", labelNames)
|
c.description = description("system", "package", "system packages version", labelNames)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,10 +41,10 @@ func (c *firmwareCollector) collect(ctx *collectorContext) error {
|
|||||||
|
|
||||||
for _, pkg := range pkgs {
|
for _, pkg := range pkgs {
|
||||||
v := 1.0
|
v := 1.0
|
||||||
if strings.Compare(pkg.Map["disabled"], "true") == 0 {
|
if strings.EqualFold(pkg.Map["disabled"], "true") {
|
||||||
v = 0.0
|
v = 0.0
|
||||||
}
|
}
|
||||||
ctx.ch <- prometheus.MustNewConstMetric(c.description, prometheus.GaugeValue, v, pkg.Map["name"], pkg.Map["disabled"], pkg.Map["version"], pkg.Map["build-time"])
|
ctx.ch <- prometheus.MustNewConstMetric(c.description, prometheus.GaugeValue, v, ctx.device.Name, pkg.Map["name"], pkg.Map["disabled"], pkg.Map["version"], pkg.Map["build-time"])
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user