mysql under zabbix monitoring windows

1. Create an account monitoring

GRANT SELECT,PROCESS,REPLICATION CLIENT ON *.* TO zabbix@'localhost' IDENTIFIED BY 'zabbix';

2. Create a script file (mysql path according to its own installation path)
in D: \ zabbix-agent created under conf \
from Ping.vbs

Set objFS =CreateObject("Scripting.FileSystemObject")
Set objArgs = WScript.Arguments
str1 = getCommandOutput("D:\software\mysql5.6.26\mysql-5.6.26-winx64\bin\mysqladmin.exe -uzabbix -pzabbix")

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

status.vbs

Set objFS = CreateObject("Scripting.FileSystemObject")
Set objArgs = WScript.Arguments
str1 = getCommandOutput("D:\software\mysql5.6.26\mysql-5.6.26-winx64\bin\mysqladmin.exe -uzabbix -pzabbix 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
' Wscript.Echo getCommandOutput 
end Function

version.vbs

Set objFS = CreateObject("Scripting.FileSystemObject")
Set objArgs = WScript.Arguments
str1 = getCommandOutput("D:\software\mysql5.6.26\mysql-5.6.26-winx64\bin\mysql.exe -V")

WScript.Echo str1

Function getCommandOutput(theCommand)
Dim objShell, objCmdExec
Set objShell = CreateObject("WScript.Shell")
Set objCmdExec = objshell.exec(thecommand)
getCommandOutput = objCmdExec.StdOut.ReadAll
end Function

3. Modify zabbix_agentd.win.conf
added at the end of zabbix_agentd.win.conf

UnsafeUserParameters=1
UserParameter=mysql.status[*], cscript/nologo D:\zabbix-agent\conf\status.vbs $1 
UserParameter=mysql.ping, cscript /nologo D:\zabbix-agent\conf\ping.vbs
UserParameter=mysql.version, cscript /nologo  D:\zabbix-agent\conf\version.vbs

4. Add template Template App MySQL comes in zabbix interface
5. Reboot zabbix agent

Guess you like

Origin blog.csdn.net/u014609263/article/details/91375611