mirror of
https://github.com/nshttpd/mikrotik-exporter.git
synced 2024-11-10 09:39:46 +01:00
Merge 2656afd9a5
into e1b06c6ebe
This commit is contained in:
commit
8208eebce6
@ -354,7 +354,7 @@ func (c *collector) connectAndCollect(d *config.Device, ch chan<- prometheus.Met
|
|||||||
ctx := &collectorContext{ch, d, cl}
|
ctx := &collectorContext{ch, d, cl}
|
||||||
err = co.collect(ctx)
|
err = co.collect(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
log.Error("error collecting metrics")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ func newLteCollector() routerOSCollector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *lteCollector) init() {
|
func (c *lteCollector) init() {
|
||||||
c.props = []string{"current-cellid", "primary-band" ,"ca-band", "rssi", "rsrp", "rsrq", "sinr"}
|
c.props = []string{"current-cellid", "primary-band", "ca-band", "rssi", "rsrp", "rsrq", "sinr", "lac", "sector-id", "phy-cellid", "cqi", "session-uptime"}
|
||||||
labelNames := []string{"name", "address", "interface", "cellid", "primaryband", "caband"}
|
labelNames := []string{"name", "address", "interface", "cellid", "primaryband", "caband"}
|
||||||
c.descriptions = make(map[string]*prometheus.Desc)
|
c.descriptions = make(map[string]*prometheus.Desc)
|
||||||
for _, p := range c.props {
|
for _, p := range c.props {
|
||||||
@ -106,16 +106,31 @@ func (c *lteCollector) collectMetricForProperty(property, iface string, re *prot
|
|||||||
if re.Map[property] == "" {
|
if re.Map[property] == "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
v, err := strconv.ParseFloat(re.Map[property], 64)
|
|
||||||
if err != nil {
|
|
||||||
log.WithFields(log.Fields{
|
|
||||||
"property": property,
|
|
||||||
"interface": iface,
|
|
||||||
"device": ctx.device.Name,
|
|
||||||
"error": err,
|
|
||||||
}).Error("error parsing interface metric value")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.ch <- prometheus.MustNewConstMetric(desc, prometheus.GaugeValue, v, ctx.device.Name, ctx.device.Address, iface, current_cellid, primaryband, caband)
|
if property == "session-uptime" {
|
||||||
|
v, err := parseDuration(re.Map[property])
|
||||||
|
if err != nil {
|
||||||
|
log.WithFields(log.Fields{
|
||||||
|
"property": property,
|
||||||
|
"interface": iface,
|
||||||
|
"device": ctx.device.Name,
|
||||||
|
"error": err,
|
||||||
|
}).Error("error parsing interface duration metric value")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ctx.ch <- prometheus.MustNewConstMetric(desc, prometheus.CounterValue, v, ctx.device.Name, ctx.device.Address, iface, current_cellid, primaryband, caband)
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
v, err := strconv.ParseFloat(re.Map[property], 64)
|
||||||
|
if err != nil {
|
||||||
|
log.WithFields(log.Fields{
|
||||||
|
"property": property,
|
||||||
|
"interface": iface,
|
||||||
|
"device": ctx.device.Name,
|
||||||
|
"error": err,
|
||||||
|
}).Error("error parsing interface metric value")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ctx.ch <- prometheus.MustNewConstMetric(desc, prometheus.GaugeValue, v, ctx.device.Name, ctx.device.Address, iface, current_cellid, primaryband, caband)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user