zabbix 监控Windows 下mysql

作者:admin 发布:2018-04-09 浏览:1600次


mysql_ping.vbs:

Set objFS =CreateObject("Scripting.FileSystemObject")
Set objArgs = WScript.Arguments
str1 = getCommandOutput("C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqladmin -uroot -p123 ping")     
  
If Instr(str1,"alive") > 0Then
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_status.vbs:


Set objFS = CreateObject("Scripting.FileSystemObject")
Set objArgs = WScript.Arguments
str1 = getCommandOutput("C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqladmin -uroot -p123 extended-status")     
Arg = objArgs(0)
str2 = Split(str1,"|")
  
For i = LBound(str2) to UBound(str2)
  
If Trim(str2(i)) = Arg Then   
WScript.Echo TRIM(str2(i+1))
Exit For
End If
next
  
  
Function getCommandOutput(theCommand)
  
Dim objShell, objCmdExec
Set objShell =CreateObject("WScript.Shell")
Set objCmdExec = objshell.exec(thecommand)
getCommandOutput =objCmdExec.StdOut.ReadAll
  
end Function

zabbix_agentd.win.conf配置中  UserParameter下加入




UserParameter=mysql.version,mysql -V
UserParameter=mysql.status[*], cscript/nologo e:\zabbix\mysql_status.vbs $1 
UserParameter=mysql.ping, cscript/nologo e:\zabbix\mysql_ping.vbs


Comments (0)