GameServerManagers / LinuxGSM

The command-line tool for quick, simple deployment and management of Linux dedicated game servers.
https://linuxgsm.com
MIT License
4.29k stars 819 forks source link

telegraf input support #3003

Closed mspencerl87 closed 1 year ago

mspencerl87 commented 4 years ago

User Story

Is there anyway to export ./gameserver monitor metics to grafana? Or is there anyway to export metrics, server stats, uptime, players, ports etc, to telegraf?

Basic info

Further Information

Would like to monitor servers status remotely, currently the only thing I can think to monitor is systemd but this will mostly only show CPU/Memory usage

Further Reading

As an example, i run docker. I can export the docker hosts metrics via telegraf and display them in grafana like the link below. It would be awesome to be able to do this with LinuxGSM https://grafana.com/grafana/dashboards/10585 Another example https://github.com/ratibor78/srvstatus

issue-label-bot[bot] commented 4 years ago

Issue-Label Bot is automatically applying the label type: feature request to this issue, with a confidence of 0.90. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

dgibbs64 commented 4 years ago

If there is an API in a similar vein to discord telegram etc then it would be possible. Of you can post any docs about sending messages via an API then I can take a look :)

mspencerl87 commented 4 years ago

@dgibbs64 Are you familiar with Telegraf? Here is the github page https://github.com/telegraf/telegraf https://github.com/influxdata/telegraf https://www.influxdata.com/time-series-platform/telegraf/

GitHub
telegraf/telegraf
Modern Telegram Bot Framework for Node.js. Contribute to telegraf/telegraf development by creating an account on GitHub.
GitHub
influxdata/telegraf
The plugin-driven server agent for collecting & reporting metrics. - influxdata/telegraf
mspencerl87 commented 4 years ago

@dgibbs64 Generally people have been using Grafana to display metrics over the last few years. These setups generally include the following. Grafana (Visiual) + Influxdb + Telegraf (Metrics Collector)

Telegraf can work in a push or pull configuration, alot of people use telegraf on Linux/Windows systems also SNMP, IPMI etc. To pull metrics

You can see all the out of the box supported inputs here https://github.com/influxdata/telegraf/tree/master/plugins/inputs

GitHub
influxdata/telegraf
The plugin-driven server agent for collecting & reporting metrics. - influxdata/telegraf
dgibbs64 commented 4 years ago

I am aware of it but never the used it myself. If I can send stuff to an API endpoint/webhook via curl then It's pretty easy for me to setup. But don't know if that's possible here. Check out alert_discord.sh in my code for an example of what I mean.

mspencerl87 commented 4 years ago

not finding alert_discord.sh in code. Can you share a link? And thank you for the consideration.

mspencerl87 commented 4 years ago

This might be a better example https://github.com/anderssonoscar0/influxdb_srcds_exporter This guy is exporting SRCDS to influxdB This is only on CSGO, but may serve you better.

I wish i could be more help!

GitHub
anderssonoscar0/influxdb_srcds_exporter
InfluxDB Exporter for SRCDS game servers, currently working with CSGO - anderssonoscar0/influxdb_srcds_exporter
DrPsychick commented 4 years ago

I've used telegraf quite a bit, maybe I can be of help. I would also be interested in exposing useful stats to telegraf/influxdb.

What to measure/export

First we probably need to find out what data is available. I'm running ARK with LGSM and the monitor command doesn't return anything useful except the number of players online. So if that is easy to get (without installing gamedig as this enlarges my docker image by 300%), I'm happy to provide a small command that can expose it as telegraf metrics.

The second question that comes to mind is: what common metrics are available for all servers? Ideally one could have a command that works for all servers to get version, players online etc.

@dgibbs64 I'm not so familiar with the Query or RCON port. I tried using rcon (which is fast and small), but it no longer works for my ARK server. I've seen code in LGSM (gsquery) which seems obsolete. gamedig is too large for me as it requires installing nodejs. Is there an easier way to get status from the Query port?

dgibbs64 commented 4 years ago

gamedig is by far the best way to get info useful from game servers. Since game servers can be very large im not sure why increasing the size of a container and installing nodejs matters. gsquery is not obsolete and is used if gamedig is not installed, but gsquery only used to check if query is responding and not gather stats.

The main metric is player numbers and if the server is online.

DrPsychick commented 4 years ago

if number of players is the only "common" metric (and if the server is online), then I'd prefer a lightweight solution.

One can easily extend my docker image or install gamedig on the host and then create a small script to fetch the result from the log.

BUT I've figured out whats wrong with RCON, so I will fix that and use it to export online players to telegraf.

DrPsychick commented 4 years ago

@dgibbs64 most of what's inside the "details" result that you posted can directly fetched from the system (cpu, mem, disk, ...) so the only interesting metric (for me) so far is the number of players online. Maybe along with the server name/map/type.

DrPsychick commented 4 years ago

So, with the fixed RCON script, I can now read the number of online players

python3 rcon-ark.py listplayers | grep -v 'No Players Connected' | wc -l (see https://github.com/DrPsychick/docker-linuxgsm-ark)

it would indeed be great if LGSM could provide the metric generically with a command as not all games work the same. And gamedig seems to be able to provide the data, right? The only requirement would be that the command executes (or fails) fast and returns machine readable output.

> myserver status
status: online
players: 5
max_players: 10

to use that with telegraf would then be easy with a script that returns influx protocol and is executed with inputs.exec in the telegraf.conf:

#!/bin/bash
stat=$(myserver status)
online=0
if [ -n "$(echo "$stat" | grep 'status: online')" ]; then
  online=1
fi
players=$(echo "$stat" | grep ^players | cut -d: -f2)
max=$(echo "$stat" | grep ^max_players | cut -d: -f2)

echo "players,host=myhost,game=mygame online=$online,players=$players,max_players=$max $(date +%s)000000000"
GitHub
DrPsychick/docker-linuxgsm-ark
LinuxGSM + Steam ARK server base (shared image for ARK servers) - DrPsychick/docker-linuxgsm-ark
dgibbs64 commented 1 year ago

NO update on this. If there is an api endpoint that can be used to send data like the other alerting systems then it will be worth taking a look. I have no knowledge in telegraf currently so closing for now

github-actions[bot] commented 1 day ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.