Download:Minecraft Munin plugins

From LizardWiki, FastLizard4's wiki and website
Jump to: navigation, search

LIZARDNET FASTLIZARD4/MUNIN-PLUGINS/MINECRAFT - A set of RRDTool/Munin plugins written in PHP to graph various statistics regarding a Minecraft server.

Some captured graphs from my own Minecraft servers utilizing these plugins (click to enlarge)


Git, Download, and Source Code

GitHub Mirroring

A read-only mirror of the LizardNet Gerrit project is available on GitHub. Pull requests and issue reports are accepted there, however they will be only acted on in Gerrit (in the case of pull requests, they will be converted into patches and submitted by a developer as a new patchset in Gerrit before they are acted on). Developers with direct push access should never push directly to the GitHub repository and should instead submit their code to Gerrit. LizardNet Continuous Integration automatically pushes all commits to the master branch on LizardNet Gerrit to GitHub when the patchset is approved and merged.

Information

This is a set of plugins that can be used in tandem with Munin (or RRDTool) to graph various aspects of a Minecraft server, including:

  • Loaded chunks (overworld, Nether, and The End) (minecraft_chunks.php)
  • Loaded entities (overworld, Nether, and The End) (minecraft_entities.php)
  • Free JVM memory (minecraft_memory.php)
  • Lag (ticks per second) (minecraft_lag.php)
  • Logged in users (minecraft_users.php)

Prerequisites

The following prerequisites must be satisfied for using any of the plugins provided here, unless otherwise noted:

  • PHP CLI 5.0 or above
  • Minecraft server 1.0 or later
  • For minecraft_chunks.php, minecraft_entities.php, minecraft_lag.php, and minecraft_memory.php: CraftBukkit version 1.0 or later (instead of the vanilla Minecraft server) and the LagMeter plugin for CraftBukkit
  • RCON must be enabled in your Minecraft server configuration (instructions for doing this below)

Downloading

Directly

These plugins can be downloaded in the archive format of your choice. See the bolded links above.

From Git

These plugins can be found on the LizardNet Git repositories. Run:

# Anonymous HTTPS clone
git clone https://gerrit.fastlizard4.org/r/p/munin-plugins/minecraft.git
# ...Or if you have an account on LizardNet Gerrit and have configured in it your SSH public key:
git clone ssh://$GERRIT_USERNAME@gerrit.fastlizard4.org:1234/munin-plugins/minecraft.git

To automatically clone the Git repository to your computer.

These plugins can also be cloned from the read only GitHub mirror repository. Before you do this, though, please read the GitHub Mirroring section above for important caveats.

# Clone by SSH
git clone git@github.com:LizardNet/munin-plugins-minecraft.git
# Clone by HTTPS
git clone https://github.com/LizardNet/munin-plugins-minecraft.git

For the rest of these instructions, we'll assume that you've cloned this repository into the folder /home/username/munin-plugins, so that your local repository root is /home/username/munin-plugins/minecraft.

Installation

Enabling Minecraft RCON

Minecraft uses the Source RCON protocol for administrative communication, and these plugins leverage that functionality. You'll have to enable RCON for each Minecraft server you want to monitor:

  • Open the server's server.properties file, and append the following to the bottom of it:
   enable-rcon=true
   rcon.port=portnumber
   rcon.password=password
  • Remember to assign an unused portnumber and a random/secure password. Note these for configuring the plugin later.
  • Restart the Minecraft server. You should see messages like this when the server is done loading:
   [INFO] Starting remote control listener
   [INFO] RCON running on 0.0.0.0:portnumber

(Required only for some components) Install and configure CraftBukkit and LagMeter

If you play to use any of the plugins other than minecraft_users.php, you'll need to use the CraftBukkit server distribution to replace vanilla Minecraft and install the LagMeter plugin. Don't worry, installing CraftBukkit is quick and easy, as it's a drop-in replacement for the vanilla Minecraft server .jar. However, the CraftBukkit installation guide is beyond the scope of this document, so please see the Bukkit wiki for help with that.

