track zeros
This commit is contained in:
parent
0cb2350735
commit
faae635c0c
|
|
@ -42,8 +42,8 @@ func (u *UnifiPoller) LogExportReport(report *promunifi.Report) {
|
|||
|
||||
u.Logf("UniFi Measurements Exported. Sites: %d, Clients: %d, "+
|
||||
"Wireless APs: %d, Gateways: %d, Switches: %d%s, Descs: %d, "+
|
||||
"Metrics: %d, Errors: %d, Elapsed: %v",
|
||||
"Metrics: %d, Errors: %d, Zeros: %d, Elapsed: %v",
|
||||
len(m.Sites), len(m.Clients), len(m.UAPs), len(m.UDMs)+len(m.USGs),
|
||||
len(m.USWs), idsMsg, report.Descs, report.Total, report.Errors,
|
||||
report.Elapsed.Round(time.Millisecond))
|
||||
report.Zeros, report.Elapsed.Round(time.Millisecond))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ type metricExports struct {
|
|||
type Report struct {
|
||||
Total int
|
||||
Errors int
|
||||
Zeros int
|
||||
Descs int
|
||||
Metrics *metrics.Metrics
|
||||
Elapsed time.Duration
|
||||
|
|
@ -140,22 +141,29 @@ func (u *unifiCollector) exportMetrics(ch chan<- prometheus.Metric, r *Report) {
|
|||
for _, m := range newMetrics {
|
||||
r.Total++
|
||||
descs[m.Desc] = true
|
||||
var value float64
|
||||
switch v := m.Value.(type) {
|
||||
case unifi.FlexInt:
|
||||
ch <- prometheus.MustNewConstMetric(m.Desc, m.ValueType, v.Val, m.Labels...)
|
||||
value = v.Val
|
||||
case float64:
|
||||
ch <- prometheus.MustNewConstMetric(m.Desc, m.ValueType, v, m.Labels...)
|
||||
value = v
|
||||
case int64:
|
||||
ch <- prometheus.MustNewConstMetric(m.Desc, m.ValueType, float64(v), m.Labels...)
|
||||
value = float64(v)
|
||||
case int:
|
||||
ch <- prometheus.MustNewConstMetric(m.Desc, m.ValueType, float64(v), m.Labels...)
|
||||
value = float64(v)
|
||||
|
||||
default:
|
||||
r.Errors++
|
||||
if u.Config.ReportErrors {
|
||||
ch <- prometheus.NewInvalidMetric(m.Desc, fmt.Errorf("not a number: %v", m.Value))
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
if value == 0 {
|
||||
r.Zeros++
|
||||
}
|
||||
ch <- prometheus.MustNewConstMetric(m.Desc, m.ValueType, value, m.Labels...)
|
||||
}
|
||||
r.wg.Done()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue