Category Archives: Calzada Media

Monitoring MySQL with Zabbix using the appaloosa-zabbix-templates

The standard MySQL Templates for Zabbix are a little basic and I admit I never really got them to work properly.  Thankfully, the Appaloosa Zabbix Templates are available that are based on the excellent Percona Monitoring Plugins.

As always, this is how I got this to work.  If you have any suggestions or improvements, get in touch.

Initial Work

On Ubuntu, some additional Perl modules are required:

$ apt-get install libxml-simple-perl libdatetime-perl

You also need to create some directories

$ mkdir /usr/local/zabbix
$ mkdir /usr/local/zabbix/plugins
$ mkdir /usr/local/zabbix/agent.d
Generating the Template

Download the source from Google Project Hosting

$ wget http://appaloosa-zabbix-templates.googlecode.com/files/appaloosa-zabbix-templates-0.0.1.tgz

Extract the source by running

$ tar -zxvf appaloosa-zabbix-templates-0.0.1.tgz

Open the extracted folder and generate the template XML

$ cd appaloosa-zabbix-templates-0.0.1
$ perl tools/gen_template.pl defs/mysql.pl mysql.xml

Copy the generated file, mysql.xml, to the /usr/local/zabbix/plugins directory

$ cp mysql.xml /usr/local/zabbix/plugins
Creating the Config File

Now create the agent’s config file by editing conf/mysql_agentd.conf using the sed command.

$ sed -e 's|$ZABBIX_AGENT_PATH|/usr/local/zabbix/plugins|' conf/mysql_agentd.conf > mysql.conf

Copy the new config file to the /usr/local/zabbix/config.d directory

$ cp mysql.conf /usr/local/zabbix/config.d

Open the Zabbix Agent configuration file

$ nano /usr/local/etc/zabbix_agentd.conf

Add the following line

Include=/usr/local/zabbix/agent.d
Restart the Zabbix Agent
$ service zabbix-agent restart
Creating a MySQL User

Connect to mysql using the command: (you will be prompted for the root’s password)

$ mysql --u root -p mysql

Create the new user

mysql> CREATE USER 'zabbixmonitor'@'localhost' IDENTIFIED BY 'password';

Grant privileges to the user

mysql> GRANT SELECT, SUPER, PROCESS ON *.* TO 'zabbixmonitor'@'localhost';

Reload all privileges:

mysql> FLUSH PRIVILEGES;

Exit mysql

mysql> quit

Alternatively, you can use a UI tool like Webmin if it is installed on your server.

Configuring the PHP Script

The template requires a PHP file from the original Cacti template.  Download and extract the latest version of the Cacti Templates using

$ wget http://mysql-cacti-templates.googlecode.com/files/better-cacti-templates-1.1.8.tar.gz
$ tar -zxvf better-cacti-templates-1.1.8.tar.gz

Copy the file scripts/ss_get_mysql_stats.php to /usr/local/zabbix/plugins

$ cp better-cacti-templates-1.1.8/scripts/ss_get_mysql_stats.php /usr/local/zabbix/plugins

Open ss_get_mysql_stats.php for editing

$ nano /usr/local/zabbix/plugins/ss_get_mysql_stats.php

Change the values of $mysql_user and $mysql_pass to that of the mysql user created above

$mysql_user = 'zabbixmonitor';
$mysql_pass = '12345678';

Save and close the file

Import the Template

If you generated the mysql.xml on the Zabbix server, you need to download it to your client computer.

Once you have the file, log into Zabbix and go to Configuration > Templates

Click on the Import button in the top right

Click on Choose File to select mysql.xml and then click on Import

If successful, you should see the message Template Imported

Adding the template to a host

In Zabbix, go to Configuration > Hosts

Click on the host to add the template

Select the Templates tab

Click on Add and select template_mysql from the list

Click on Select and then Save

Troubleshooting

If you don’t get any data, check the Zabbix agent’s log.  The logfile’s path is defined in the agent’s configuration file, but the default are:

  • Linux: /tmp/zabbix_agent.log
  • Windows: c:\zabbix\zabbix_agentd.log

Don’t forget, if you make any changes to the configuration file, you will need to restart the agent for them to take effect.

References

Appaloosa Installation Notes: http://code.google.com/p/appaloosa-zabbix-templates/wiki/Installation

Buxxnt: http://buzznt.blogspot.co.uk/2011/09/install-zabbix-mysql-plugin-imported.html

 

The return of LeafURL

Nearly a year ago I wrote a URL Shortening service called LeafURL.  This was part intellectual exercise and part fun – part of me just wanted to build something other than a “standard” website.  As with most spur of the moment ideas, it took longer than expected to complete.  I did include some extra bells and whistles including graphical reports using the Microsoft Chart Controls.

A few weeks ago, I decided to give LeafURL an annual service and to improve its’ overall integration with the Calzada Media website.  A few scratchings of the head later punctuated with quite a few what on earth did I do here? and version 2 of LeafURL has appeared.  With version 2, LeafURL is now powered by the UrlShortener module for Camino CMS, Calzada Media’s own content management system.  Outwardly, there are few visual changes, but by using the latest version of Camino, LeafURL is now more stable and robust than before.

