Jump to content

[REL] Golang MTA:SA server monitoring solution


Recommended Posts

Hello everyone,
Now i preesent you simple MTA:SA server monitoring solution written in go language.
Actually this is an adoptation of Lipau3n's python 3 solution ( topic, repo ).
Via server object you can get some information like:

  • Game (mta)
  • Address string with MTA server ip address
  • Port - server main port (UDP)
  • AsePort - main MTA:SA port + 123
  • Name - server name
  • Gamemode - server mode
  • Map - server map
  • Version - mta:sa server version
  • Players - number of players on the server right now
  • Maxplayers - the maximum number of players that can join

Usage example:

package main

import (
	"fmt"

	"github.com/LuaSavage/mta-monitoring/server"
)

func main() {
	// pass server address and port
	exampleServer := server.NewServer("185.71.66.81", 22003)

	// Note that it updating fields once.
	// To update them frequently or on occasion you've to have some sort of poller
	if err := exampleServer.UpdateOnce(); err != nil {
		panic(err)
	}

	// Printing updated data in objects structure
	fmt.Printf("%+v\n", exampleServer)

	// Printing link to join mta:sa server
	fmt.Println(exampleServer.GetJoinLink())
}

Source code here: github

Edited by Miami Night Studio
  • Like 2
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...