I am setting up a basic monitoring (with
monit) for my children's Minecraft server.
My plan is to check whether port
25565 is open but it would be nice if I could gather some more information to check if the server state, as announced, is healthy.
I tried to
nc on its port but there is no feedback to random output. I also saw that the Minecraft wiki has information about the structure of packets but it is not obvious that this can be used to check an initial connection.
Is there something like the equivalent of
EHLO for SMTP (or any other text-based protocols) to check for a Minecraft server self-announced status? I am sure there must be something since a server announces e.g. the number of available connections - though it may be part of a more sophisticated exchange between the client and the server.
I know of no purely text based protocols, but parsers exist to take the binary data from the server and make something readable out of it.
A long while ago, I used this PHP-Minecraft-Query script to push server data into a monitoring system. I don't have the code around anymore (that was a long time ago), but this may give you exactly what you need.
mcstatus is a tool written in Python that can query a Minecraft (non-Win10 edition) server for basic information about the server state such as the server version, how many player slots it has, and how many players are online. It is written and maintained by one of the Minecraft developers.