2017-09-27 13:55:02 +02:00
|
|
|
package influxdb
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/FreifunkBremen/yanic/runtime"
|
2019-01-15 20:19:55 +01:00
|
|
|
models "github.com/influxdata/influxdb1-client/models"
|
2017-09-27 13:55:02 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
// InsertLink adds a link data point
|
|
|
|
func (conn *Connection) InsertLink(link *runtime.Link, t time.Time) {
|
|
|
|
tags := models.Tags{}
|
|
|
|
tags.SetString("source.id", link.SourceID)
|
2017-12-05 23:17:49 +01:00
|
|
|
tags.SetString("source.addr", link.SourceAddress)
|
2017-09-27 13:55:02 +02:00
|
|
|
tags.SetString("target.id", link.TargetID)
|
2017-12-05 23:17:49 +01:00
|
|
|
tags.SetString("target.addr", link.TargetAddress)
|
2021-03-26 10:18:29 +01:00
|
|
|
if link.SourceHostname != "" {
|
|
|
|
tags.SetString("source.hostname", link.SourceHostname)
|
|
|
|
}
|
|
|
|
if link.TargetHostname != "" {
|
|
|
|
tags.SetString("target.hostname", link.TargetHostname)
|
|
|
|
}
|
2017-09-27 13:55:02 +02:00
|
|
|
|
2017-12-05 23:17:49 +01:00
|
|
|
conn.addPoint(MeasurementLink, tags, models.Fields{"tq": link.TQ * 100}, t)
|
2017-09-27 13:55:02 +02:00
|
|
|
}
|