Posted by Chris Tanner at 23 March 2016

Category: Coding, Linux, Uncategorized

Problem:

Trying to create an aggregate check in Zabbix to measure total bandwidth in a group of servers using ‘grpsum’, get status ‘Not supported’ and error message ‘Unsupported item key.’

Solution:

It’s not anywhere obvious in the docs  or after googling the error, but the item type needs to be changed from ‘Zabbix agent’ to ‘Zabbix aggregate’

Posted by Chris Tanner at 27 December 2015

Category: Linux

Problem:

Interface lag in linux mint when moving or resizing windows.

Solution:

Problem is caused by the theme needing equinox but it not being installed. MATE highlights this issue but cinnamon doesn’t. Can be solved by either installing equinox, or change to a theme that doesn’t need it.

Posted by Chris Tanner at 27 December 2015

Category: Android, Coding

Problem:

Tonnes of logcat spam in Eclipse ‘attempt to remove non jni local reference’

Solution:

edit filter configuration

^(?!.*(non-JNI)).*$

 

From http://stackoverflow.com/questions/16017356/how-to-hide-remove-filter-logs-in-the-logcat-in-eclipse-for-android

 

Posted by Chris Tanner at 27 December 2015

Category: Uncategorized

Problem:

Trying to convert from InnoDB to MyISAM for smaller RAM footprint MySQL on a tiny VPS

Solution:

adding skip-innodb on its own didn’t work, had to add:

default-storage-engine = MYISAM

skip-innodb

And then run:

CONVERT_SCRIPT=Convert_InnoDB_to_MyISAM.sql
mysql -u... -p... -AN -e"SELECT CONCAT('ALTER TABLE ',table_schema,'.',table_name,' ENGINE=MyISAM;') FROM information_schema.tables WHERE engine ='InnoDB';" > ${CONVERT_SCRIPT}
mysql -u... -p... -A < ${CONVERT_SCRIPT}

Posted by Chris Tanner at 27 December 2015

Category: Uncategorized

Problem:

Installed Windows 10, installed steam, xbox button on controller doesn’t open up Big Picture any more

Solution:

Need to disable DVR setting in the xbox application that comes with win10.

Can either login into the xbox app and disable the DVR option under settings, or if you can’t login for some reason, you can press the windows key and g in any program, and select “this is a game”, then turn off the dvr setting there.

 

Posted by Chris Tanner at 17 July 2015

Category: Uncategorized

Got a fairly unhelpful error while trying to send an email using LuaSec and LuaSocket to connect to googles SMTP servers:

555 5.5.2 Syntax error. uc3sm9880237wib.2

Turns out google doesn’t like the recipient format

‘FirstName LastName <name@example.com>’

and instead prefers just

‘<name@example.com>’

Posted by Chris Tanner at 23 March 2015

Category: Bad Drawing

Pheasant in snow. Watercolour, approx 15 hours.

pheasant in snow, watercolor

pheasant in snow, watercolor

Posted by Chris Tanner at 23 March 2015

Category: Coding, Linux

Came across this error today while trying to install luasec:

Error: Could not find expected file libssl.a, or libssl.so, or libssl.so.* for OPENSSL — you may have to install OPENSSL in your system and/or pass OPENSSL_DIR or OPENSSL_LIBDIR to the luarocks command. Example: luarocks install luasec OPENSSL_DIR=/usr/local

The solution is to find the libssl files

find / -name ‘libssl.*’

and then add the the path using OPENSSL_LIBDIR on the end of the command, e.g:

sudo luarocks install luasec OPENSSL_LIBDIR=/usr/lib/x86_64-linux-gnu/

Posted by Chris Tanner at 25 March 2014

Category: Uncategorized

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)

Posted by Chris Tanner at 17 March 2014

Category: Linux, Minecraft

So now our tunnels are set up, our round-robin SRV records are distributing our players across our VPS’s, next it would be nice if we could check the traffic passing across them, and also keep an eye on the system stats for each machine.

In this section we’re going to look at the basic structure of Zabbix, the terminology, and adding custom graphs.

Basics

Zabbix is made up of 3 parts:

Server Core
  • Receives and processes stats from each server
  • Stores the data
  • Can send alerts based on certain criteria (“triggers”)