If you already use CraftBukkit, or have finished installing it, now install (if you haven't already) the LagMeter plugin by navigating to the plugins/ directory of the Minecraft server and typing this command:

wget 'http://dev.bukkit.org/media/files/715/67/LagMeter.jar'

Note: The link above may occasionally change, and if it does, go to the plugin information page to get the most up-to-date installation information.

After you install LagMeter, restart your Minecraft server.

Now, regardless of whether you've just installed LagMeter or have previously had it installed, stop your CraftBukkit server as some configuration changes now need to be made in LagMeter:

  • Open the plugins/LagMeter/settings.yml file in your CraftBukkit server directory
  • Ensure that useAverage under General at the top of the file is set to true (this is the default).
  • Go down to the Commands section of the config file
  • Set both Commands.Lag.displayEntities and Commands.Lag.displayChunks to true (changing the values from the default).
  • Save the file, exit your text editor, and start CraftBukkit

Install the Munin plugins

This guide assumes that you already have Munin installed. If you need help installing Munin, please see here.

You'll need to create the symlinks Munin uses to determine what plugins to run. The installation at this point depends on how many servers you wish to monitor, so please skip to the appropriate section below:

Monitoring a single Minecraft server

If you wish to only monitor one Minecraft server, just run this command (as root):

ln -s '/home/username/munin-plugins/minecraft/minecraft_chunks.php' '/etc/munin/plugins/minecraft_chunks'

...changing the filename at the end of both paths (minecraft_chunks in this case) as necessary. You may install all the plugins provided in this distribution, or just one; this is how you choose which ones will be installed and used.

Now you need to configure Munin to connect to the server. Open the the munin-node in /etc/munin/plugin-conf.d, and append to the bottom:

   [minecraft_*]
   env.host hostname
   env.port portnumber
   env.password password

Using the same information you entered into your server.properties file above. In almost all circumstances, hostname will be localhost (the rare exception would be if Munin-Node is running on a different system from the Minecraft servers being monitored).

Once that is done, run (as root):

restart munin-node

...Wait up to five minutes, and you should see your new graphs appear!

Monitoring multiple Minecraft servers

Setting up these plugins to monitor multiple Minecraft servers is a little tricky, but still doable thanks to the way Munin works. Note that, to proceed, you'll need some unique identifier for each server you want to monitor (both for configuration and for user presentation)! It is also possible to have a different set of Munin plugins active for each server.

For this guide, we'll assume you want to monitor three servers, srv1, srv2, and srv3. You want to use all plugins to monitor srv1 and srv2, but srv3 (being vanilla) will only be using the minecraft_users plugin.

We'll start with srv1 and srv2. Run these commands as root:

ln -s '/home/username/munin-plugins/minecraft/minecraft_chunks.php' '/etc/munin/plugins/minecraft_srv1_chunks'
ln -s '/home/username/munin-plugins/minecraft/minecraft_chunks.php' '/etc/munin/plugins/minecraft_srv2_chunks'
ln -s '/home/username/munin-plugins/minecraft/minecraft_entities.php' '/etc/munin/plugins/minecraft_srv1_entities'
ln -s '/home/username/munin-plugins/minecraft/minecraft_entities.php' '/etc/munin/plugins/minecraft_srv2_entities'
#...etc...

Note how we are symlinking to each plugin multiple times, but with the server's unique identifier in the name of the symlink, and after "minecraft" but before the plugin's subject. Repeat the above as necessary, changing the name of the script (in this case, minecraft_chunks and minecraft_entities) at the end of both paths as necessary.

Finally, we only want one plugin for srv3, but since we're still monitoring multiple Minecraft servers, it still requires a unique ID in the symlink name - even if it's the only server of the set having that particular Munin plugin used:

ln -s '/home/username/munin-plugins/minecraft/minecraft_users.php' '/etc/munin/plugins/minecraft_srv3_users'

Now we need to configure Munin with the RCON details. In this case, you would do something like this:

   [minecraft_srv1_*]
   env.host hostname_srv1
   env.port portnumber_srv1
   env.password password_srv1
   env.customTitle Minecraft server srv1
   
   [minecraft_srv2_*]
   env.host hostname_srv2
   env.port portnumber_srv2
   env.password password_srv2
   env.customTitle Minecraft server srv2
   
   [minecraft_srv3_*]
   env.host hostname_srv3
   env.port portnumber_srv3
   env.password password_srv3
   env.customTitle Minecraft server srv3

Note that each Minecraft server has its own RCON connection configuration in the Munin config now (each server will have different RCON ports and should have different RCON passwords!), and that here the env.customTitle setting is used to make each server's set of graphs have identifying titles (though the env.customTitle setting is, of course, optional). The hostnames will be localhost if the Minecraft servers are running on the same server as the Munin-Node instance - i.e., almost always.

Now, just restart munin-node by running this command as root:

restart munin-node

And voila! Wait five minutes and the new graphs should appear in your Munin page!

Examples

My own Minecraft servers are monitored using these plugins, see here.

Questions? Comments? Bug reports? Pull requests?

You can email questions, comments, bug reports, and patches to munin-mc-questions-a92fe89 [ a t ] fastlizard4 [ d o_ t ] org. Note that this email address may change occasionally to stop spam.

Alternatively, (and it would be much appreciated), create an account at LizardBugs (if you don't have on already) and file a formal bug report, or submit a patch to LizardNet Code Review:

  • Go to https://gerrit.fastlizard4.org
  • Click "Sign In" and log in/create an account with your Google OpenID credentials
  • If necessary, provide your SSH public key and an email address in your user options
  • clone the git repository
  • create a working branch and checkout it
  • make your changes
  • git commit
  • git pull origin master
  • git rebase master
  • git push origin refs/for/master
  • Optionally, to return to the master branch containing already-reviewed code::
    • git checkout master
    • delete your working branch
  • wait for your patch to be reviewed!

Copyrights

LIZARDNET FASTLIZARD4/MUNIN-PLUGINS/MINECRAFT https://fastlizard4.org/wiki/Download:Minecraft_Munin_plugins by FastLizard4 and the LizardNet Munin Plugins Development Team https://gerrit.fastlizard4.org/r/#/admin/groups/17,members

Copyright (C) 2013 by FastLizard4 and the LizardNet Munin Plugins Development Team. Some rights reserved.

License GPLv3+: GNU General Public License version 3 or later (at your choice): http://gnu.org/licenses/gpl.html. This is free software: you are free to change and redistribute it at your will provided that your redistribution, with or without modifications, is also licensed under the GNU GPL.

There is NO WARRANTY FOR THIS SOFTWARE to the extent permitted by law.

This is an open source project. The source Git repositories, which you are welcome to contribute to, can be found here: https://gerrit.fastlizard4.org/r/gitweb?p=munin-plugins/minecraft.git;a=summary

Gerrit Code Review for the project: https://gerrit.fastlizard4.org/r/#/q/project:munin-plugins/minecraft,n,z

Acknowledgements

GITHUB IVKOS/MINECRAFT-QUERY-FOR-PHP https://github.com/ivkos/Minecraft-Query-for-PHP

This class was originally written by xPaw. Modifications and additions by ivkos.

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/