add map as hashed field
This commit is contained in:
8
main.go
8
main.go
@@ -6,6 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/influxdata/line-protocol/v2/lineprotocol"
|
"github.com/influxdata/line-protocol/v2/lineprotocol"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"hash/fnv"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -48,11 +49,16 @@ func main() {
|
|||||||
|
|
||||||
enc.StartLine("tf2server")
|
enc.StartLine("tf2server")
|
||||||
enc.AddTag("address", string(ip))
|
enc.AddTag("address", string(ip))
|
||||||
enc.AddTag("map", tStat.Map)
|
|
||||||
enc.AddTag("name", tStat.Name)
|
enc.AddTag("name", tStat.Name)
|
||||||
enc.AddField("player", lineprotocol.IntValue(int64(tStat.NumPlayers)))
|
enc.AddField("player", lineprotocol.IntValue(int64(tStat.NumPlayers)))
|
||||||
enc.AddField("maxplayer", lineprotocol.IntValue(int64(tStat.MaxPlayers)))
|
enc.AddField("maxplayer", lineprotocol.IntValue(int64(tStat.MaxPlayers)))
|
||||||
enc.AddField("ping", lineprotocol.IntValue(int64(tStat.Ping)))
|
enc.AddField("ping", lineprotocol.IntValue(int64(tStat.Ping)))
|
||||||
|
|
||||||
|
// hash map to convert it to int
|
||||||
|
h := fnv.New32a()
|
||||||
|
h.Write([]byte(tStat.Map))
|
||||||
|
enc.AddField("map", lineprotocol.UintValue(uint64(h.Sum32())))
|
||||||
|
|
||||||
enc.EndLine(time.Now())
|
enc.EndLine(time.Now())
|
||||||
fmt.Print(string(enc.Bytes()))
|
fmt.Print(string(enc.Bytes()))
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user