diff --git a/main.go b/main.go index e3aaaa1..ae6f6b2 100644 --- a/main.go +++ b/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())) }