Last active
January 4, 2021 15:11
-
-
Save tsleite/92d2e01c0a274eb4756b0047f1450b57 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Instala automaticamente Zabbix Agente no ambiente Windows, utilizando a internet. | |
# SO: Windows Server 2012, 2012R2, 2016, 2019 | |
# Criado/Modificado: tleite@icloud.com | |
# links Download | |
$version428 = "https://www.zabbix.com/downloads/4.2.8/zabbix_agent-4.2.8-windows-amd64.zip" | |
$version428ssl = "https://www.zabbix.com/downloads/4.2.8/zabbix_agent-4.2.8-windows-amd64-openssl.zip" | |
$version444 = "https://www.zabbix.com/downloads/4.4.4/zabbix_agent-4.4.4-windows-amd64.zip" | |
$version444ssl = "https://www.zabbix.com/downloads/4.4.4/zabbix_agent-4.4.4-windows-amd64-openssl.zip" | |
# Obtendo hostname do Servidor | |
$serverHostname = Invoke-Command -ScriptBlock {hostname} | |
# IP Zabbix Server / Zabbix Proxy | |
$ServerIP = <COLOCAR_IP_AQUI> | |
# Caminho Log | |
$log = c:\zabbix\zabbix_agentd.log | |
# Cria diretório Zabbix | |
mkdir c:\zabbix | |
# Download da versão | |
Invoke-WebRequest "$version444" -outfile c:\zabbix\zabbix.zip | |
Add-Type -AssemblyName System.IO.Compression.FileSystem | |
function Unzip | |
{ | |
param([string]$zipfile, [string]$outpath) | |
[System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath) | |
} | |
# Descompactando | |
Unzip "c:\Zabbix\zabbix.zip" "c:\zabbix" | |
# Movendo bin arquivos em c:\zabbix | |
Move-Item c:\zabbix\bin\zabbix_agentd.exe -Destination C:\zabbix\bin | |
# Movendo conf c:\zabbix | |
Move-Item c:\zabbix\conf\zabbix_agentd.conf -Destination C:\zabbix\conf | |
# Config IP | |
(Get-Content -Path c:\zabbix\zabbix_agentd.conf) | ForEach-Object {$_ -Replace '127.0.0.1', "$ServerIP"} | Set-Content -Path c:\zabbix\conf\zabbix_agentd.conf | |
# Config Hostname | |
(Get-Content -Path c:\zabbix\zabbix_agentd.conf) | ForEach-Object {$_ -Replace 'Windows host', "$ServerHostname"} | Set-Content -Path c:\zabbix\conf\zabbix_agentd.conf | |
# Config Log | |
(Get-Content -Path c:\zabbix\zabbix_agentd.conf) | ForEach-Object {$_ -Replace 'c:\zabbix_agentd.log', "$log"} | Set-Content -Path c:\zabbix\conf\zabbix_agentd.conf | |
# Instalação do Agent | |
c:\zabbix\zabbix_agentd.exe --config c:\zabbix\conf\zabbix_agentd.conf --install | |
# Iniciar serviço | |
c:\zabbix\bin\zabbix_agentd.exe --start | |
# Criação regra firewall | |
New-NetFirewallRule -DisplayName "Allow Zabbix communication" -Direction Inbound -Program "c:\zabbix\bin\zabbix_agentd.exe" -RemoteAddress LocalSubnet -Action Allow |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment