arkmanager / ark-server-tools

Set of server tools used to manage ARK: Survival Evolved servers on Linux
MIT License
677 stars 143 forks source link

ARK server info #57

Closed klightspeed closed 8 years ago

klightspeed commented 9 years ago

What are your thoughts on either having an info command or integrating into the status command basic server info (i.e. server name including version, and number of players)?

So far, the only cross-distribution way that doesn't involve compiling a program uses either python or perl. Both can take their scripts as multi-line strings arguments.

I looked at bash networking, but it's compiled out on a lot of distributions.

nc isn't universal, and sometimes ncat will be installed instead of nc.

If python or perl are not present, then the distribution must be very limited indeed.

python:

python -c "
import socket

try:
  sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  sock.settimeout(1.0)
  sock.sendto('\xff\xff\xff\xffTSource Engine Query\x00', ('127.0.0.1', ${ark_QueryPort}))
  data, addr = sock.recvfrom(1400)
  servername, mapname, game, fullname, rest = data[6:-1].split('\0', 4)
  players = ord(rest[2])
  maxplayers = ord(rest[3])
  print('Server Name: {0}'.format(servername))
  print('Players: {0} / {1}'.format(players, maxplayers))
except:
  print('Unable to query server')
"

perl:

perl -e "my \$port = ${ark_QueryPort}" -e '
use Socket;

socket(my $socket, PF_INET, SOCK_DGRAM, 0);
setsockopt($socket, SOL_SOCKET, SO_RCVTIMEO, pack("i4", 1, 0, 0, 0));
my $sockaddr = pack_sockaddr_in($port, inet_aton("127.0.0.1"));
send($socket, "\xff\xff\xff\xffTSource Engine Query\x00", 0, $sockaddr);
my $data = "";
recv($socket, $data, 1400, 0) or (print "Unable to query server\n" and exit(1));
my ($servername, $mapname, $game, $fullname, $rest) = split(/\x00/, substr($data, 6), 5);
my $players = ord(substr($rest, 2, 1));
my $maxplayers = ord(substr($rest, 3, 1));
print "Server Name: $servername\n";
print "Players: $players / $maxplayers\n";
'
FezVrasta commented 9 years ago

I think I'd prefer the perl version, I'm not sure if it should be part of arkmanager or be a different script of the ARK Server Tools tho

FezVrasta commented 9 years ago

Maybe we could even prepare a small node.js web app to provide a web interface to show these values. Without have to ask our users to configure nginx and so on.

Sispheor commented 9 years ago

We should wait for official RCON command to do that.

Sispheor commented 9 years ago

RCON is coming. http://steamcommunity.com/app/346110/discussions/0/594820656447032287/

FezVrasta commented 9 years ago

yey :D

Atriusftw commented 9 years ago

And an administration UI even! I like what i'm seeing.

Sispheor commented 8 years ago

This can be closed, doesn't it?

klightspeed commented 8 years ago

Yes, the main feature in this issue has been fulfilled.

The Admin UI suggested by @FezVrasta would be a separate feature.