cc-tweaked / CC-Tweaked

Just another ComputerCraft fork
https://tweaked.cc
898 stars 208 forks source link

JMX monitoring for CC: Tweaked #482

Closed SquidDev closed 4 years ago

SquidDev commented 4 years ago

Minecraft 1.16 now provides a JMX monitoring interface:

A new flag enable-jmx-monitoring has been added to the server.properties file which if set to true will expose an MBean with the Object name net.minecraft.server:type=Server and two attributes averageTickTime and tickTimes exposing the tick times in milliseconds

We should hook into this system and expose beans for all the various tracking fields. This should make the existing prometheus exporter largely redundant, as people can just drop in one of the many existing JMX → Prometheus ones.

SquidDev commented 4 years ago

Having had a prod at this, I'm really not sure there's a way to do it elegantly. Given the dynamic nature of computers, we'd need to register and unregister MBeans an awful lot, which is pretty vile.

SquidDev commented 3 years ago

I've added global statistics in the following commit. As mentioned above, there's not really a "nice" way of doing per-computer metrics (short of dynamically registering beans, or just returning an Int -> Long map), so that will be ignored for now.