The newly refurbished LeafURL is now available and is free to use by anyone.

IIS FastCGI Fatal Error: Allocated memory size exhausted

Traditionally IIS and PHP have not mixed particularly well.  Things have gotten a lot better since the arrival of FastCGI and the Web Platform Installer, but there are still occasions when something occurs which flummoxes an ASP.Net guy like myself.

I recently moved this blog onto a Windows 2008 R2 server running IIS 7.5.  I’ll admit that I wasn’t really expecting any problems as I had already moved a MyBB forum onto the same server without any problems.  My normal level of IT paranoia had taken a leave of absence as I made the assumption that MyBB would be a far more demanding PHP application than WordPress, so there shouldn’t be any issues.

You know what they say about assumptions?  After all the data and files had been migrated I fired up my browser and initially got a blank page in return.  By default, FastCGI PHP does not return error messages – it is after all running on a production server.  So I dropped the following code into the top of the wp-config.php to manually enable errors.

ini_set('display_errors',true);

This duly returned the following error message:

Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 261904 bytes) in C:\inetpub\HostingSpaces\alexanderjohn\alexanderjohn.co.uk\wwwroot\wp-includes\functions.php on line 2109

Now, any quick Google search on this will immediately return a series of results all recommending the solution being to increase the memory_limit value in the php.ini from 128MB as the likely source is probably memory leaks in PHP.  This did seem a little counter intuitive – does WordPress really need that much memory?  I duly increase it several times, and each time I got a variation on the above error – all that changed was the Allowed memory size value increased to match the memory_limit value.

My next step was to check the various application pool settings.  They were all fine, and the site still refused to work with a new, dedicated pool.

Realistically, this only left WordPress as the culprit.  I duly downloaded the latest version and performed a manual upgrade.  Still no luck.

I then stripped out all the additional plugins and themes that were installed, and Hey Presto!, there was life.

I don’t know which plugin caused the problem as I have taken this opportunity to re-evaluate every plugin I was using.  This is something that I hadn’t done in a while, and to be honest, was well overdue.

As for the root core cause.  I would suspect that this down to some form of infinite loop.  If it is so, I am amazed that some developers are still adding iterations without some form of safety net.  At Calzada, it is actually part of our coding practice that any loop that has the potential of going infinite has some form of safety net.  At the end of the day, it is very hard to look professional to a customer when a product fails because of a very simple coding error.

Setting up a forum – not as easy as you might think

Several of years ago, when working for a now defunct company, a customer wanted to add a forum to his website.  That’s easy the boss said, and a colleague duly installed one of the many free to use forums.  As we weren’t managing the forum beyond the installation of the software, we paid little or no heed to the initial configuration of the forum.  As a casual forum visitor, I guess I assumed that starting up a forum would just as easy as using it.

I was wrong.  In the last couple of weeks, Calzada Media has been working towards the launch of a new online forum for the local cricket community called LegStump.  LegStump is all about building online cricket communities between the grass roots supporters and players: the local village and community teams who play cricket for simple enjoyment.

It would have been easy to upload any forum software and then configure it on the hoof.  Such an approach doesn’t mean you’re doing anything especially wrong but you are lining yourself for some potentially big problems in the future.

So, we took the other road and took our time applying the normal Calzada project management processes.  Only when we were happy with a version of the forum running on our development servers, did we even consider moving it into the live environment.

With our experience fresh in the memory, here are our recommendations for those, like us, starting our with their first forum:

Choose your forum software wisely

This will be your biggest and most important choice.  Once you have deployed a forum, migrating to a different software package is a challenging prospect, not only for you, but also for your members.

Based on our experience, we advise:

  • Be aware of your limitations and knowledge – For example, don’t use a Perl based forum if you have never used Perl.
  • Taken into consideration the hosting platform upon which you will run your forum.  If you already have web hosting, then bear in mind your package’s functionality and capabilities.  If you don’t have hosting, you do need to consider potential hosting costs.
  • Look for a consistent and high quality user experience for all grades of members.
  • Can the forum software be extended?  Are there a good range of modifications, plugins and themes available?
  • How easy and capable are the forum’s management capabilities?

Whatever software you choose, be sure to evaluate the software prior to deployment.  With LegStump, there were a number of forums we liked but it was through testing and evaluation we narrowed down our choice to MyBB.

Prepare and publish your rules, guidelines and legal notices

This is an area that often overlooked.  Without stated rules and guidelines, you run the very real risk of losing control of the discussions and content on your forum.  You should not only clearly define your forum’s rules and guidelines, but also place them at a location where everyone including non-members can read them.

At LegStump, we currently operate under four principal legal documents:

It is also worth noting that these rules and guidelines apply to all users irrespective of their roles or positions within the forum.

Design

The wrong design or theme will drive members away as quickly as the improper choice of forum software.  You chosen design should:

  • Reflect the tone of your forum’s content
  • Be easy on the eye – no big clashes of colour
  • Not unduly affect the performance of the software

Enhance the capabilities of your forum with plugins 

Do check out the range of modifications or plugins that are available for your chosen forum software.  You may be surprised just what are available and how they will enhance your forum.

With LegStump, we have utilised nearly 10 mods to improve both the user experience and also management capabilities.