Minecraft Monitoring with Zabbix Part 2

This is just a quick update on the previous post about monitoring zabbix, and assumes you already have zabbix set up and monitoring the basic properties of your server. (if you don’t, see here.)

We’re going to add a simple php script on our minecraft server that queries the number of players online, then return this value to the zabbix server by adding it ot the agent as a UserParameter.

Adding the PHP:

No point in reinventing the wheel, so we’re going to grab  xPaw’s MinecraftQuery.class.php from here and save it on the minecraft server as “MinecraftQuery.class.php”

Then we need to add our own file which uses this one, queries our server ip and port, and returns the number:

<?php
require_once(‘MineCraftQuery.class.php’);

$Query = new MinecraftQuery( );

try
{
//$arg[1] is the argument passed in when calling the php, in this case the port
$Query->Connect( ‘127.0.0.1’, $argv[1] );

$result = $Query->GetInfo( );

echo $result[“Players”];
}
catch( MinecraftQueryException $e )
{
//return 0 if something goes wrong
echo 0;
}

unset($Query);
unset($result);
?>

Now we add a custom user parameter to the bottom of /etc/zabbix/zabbix_agentd.conf :

UserParameter=minecraft.players[*],php /home/mc/ServerQuery.php $1

The first part is the key to identify the item in zabbix server: the * in brackets tells the agent to use the values that the server is sending in place of any numbers prepended with $. This means with a single UserParameter on the agent, we can query multiple minecraft servers from the zabbix server, simply by passing a different port in with the trigger. The second part is the command to run our script, change it to match your script’s path.

Finally, on the server we need to reload the zabbix agent so it know about the new key:

/etc/init.d/zabbix-agent restart

Adding the Host Item

In the zabbix web interface, go to configuration -> Hosts, select your minecraft server and go to Item -> Create Item.

For the key, enter the key you used as a UserParamter, but replace the * with the server query port.

Thats all you need to do to add the item, but to make it a bit neater you can set the Units to “players” and create a new application group such as “minecraft players”

Here’s mine:

Capture

Repeat the above for any extra servers you have, and add all of the items to a graph to display them together (see part 1 for more on graphs) You should end up with something like this:

Capture

To link externally to your graphs you need to enable guest readonly access, and use the following address:

http://mydomain.com/zabbix/chart2.php?graphid=<graphID>

(you can find the graph ID in the URL when you are configuring the graph)

Dog dog!

Tried and failed 3 times to get an uninterrupted 25 mins for this one, so this is an hour and a half minus a lot of distractions.

I tired a bit of shading today. Turns out i had my tablet on the wrong setting so shading is really tricky, any lines that overlap in the same penstroke would get darker much quicker. I’ve sorted that out now but my shading still has much to be desired!

Here goes nothing.

I like to draw well. 

But I can’t. 
So I don’t draw at all. 
Which kind of hinders improvement.
 

I thought maybe if I had a drawing tablet I’d draw more because I’m on my computer so often, but I’ve had a Bamboo Fun for over a year now and I’ve hardly used it. I think I’m scared of people seeing what I’ve drawn and thinking its crap. 

To end this now, I’m making this blog. I’m going to spend 30 minutes every day drawing anything at all, and then post it here no matter what state it is in. The best thing that could happen is I gradually get better at drawing and less embarrassed about showing people my work. The worst that could happen is I make a shit blog. We’ll see.

Cyanogenmod on HP Touchpad

I had a bit of time today, so I decided to update my HP Touchpad to the ICS version of Cyanogenmod. As usual, the nice easy guide didn’t work for me, and I ended up faffing around for ages trying to work out why.


The point I got stuck at was step 10 of the guide:

type: novacom boot mem:// < ACMEInstaller2 into the command line.

The problem here was that instead of it starting the update process as desired, it instead simply said “no device found.” Turns out that the novacom drivers didn’t install properly, or windows didn’t like them. I found this handy tool which auto detects and installs the drivers, however that didn’t work either. 

Manually installing the driver in Device Manager also failed miserably, so I was pulling my hair out slightly.

In the end I found this page with some slightly different drivers, and success! The drivers finally worked and ACMEInstaller2 ran successfully.

I hope this helps anyone else out there who might come across the same issue.

Chicken Chow Mein

For this recipe I pretty much followed the BBC recipe word for word, so there’s no point in repeating it.
I was very surprised at how quick and easy this recipe was, and how good it tasted! I made double and have frozen half, I’ll find out soon how well it withstands being frozen.

First!

First and potentially last post in my blog, as my attention span is very short. I’ll mostly be posting about things that interest me, and solutions I’ve found to problems that always seem to plague me, I’ll also be posting a few recipes and other bits of pieces that other people may find useful.