2023-09-17 01:06:33 +02:00
|
|
|
package influxdb
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/FreifunkBremen/yanic/runtime"
|
|
|
|
|
|
|
|
influxdb "github.com/influxdata/influxdb-client-go/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
// InsertLink adds a link data point
|
|
|
|
func (conn *Connection) InsertLink(link *runtime.Link, t time.Time) {
|
|
|
|
p := influxdb.NewPoint(MeasurementLink,
|
|
|
|
conn.config.Tags(),
|
|
|
|
map[string]interface{}{
|
|
|
|
"tq": link.TQ * 100,
|
|
|
|
},
|
|
|
|
t).
|
|
|
|
AddTag("source.id", link.SourceID).
|
|
|
|
AddTag("source.addr", link.SourceAddress).
|
|
|
|
AddTag("target.id", link.TargetID).
|
2024-07-20 00:33:16 +02:00
|
|
|
AddTag("target.addr", link.TargetAddress).
|
|
|
|
AddTag("type", link.Type.String())
|
2023-09-17 01:06:33 +02:00
|
|
|
if link.SourceHostname != "" {
|
|
|
|
p.AddTag("source.hostname", link.SourceHostname)
|
|
|
|
}
|
|
|
|
if link.TargetHostname != "" {
|
|
|
|
p.AddTag("target.hostname", link.TargetHostname)
|
|
|
|
}
|
|
|
|
conn.writeAPI[MeasurementLink].WritePoint(p)
|
|
|
|
}
|