Friday, June 24, 2011

Delay for a few seconds in a Batch file

This is simple:

choice /T 10 /D Y /N

Replace 10 with the number of seconds to replace.  This will return an error code of 1 (1st choice on the list) so just be aware that errorcode=1 is success for this.

Zabbix monitoring MySQL on a windows Server

In order to monitor MySQL on windows you need a few extra utilities.  I downloaded http://sourceforge.net/projects/unxutils/ 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
UserParameter=mysql.ping,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.