|
|
@ -155,14 +155,8 @@ func (c *muninCollector) muninConfig(name string) (config map[string]map[string] |
|
|
|
return config, graphConfig, err |
|
|
|
return config, graphConfig, err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (c *muninCollector) registerMetrics() (err error) { |
|
|
|
|
|
|
|
items, err := c.muninList() |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
return fmt.Errorf("Couldn't get graph list: %s", err) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for _, name := range items { |
|
|
|
func (c *muninCollector) registerMetric(name string) (err error) { |
|
|
|
c.graphs = append(c.graphs, name) |
|
|
|
|
|
|
|
configs, graphConfig, err := c.muninConfig(name) |
|
|
|
configs, graphConfig, err := c.muninConfig(name) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return fmt.Errorf("Couldn't get config for graph %s: %s", name, err) |
|
|
|
return fmt.Errorf("Couldn't get config for graph %s: %s", name, err) |
|
|
@ -179,14 +173,18 @@ func (c *muninCollector) registerMetrics() (err error) { |
|
|
|
c.gaugePerMetric[metricName] = gauge |
|
|
|
c.gaugePerMetric[metricName] = gauge |
|
|
|
c.registry.Register(metricName, desc, prometheus.NilLabels, gauge) |
|
|
|
c.registry.Register(metricName, desc, prometheus.NilLabels, gauge) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return nil |
|
|
|
return err |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (c *muninCollector) Update() (updates int, err error) { |
|
|
|
func (c *muninCollector) Update() (updates int, err error) { |
|
|
|
err = c.registerMetrics() |
|
|
|
items, err := c.muninList() |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return updates, fmt.Errorf("Couldn't register metrics: %s", err) |
|
|
|
return updates, fmt.Errorf("Couldn't get graph list: %s", err) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for _, name := range items { |
|
|
|
|
|
|
|
c.graphs = append(c.graphs, name) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for _, graph := range c.graphs { |
|
|
|
for _, graph := range c.graphs { |
|
|
@ -215,6 +213,12 @@ func (c *muninCollector) Update() (updates int, err error) { |
|
|
|
continue |
|
|
|
continue |
|
|
|
} |
|
|
|
} |
|
|
|
key, value_s := strings.Split(parts[0], ".")[0], parts[1] |
|
|
|
key, value_s := strings.Split(parts[0], ".")[0], parts[1] |
|
|
|
|
|
|
|
name := graph + "-" + key |
|
|
|
|
|
|
|
if _, ok := c.gaugePerMetric[name]; !ok { |
|
|
|
|
|
|
|
if err := c.registerMetric(name); err != nil { |
|
|
|
|
|
|
|
return updates, err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
value, err := strconv.ParseFloat(value_s, 64) |
|
|
|
value, err := strconv.ParseFloat(value_s, 64) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
debug(c.Name(), "Couldn't parse value in line %s, malformed?", line) |
|
|
|
debug(c.Name(), "Couldn't parse value in line %s, malformed?", line) |
|
|
@ -223,7 +227,6 @@ func (c *muninCollector) Update() (updates int, err error) { |
|
|
|
labels := map[string]string{ |
|
|
|
labels := map[string]string{ |
|
|
|
"hostname": c.hostname, |
|
|
|
"hostname": c.hostname, |
|
|
|
} |
|
|
|
} |
|
|
|
name := graph + "-" + key |
|
|
|
|
|
|
|
debug(c.Name(), "Set %s{%s}: %f\n", name, labels, value) |
|
|
|
debug(c.Name(), "Set %s{%s}: %f\n", name, labels, value) |
|
|
|
c.gaugePerMetric[name].Set(labels, value) |
|
|
|
c.gaugePerMetric[name].Set(labels, value) |
|
|
|
updates++ |
|
|
|
updates++ |
|
|
|