简言
上篇文章结合了Percona监控了Linux下的Mysql效果非常好,监控项非常多。这里我们也需要记录一片监控Window下Mysql的文章。百度搜索了一下发现大部分监控也都是使用脚本进行监控的,用的模板也是zabbix自带的,并没有说结合Percona的方式的。这里咱们使用上述方法来实践一下。
一、编写VBS脚本
1.我们需要在zabbix下面建立一个文件夹用来存放脚本
第一个脚本mysql-ping.vbs
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objArgs = WScript.Arguments
str1 = getCommandOutput("C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqladmin -u root -p123456 ping")
If Instr(str1,"alive") > 0 Then
WScript.Echo 1
Else
WScript.Echo 0
End If
Function getCommandOutput(theCommand)
Dim objShell, objCmdExec
Set objShell = CreateObject("WScript.Shell")
Set objCmdExec = objshell.exec(thecommand)
getCommandOutput = objCmdExec.StdOut.ReadAll
end Function
第二个脚本mysql-stat