本文共 1637 字,大约阅读时间需要 5 分钟。
这文档是我拼凑出来的,脚本也是复制其他人的。自己当时找了很久。现在在这里分享给大家,顺便鄙视下51CTO上那些同样复制别人东西,还拿出来卖豆豆的人。
一、创建脚本
找一个放脚本的目录,如:C:\zabbix\Scripts创建脚本:MySQL-ping.vbs
Set objFS = CreateObject("Scripting.FileSystemObject")Set objArgs = WScript.Argumentsstr1 = getCommandOutput("C:\Program Files (x86)\MySQL\MySQL Server 5.0\bin\mysqladmin -uroot -proot ping")If Instr(str1,"alive") > 0 ThenWScript.Echo 1ElseWScript.Echo 0End IfFunction getCommandOutput(theCommand)Dim objShell, objCmdExecSet objShell = CreateObject("WScript.Shell")Set objCmdExec = objshell.exec(thecommand)getCommandOutput = objCmdExec.StdOut.ReadAllend Function
创建脚本:MySQL-Status_Script.vbs
Set objFS = CreateObject("Scripting.FileSystemObject")Set objArgs = WScript.Argumentsstr1 = getCommandOutput("C:\Program Files (x86)\MySQL\MySQL Server 5.0\bin\mysqladmin -u root -proot 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 ForEnd IfnextFunction getCommandOutput(theCommand)Dim objShell, objCmdExecSet objShell = CreateObject("WScript.Shell")Set objCmdExec = objshell.exec(thecommand)getCommandOutput = objCmdExec.StdOut.ReadAllend Function
#注意,str1 = getCommandOutput此处修改命令的绝对路径,用户名与密码。
二、修改agent配置文件
修改需要被监控的mysql所在服务器上的zabbix_agent.confUnsafeUserParameters=1 添加键值UserParameter=mysql.status[*], cscript /nologo C:\zabbix\Scripts\MySQL-Status_Script.vbs $1 UserParameter=mysql.ping, cscript /nologo C:\zabbix\Scripts\MySQL-ping.vbs在Server端测试是否成功
/usr/local/zabbix-server/bin/zabbix_get -s 192.168.1.1 -k mysql.ping三、重启agentd
四、在相应主机上添加zabbix的MySQL模板
转载于:https://blog.51cto.com/11575637/2056976