Getting the Zabbix MySQL template to work on a Windows host requires a little bit of tweaking.  None of this is documented in the Zabbix manual.  Fortunately, the work effort is minimal and you can you use the default Zabbix MySQL template without any changes.

What you need

  • Functioning Zabbix server installation.  All of the steps below were performed with Zabbix 3.0.2, but should work in version 2.x as well.
  • Functioning Zabbix agent installed on a Microsoft Windows server with MySQL installed.  The steps below were performed with MySQL 5.6, but should work in any 5.x release.
  • Three Unix tools – cut, grep, wc and their dependent libraries (libiconv2.dll, libintl3.dll, pcre3.dll, regex2.dll).  cut and wc can be found at http://gnuwin32.sourceforge.net/packages/coreutils.htm.  grep can be found at http://gnuwin32.sourceforge.net/packages/grep.htm.

What to do

On the Windows MySQL Host

  1. Create a MySQL user to be used by Zabbix for monitoring.
    mysql -uroot -p -e "GRANT PROCESS ON *.* TO 'zabbix'@'127.0.0.1' IDENTIFIED BY 'ZabbixPassword'";
    mysql -uroot -p -e "flush privileges"
    Set the user and password to whatever you like.  If you’re using MySQL workbench, you will need to assign the MonitorAdmin role.
  2. Copy cut, grep, wclibiconv2.dll, libintl3.dll, pcre3.dll, regex2.dll to your Windows folder (e.g C:\Windows).
  3. Append the path to the MySQL binaries to your system PATH variable.  This is done via Control Panel -> System and Security -> System -> Advanced System Settings -> Environment Variables.
    The path to the binaries will vary based on the installed version of MySQL and whether you used the installer or zip package.  For version 5.6, the default path is C:\Program Files\MySQL\MySQL Server 5.6\bin.
  4. Create two files in the same directory as your Zabbix agent configuration file – zabbix_agentd.userparams.conf and zabbix_mysql.cnf.
  5. Open zabbix_mysql.cnf and place the following in the file:
    [client]
    user = zabbix
    password = "ZabbixPassword"
    host = 127.0.0.1
    Replace the bold sections with your user name and password.  I highly recommend you enclose your password in double quotes – especially if you have special characters in your password.
  6. Open zabbix_agentd.userparams.conf and place the following in the file:
    UserParameter=mysql.status[*],mysql --defaults-extra-file="C:\Program Files\Zabbix\conf\zabbix_mysql.cnf" -N -e "show global status like '$1';" -s | cut -f2
    UserParameter=mysql.ping,mysqladmin --defaults-extra-file="C:\Program Files\Zabbix\conf\zabbix_mysql.cnf" ping | grep alive | wc -l | cut -d" " -f 7
    UserParameter=mysql.version,mysql -V
    Replaced the bold sections with the actual path to your zabbix_mysql.cnf file.
  7. Open zabbix_agentd.win.conf and search for “# Include”.  Add the following line:
    Include=C:\Program Files\Zabbix\conf\zabbix_agentd.userparams.conf
    Replace the bold section with the actual path to your zabbix_agentd.userparams.conf file.
  8. Restart the Zabbix agent service.

In the Zabbix UI

  1. Navigate to the Windows MySQL host.
  2. Associate the “Template App MySQL” Zabbix template with the host.

Conclusion

As you can see, it’s a simple process to enable MySQL monitoring within Zabbix.  There’s just a lack of documentation.  Thoughts, comments, suggestions – post below or contact me.

Leave a Reply

Your email address will not be published. Required fields are marked *