Friday, June 24, 2011

Zabbix monitoring MySQL on a windows Server

In order to monitor MySQL on windows you need a few extra utilities.  I downloaded and used the cut, wc, and grep utilities out of that.

Then add the following lines to your agentd configuration file:

UserParameter=mysql.queries[*],mysql -u root -ptest -N -e "show global status like 'Com_$1'" -s | cut -f2,mysqladmin -uroot -ptest ping | grep alive | wc -l | cut -d" " -f 7
UserParameter=mysql.uptime,mysqladmin -uroot -ptest status | cut -d: -f2 | cut  -d " " -f2
UserParameter=mysql.threads,mysqladmin -uroot -ptest status | cut -d: -f3 | cut  -d " " -f2
UserParameter=mysql.questions,mysqladmin -uroot -ptest status | cut -d: -f4 | cut  -d " " -f2
UserParameter=mysql.slowqueries,mysqladmin -uroot -ptest status | cut -d: -f5 | cut  -d " " -f2
UserParameter=mysql.qps,mysqladmin -uroot -ptest status | cut -d: -f9 | cut  -d " " -f2
UserParameter=mysql.version,mysql -V
 Replace test with the root@localhost password for your MySQL box.  Once you have done this you can use the Template_App_MySQL to monitor all of those UserParameters.  I ended up making a clone of that template so that I could change the service from "mysql" to "mysqld.exe" in order to monitor it.

1 comment:

Mohamed Azzaki said...

Thanks very much for this valuable guide,,

I have applied these steps for MySQL 5.1 service on Windows 2003 server, but I faced the following problem:

If I start the zabbix agent while MySQL service is running I see that the trigger of "MySQL is down" is enabled without error.

If I stop MySQL service; the following error message is appearing in "MySQL is down" trigger:

Received value [ mysqladmin: connect to server at 'localhost' failederror: 'Can't connect to MySQL server on 'localhost' (10061)

Do you have any idea about this issue?

Best Regards