2019独角兽企业重金招聘Python工程师标准>>>
系统环境:
操作系统:Windows Server 2012
ZABBIX Server:2.4.8
IP地址:192.168.0.77
模板脚本地址:http://pan.baidu.com/s/1eSDaiS6
ZABBIX客户端操作
1、在zabbix.conf中添加以下字段信息
Include=c:\Program Files\zabbix_agents\conf.d\*.conf 2、以下目录中新增一个目录和一个disk.conf文件
c:\Program Files\zabbix_agents\conf.d\mysql.conf3、mysql.conf
UserParameter=mysql.status[*], cscript /nologo D:\Zabbix_Monitor\Scripts\MysqlMonitoring\MySQL_Ext-Status_Script.vbs $1
UserParameter=mysql.ping, cscript /nologo D:\Zabbix_Monitor\Scripts\MysqlMonitoring\MySql_Ping.vbs 4、将网盘中的Zabbix_Monitor文件夹至D盘的根目录,附MySQL_Ext-Status_Script.vbs、MySQL_Ping.vbs脚本信息4.1、MySQL_Ext-Status_Script.vbs
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objArgs = WScript.Arguments
str1 = getCommandOutput("E:\MYOA\mysql5\bin\mysqladmin.exe -uroot -pmyoa888 --port=3336 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
nextFunction getCommandOutput(theCommand)
Dim objShell, objCmdExec
Set objShell = CreateObject("WScript.Shell")
Set objCmdExec = objshell.exec(thecommand)
getCommandOutput = objCmdExec.StdOut.ReadAll
end Function4.2、MySQL_Ping.vbs
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objArgs = WScript.Arguments
str1 = getCommandOutput("E:\MYOA\mysql5\bin\mysqladmin.exe -uroot -pmyoa888 --port=3336 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 Function5、重启ZABBIX Agentd服务、服务端使用zabbix_get测试是是否能抓取到结果。
[root@localhost ~]# zabbix_get -s 192.168.0.77 -k mysql.ping
1