############################################ #Author:Lixiaosong #lixiaosong8706@gmail.com #For:Auto install zabbix-agent #Version:1.0 ############################################## wget http://www.zabbix.com/downloads/2.4.1/zabbix_agents_2.4.1.win.zip -OutFile C:\zabbix_agent.zip Function Unzip-File() { param([string]$ZipFile,[string]$TargetFolder) #确保目标文件夹必须存在 if(!(Test-Path $TargetFolder)) { mkdir $TargetFolder } $shellApp = New-Object -ComObject Shell.Application $files = $shellApp.NameSpace($ZipFile).Items() $shellApp.NameSpace($TargetFolder).CopyHere($files) } #将安装文件解压 Unzip-File -ZipFile C:\zabbix_agent.zip -TargetFolder C:\zabbix_agent #删除默认配置文件 rm C:\zabbix_agent\conf\zabbix_agentd.win.conf $hostname=hostname Add-Content -value "LogFile=C:\zabbix_agent\zabbix.log" C:\zabbix_agent\conf\zabbix_agentd.win.conf Add-Content -value "Server=1.1.1.1" C:\zabbix_agent\conf\zabbix_agentd.win.conf Add-Content -value "Hostname=$hostname" C:\zabbix_agent\conf\zabbix_agentd.win.conf Add-Content -value "ServerActive=1.1.1.1" C:\zabbix_agent\conf\zabbix_agentd.win.conf #判断系统类型 $sysinfo=(systeminfo.exe)[14] $sysinfonew=$sysinfo.Replace("系统类型: ","") if ($sysinfonew -like "x64-based PC" ){ C:\zabbix_agent\bin\win64\zabbix_agentd.exe -c C:\zabbix_agent\conf\zabbix_agentd.win.conf -i} else {C:\zabbix_agent\bin\win32\zabbix_agentd.exe -c C:\zabbix_agent\conf\zabbix_agentd.win.conf -i} Start-Service "Zabbix Agent" rm C:\zabbix_agent.zip
本文出自 “运维人生” 博客,请务必保留此出处http://lixiaosong.blog.51cto.com/705126/1663595
原文地址:http://lixiaosong.blog.51cto.com/705126/1663595