Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Collect more metrics from LTE interfaces #162

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ func (c *collector) connectAndCollect(d *config.Device, ch chan<- prometheus.Met
ctx := &collectorContext{ch, d, cl}
err = co.collect(ctx)
if err != nil {
return err
log.Error("error collecting metrics")
}
}

Expand Down
37 changes: 26 additions & 11 deletions collector/lte_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func newLteCollector() routerOSCollector {
}

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"}
c.descriptions = make(map[string]*prometheus.Desc)
for _, p := range c.props {
Expand Down Expand Up @@ -106,16 +106,31 @@ func (c *lteCollector) collectMetricForProperty(property, iface string, re *prot
if re.Map[property] == "" {
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")

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)
}

ctx.ch <- prometheus.MustNewConstMetric(desc, prometheus.GaugeValue, v, ctx.device.Name, ctx.device.Address, iface, current_cellid, primaryband, caband)
}