Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minecraft input plugin isn't loading metrics #6287

Closed
AWegnerGitHub opened this issue Aug 20, 2019 · 12 comments · Fixed by #6315
Closed

Minecraft input plugin isn't loading metrics #6287

AWegnerGitHub opened this issue Aug 20, 2019 · 12 comments · Fixed by #6315
Assignees
Labels
bug unexpected problem or unintended behavior
Milestone

Comments

@AWegnerGitHub
Copy link

Relevant telegraf.conf:

[[inputs.minecraft]]
  ## Address of the Minecraft server.
  server = "192.168.10.187"
  ## Server RCON Port.
  port = "25575"
  ## Server RCON Password.
  password = "AREALPASSWORD"
  [inputs.minecraft.tags]
    influx_database = "telegraf_server"

System info:

No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.3 LTS
Release:	18.04
Codename:	bionic

Telegraf version: 1.11.4-1 (installed via apt-get)
Minecraft server: 1.14.4
Only plugins installed on minecraft are EssentialsX and Dynmap.
Rcon is enabled. Correct password, port and host are provided.
Scoreboard is set up and objectives can be seen in game.

Steps to reproduce:

  1. Enabled minecraft telegraf plugin with the configuration above
  2. Restarted Telegraf
  3. Logged into Minecraft server. Checked score board and see that results are changing as expected
  4. Check influxdb for minecraft measurements. Nothing.

Expected behavior:

Minecraft measurements would be sent to influxdb like all my other metrics. None of those metrics are failing unexpectedly.

Actual behavior:

No minecraft measurements are sent.

Additional info:

Minecraft plugin is listed as being loaded in the telegraf log:

2019-08-20T19:24:45Z I! Loaded inputs: diskio minecraft exec internal cpu disk kernel mem processes swap system influxdb zfs snmp snmp snmp

Doing a test run of telegraf doesn't show any minecraft metrics:

$ sudo -u telegraf telegraf --config /etc/telegraf/telegraf.conf --test --input-filter=minecraft
2019-08-20T19:52:54Z I! Starting Telegraf 1.11.4

(Other filtered metrics product a result)

No errors are appearing in

$ sudo journalctl -u telegraf
Aug 20 14:24:45 mc-server systemd[1]: Started The plugin-driven server agent for reporting metrics into InfluxDB.
Aug 20 14:24:45 mc-server telegraf[18978]: 2019-08-20T19:24:45Z I! Starting Telegraf 1.11.4

All of my other metrics are loading as expected and are using [inputs.*.tags]

@danielnelson danielnelson added the bug unexpected problem or unintended behavior label Aug 20, 2019
@danielnelson danielnelson self-assigned this Aug 20, 2019
@danielnelson
Copy link
Contributor

I think rcon must be setup correctly because there are no errors, but can you check the minecraft log file for something like this:

