https://www.zabbix.com/downloads/3.4.0/zabbix_agents_3.4.0.win.zipmysql
查看目录结构sql
conf目录存放的是agent的配置文件shell
bin目录存放的Windows下32位和64位安装程序数据库
建立logs目录存放zabbix_agent日志windows
# 须要建立logs目录存放zabbix_agent的日志 LogFile=d:\zabbix\logs\zabbix_agentd.log # 指定zabbix-server的ip, Server=192.168.1.65 # 指定server端的ip:interface ServerActive=192.168.1.65 # 指定主机名 Hostname=Windows-host-test
其中Server和ServerActive都指定zabbix Server的IP地址,不一样的是,前者是被动后者是主动。也就是说Server这个配置是用来容许192.168.1.65这个ip来我这取数据。而ServerActive的192.168.1.65的意思是,客户端主动提交数据给他。bash
> D:\zabbix\bin\win64\zabbix_agentd.exe -i -c d:\zabbix\conf\zabbix_agentd.win.conf
zabbix_agentd.exe [8288]: service [Zabbix Agent] installed successfully
zabbix_agentd.exe [8288]: event
source
[Zabbix Agent] installed successfull
D:\zabbix\bin\win64> zabbix_agentd.exe -c d:\zabbix\conf\zabbix_agentd.win.conf -s
D:\zabbix\bin\win64> zabbix_agentd.exe -c d:\zabbix\conf\zabbix_agentd.win.conf -x
D:\zabbix\bin\win64> zabbix_agentd.exe -c d:\zabbix\conf\zabbix_agentd.win.conf -d
控制面板--à选择windows 防火墙--à高级设置--à设置入站规则--à新建规则测试
设置开机启动spa
运行services.msc日志
zabbix_agentd.exe命令说明code
-c 制定配置文件所在位置
-i 安装客户端
-s 启动客户端
-x 中止客户端
-d 卸载客户端
要想在Windows上取得MySQL的状态数据,能够用vbs脚本运行mysql命令,
第一步,脚本下载:http://pan.baidu.com/s/1eSDaiS6下载好后,放到一个文件夹中,好比d:\Zabbix\Scripts
第二步,修改windows上的zabbix_agentd.comf文件,设置key值。在UserParameter下面加两句;
UserParameter=mysql.status[*], cscript /nologo d:\Zabbix\Scripts\MySQL_Ext-Status_Script.vbs $1
UserParameter=mysql.ping, cscript /nologo d:\Zabbix\Scripts\MySql_Ping.vbs
第三步,重启zabbix_agentd。到zabbix_server上把mysql模板应用到主机上,查看items状态。
而后我就看到这样:
一、在zabbix.conf中添加如下字段信息
Include=D:\zabbix\conf\zabbix_agents.conf.d\*.conf
二、如下目录中新增一个目录和一个disk.conf文件
D:\zabbix\conf\zabbix_agents.conf.d\mysql.conf
三、mysql.conf
UserParameter=mysql.status[*], cscript /nologo D:\zabbix\bin\Scripts\MysqlMonitoring\MySQL_Ext-Status_Script.vbs $1 UserParameter=mysql.ping, cscript /nologo D:\\zabbix\bin\Scripts\MysqlMonitoring\MySql_Ping.vbs
四、将网盘中的Zabbix_Monitor文件夹至D盘的根目录,附MySQL_Ext-Status_Script.vbs、MySQL_Ping.vbs脚本信息 4.一、MySQL_Ext-Status_Script.vbs
Set objFS = CreateObject("Scripting.FileSystemObject") Set objArgs = WScript.Arguments str1 = getCommandOutput("D:\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 next Function getCommandOutput(theCommand) Dim objShell, objCmdExec Set objShell = CreateObject("WScript.Shell") Set objCmdExec = objshell.exec(thecommand) getCommandOutput = objCmdExec.StdOut.ReadAll end Function
注:str1 = getCommandOutput("D:\MYOA\mysql5\bin\mysqladmin.exe -uroot -pmyoa888 --port=3336 extended-status") 根据实际状况修改
4.二、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 Function
五、重启ZABBIX Agentd服务、服务端使用zabbix_get测试是是否能抓取到结果。
[root@localhost ~]# zabbix_get -s 192.168.0.77 -k mysql.ping 1