add map as tag
This commit is contained in:
10
main.go
10
main.go
@@ -26,7 +26,6 @@ type TF2Server string
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
server = flag.String("server", "", "comma seperated list of addresses to query")
|
server = flag.String("server", "", "comma seperated list of addresses to query")
|
||||||
oldIDs = flag.Bool("oldids", false, "use old gamedig IDs")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -49,10 +48,10 @@ 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("map", lineprotocol.MustNewValue(tStat.Map))
|
|
||||||
enc.AddField("ping", lineprotocol.IntValue(int64(tStat.Ping)))
|
enc.AddField("ping", lineprotocol.IntValue(int64(tStat.Ping)))
|
||||||
enc.EndLine(time.Now())
|
enc.EndLine(time.Now())
|
||||||
fmt.Print(string(enc.Bytes()))
|
fmt.Print(string(enc.Bytes()))
|
||||||
@@ -60,12 +59,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ip TF2Server) Stats() (*TF2Stat, error) {
|
func (ip TF2Server) Stats() (*TF2Stat, error) {
|
||||||
gameID := "teamfortress2"
|
cmd := exec.Command("gamedig", "--type", "teamfortress2", string(ip))
|
||||||
if *oldIDs {
|
|
||||||
gameID = "tf2"
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd := exec.Command("gamedig", "--type", gameID, string(ip))
|
|
||||||
bOut, err := cmd.CombinedOutput()
|
bOut, err := cmd.CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Reference in New Issue
Block a user