[14:49:34] [Server thread/INFO]: Starting remote control listener
[14:49:34] [RCON Listener #1/INFO]: RCON running on 0.0.0.0:25575

When you start Telegraf there should be a log message for the new connection:

[14:49:40] [RCON Listener #1/INFO]: Rcon connection from: /127.0.0.1

If that looks okay, can you run these commands using one of your actual players and attach the output?

/scoreboard players list
/scoreboard players list Etho

@AWegnerGitHub
Copy link
Author

I see a connection attempt when I restart telegraf:

[22:21:00] [RCON Listener #1/INFO]: Rcon connection from: /192.168.10.150

I only see this once though. I do not see it everytime telegraf should be collecting metrics.

In game I issue this:

[22:28:19] [Server thread/INFO]: InsaneMosquito issued server command: /scoreboard players list

I get a response saying:

There are 1 tracked entities: InsaneMosquito

(this is a new server set up, so only me so far)

In game I issue this:

/scoreboard players list InsaneMosquito

I get a response showing my scores (just the demo jumps set up so far)

InsaneMosquito has 1 scores:
[jumps]: 62

@danielnelson
Copy link
Contributor

Telegraf does reuse the connection each interval, so it's normal to see only a single connection. All the output looks as expected too.

Would you be able to do a packet capture with tcpdump and attach the output file rcon.pcap?

sudo apt-get install tcpdump
# run this in the background and run `telegraf --input-filter minecraft --test`
sudo tcpdump -s0 -i eth0 -w rcon.pcap 'tcp port 25575'

You may want to reset the rcon password to a temporary password first, because it will be visible in the packet capture.

@AWegnerGitHub
Copy link
Author

That didn't return anything when I run

sudo -u telegraf telegraf --config /etc/telegraf/telegraf.conf --input-filter minecraft --test

I do get a pcap when I run the python rcon script though. I can attach that it if help, but I am assuming it doesn't right now.

Could it be related to the tags?

[inputs.minecraft.tags]
  influx_database = "telegraf_server"

That is the same thing as I have for other metrics like this (and they work).

# Read metrics about system load & uptime
[[inputs.system]]
  # no configuration
  [inputs.system.tags]
    influx_database = "telegraf_server"

@danielnelson
Copy link
Contributor

I'm surprised nothing is picked up since we know Telegraf is at least making the connection. Perhaps it will be easier if you run this build of Telegraf with extra logging added:

Run it with the --debug flag:

telegraf --input-filter minecraft --test --debug

@AWegnerGitHub
Copy link
Author

I am sorry. I'm not sure how to best install that version without messing up the 1.11 version I have currently installed. apt doesn't see it as an available version yet. Do you have a quick guide I can follow to temporarily switch to this?

@danielnelson
Copy link
Contributor

I think the standalone tar package will be best for this, this way you don't need to replace your existing setup:

wget https://39423-33258973-gh.circle-artifacts.com/0/build/linux/amd64/telegraf-1.12.0~eb87104e_linux_amd64.tar.gz
tar xf telegraf-1.12.0~eb87104e_linux_amd64.tar.gz
./telegraf/usr/bin/telegraf --config /etc/telegraf/telegraf.conf --test --input-filter=minecraft --debug

@AWegnerGitHub
Copy link
Author

Thanks for those instructions.

Output with 1.12:

2019-08-24T03:20:52Z I! Starting Telegraf 
2019-08-24T03:20:52Z E! Unable to open /var/log/telegraf/telegraf.log (open /var/log/telegraf/telegraf.log: permission denied), using stderr
2019-08-24T03:20:52Z D! [agent] Initializing plugins
2019-08-24T03:20:52Z D! [inputs.minecraft] Authorized
2019-08-24T03:20:52Z D! [inputs.minecraft] Connected
2019-08-24T03:20:52Z D! [inputs.minecraft] /scoreboard players list: "Unknown command. Type \"/help\" for help.\n"
2019-08-24T03:20:52Z D! [inputs.minecraft] Players []

I issued the same command in game:

/scoreboard players list 

It returns the same result as before:

There are 1 tracked entities: InsaneMosquito

I also don't see anything with the tcpdump.

@danielnelson
Copy link
Contributor

You mentioned a python rcon script earlier, which one are you using and can you run /scoreboard players list using it?

Since you have a few mods, are you using Spigot?

@AWegnerGitHub
Copy link
Author

AWegnerGitHub commented Aug 24, 2019

I am using mcrcon

In the example provided in their docs, they have the command to run like this:

resp = mcr.command("/scoreboard players list")

This returns the same Unknown command error above. However, removing the leading slash works as expected.

resp = mcr.command("scoreboard players list")

I am using spigot.

This server is running CraftBukkit version git-Spigot-798ea6a-2012f1e (MC: 1.14.4) (Implementing API version 1.14.4-R0.1-SNAPSHOT)

I just followed the instructions to get BuildTools and then built is using java -jar BuildTools.jar --rev 1.14.4

My full mcrcon test script:

from mcrcon import MCRcon

with MCRcon("192.168.10.187", "AREALPASSWORD", 25575) as mcr:
    resp = mcr.command("scoreboard players list")
    print(resp)
    print("-----------")
    resp = mcr.command("scoreboard players list InsaneMosquito")
    print(resp)

@danielnelson
Copy link
Contributor

Must be a difference between Spigot and the Vanilla server, I was able to replicate and it looks like the fix is as easy as just removing the / from the commands. This seems to work in both servers for me. Here is a build with the change for testing:

If this works for you then we can add the fix to 1.11.5 which should be released on Tuesday.

@danielnelson danielnelson added this to the 1.11.5 milestone Aug 24, 2019
@AWegnerGitHub
Copy link
Author

It works!

Thank you for helping figure out the issue and for planning it's release so quickly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants