zabbix监控windows下的mysql

11 篇文章 0 订阅

1.创建监控账号

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

2.创建脚本文件(mysql路径按照自己的安装路径)
在D:\zabbix-agent\conf下创建
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.修改zabbix_agentd.win.conf
在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.在zabbix界面添加自带模板Template App MySQL
5.重启zabbix agent

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值