Server Web Interface
  • Displays graphs and information about the servers
  • Can be on a separate machine from the core
Zabbix Agent
  • Runs on each of the servers you want to monitor
  • Reports the servers status to Zabbix
  • Can be customised with extra scripts

Installing zabbix core and web interface

To install Zabbix you will need a webserver and a mysql database. Your webserver can be on another machine to the one you’re installing zabbix server on, you just need to tell it where during the configuration.

Zabbix has some good documentation so I won’t re-write it, the version I used is here but feel free to use a later release, the only thing that’s important is that you don’t use the default from the apt repository: it will most likely be < v2.0 and not support interface auto discovery properly.

You will also need to enable access to port 10051 incoming to your zabbix server, either through your firewall or its iptables.

Installing zabbix agent on your servers

As above: add the repository, update,  and “apt-get install zabbix-agent”.

Few extra notes:

  • Make sure you’re on a version later than 2.0 with “zabbix-agent –version”
  • Change “Server=127.0.0.1” in /etc/zabbix/zabbix_agentd.conf to your zabbix server IP
  • Restart the agent with “/etc/init.d/zabbix_agentd restart”
  • Allow port 10050 through iptables with ” iptables -A INPUT -p tcp –dport 10050 -j ACCEPT”

Host Configuration

Assuming you’ve now installed Zabbix and aren’t screaming at me for not including more detail, you’re probably now staring at the web GUI wondering where to start. Here are the basic terms you need to know:

Items

  • Measure a specific value on the server, e.g. CPU load

Applications

  • Group Items into categories, e.g. “OS Memory” = all memory items.

Discovery Rules

  • Auto-generate new items by scanning the system for extra hard drives, interfaces, etc.

Triggers

  • Perform an event when an item matches certain criteria, e.g. send an email when CPU load exceeds 100%

Graphs

  • Self explanatory, graph an item or set of items on a host.

Screens

  • Can be used to create a page with multiple graphs.

Templates

  • Group all of the above together into a package that can be easily added to a new host with minimal extra configuration.

Add new host

New hosts can be added via configuration > Hosts > Create host

Give the host a descriptive name, add it to “linux servers” group, and enter it’s IP address. You then need to add a template to tell it what to monitor. “Template OS Linux” covers everything we need for our VPS, including an interface discovery script for our GRE tunnels.

Save your new host, and go back to Configuration > Hosts. After a few minutes you should see Status: Monitored and a green Z icon indicating that everything is fine.

If you have a grey icon, you may have not added any templates (hence nothing to monitor.

If there is a red icon then there is most likely an issue with communication to the host, hover over the red icon to see the details, check that your firewall rules are allowing the correct ports, and that the IP’s are correct.

Graphing:

If you navigate to Monitoring > Graphs and select your new host.  There should be a graph available with a name like “Network traffic on gre1”, which if you have any players connected will look something like this:

Capture

Using this page when can now switch between each host we’ve added and view the bandwidth usage on each interface. Great start, but it would be nice if we could combine the information into one place, which we’ll do with a custom graph.

Creating a custom graph

Since our MC server host has an interface for each tunnel, we can add each item for each tunnel onto a new custom graph:

Go to Configuration > Hosts and select “Graphs” on the entry for your MC server.

Select “Create Graph” in the top right corner.

You can leave everything default except the name and the Items.

Select “add items” and then select each incoming and outgoing item for your GRE interfaces. You can change any colours you want, and preview your changes in the preview tab.

Once you’re happy with the result, save the result and your new graph should appear under Monitoring > Graphs.

Capture

Screens

Depending on how many VPS’s you have and which interfaces you have selected, your graph may look a bit messy, even with some custom colours assigned to interfaces. Another option is to use a screen to display the data, with each interfaces as a separate graph, but all on the same page.

To do this go to Configuration > Screens and “Create Screen.”

Give it a name and decide an initial size, you can change it later.

Save it and it should appear in the list of screens: select your screen and you will be presented with a grid and an option to change the data for each one.

Select the data you want and you’re done, you can now view your new screen under Monitoring > Screens:

Capture

And we’re done for now. Thanks for reading, next up: traffic shaping on our VPS’s