add map as hashed field
This commit is contained in:
8
main.go
8
main.go
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"github.com/influxdata/line-protocol/v2/lineprotocol"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"hash/fnv"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -48,11 +49,16 @@ func main() {
|
||||
|
||||
enc.StartLine("tf2server")
|
||||
enc.AddTag("address", string(ip))
|
||||
enc.AddTag("map", tStat.Map)
|
||||
enc.AddTag("name", tStat.Name)
|
||||
enc.AddField("player", lineprotocol.IntValue(int64(tStat.NumPlayers)))
|
||||
enc.AddField("maxplayer", lineprotocol.IntValue(int64(tStat.MaxPlayers)))
|
||||
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())
|
||||
fmt.Print(string(enc.Bytes()))
|
||||
}
|
||||
|
Reference in New Issue
Block a user