2017-06-01 20:52:14 +00:00
|
|
|
package graphite
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/FreifunkBremen/yanic/runtime"
|
|
|
|
"github.com/fgrosse/graphigo"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (c *Connection) InsertGlobals(stats *runtime.GlobalStats, time time.Time) {
|
|
|
|
c.addPoint(GlobalStatsFields(stats))
|
|
|
|
c.addCounterMap(CounterMeasurementModel, stats.Models, time)
|
|
|
|
c.addCounterMap(CounterMeasurementFirmware, stats.Firmwares, time)
|
|
|
|
}
|
|
|
|
|
|
|
|
func GlobalStatsFields(stats *runtime.GlobalStats) []graphigo.Metric {
|
|
|
|
return []graphigo.Metric{
|
|
|
|
{Name: MeasurementGlobal + ".nodes", Value: stats.Nodes},
|
|
|
|
{Name: MeasurementGlobal + ".gateways", Value: stats.Gateways},
|
|
|
|
{Name: MeasurementGlobal + ".clients.total", Value: stats.Clients},
|
|
|
|
{Name: MeasurementGlobal + ".clients.wifi", Value: stats.ClientsWifi},
|
|
|
|
{Name: MeasurementGlobal + ".clients.wifi24", Value: stats.ClientsWifi24},
|
|
|
|
{Name: MeasurementGlobal + ".clients.wifi5", Value: stats.ClientsWifi5},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Connection) addCounterMap(name string, m runtime.CounterMap, t time.Time) {
|
|
|
|
var fields []graphigo.Metric
|
|
|
|
for key, count := range m {
|
2017-08-06 10:39:16 +00:00
|
|
|
fields = append(fields, graphigo.Metric{Name: name + `.` + replaceInvalidChars(key) + `.count`, Value: count, Timestamp: t})
|
2017-06-01 20:52:14 +00:00
|
|
|
}
|
|
|
|
c.addPoint(fields)
|
|
|
|
}
|