How to Set Up Zabbix Agent on Windows Server 2012 R2
Zabbix is a mature, enterprise-grade open-source monitoring platform that provides agent-based and agentless monitoring with built-in alerting, trending, dashboards, and auto-discovery. The Zabbix Agent 2 provides active and passive check modes, native Windows performance counter collection, event log monitoring, process monitoring, and support for custom user parameters. Installing Zabbix Agent 2 on Windows Server 2012 R2 integrates the server into a Zabbix monitoring environment with the full capabilities of the Zabbix server’s templates, triggers, and escalation workflows. This guide covers downloading and installing Zabbix Agent 2, configuring it for both passive (Zabbix server polls the agent) and active (agent pushes metrics to Zabbix server) modes, setting up Windows-specific monitoring items, and verifying host registration in the Zabbix web interface.
Prerequisites
- Windows Server 2012 R2 with administrator access
- PowerShell 4.0
- A running Zabbix Server (5.4 LTS, 6.0 LTS, or 6.4 recommended) with web frontend
- Network connectivity: TCP 10050 (passive mode, Zabbix server initiates) or TCP 10051 (active mode, agent initiates)
- Zabbix server IP address or hostname
Step 1: Download Zabbix Agent 2
Zabbix Agent 2 is the current recommended agent, written in Go, with improved performance and plugin support compared to the original C-based Zabbix Agent. Download the Windows binary package:
$ZabbixVersion = "6.4.15"
$ZabbixUrl = "https://cdn.zabbix.com/zabbix/binaries/stable/6.4/$ZabbixVersion/zabbix_agent2-${ZabbixVersion}-windows-amd64-openssl.zip"
New-Item -ItemType Directory -Path "C:Temp" -Force
Invoke-WebRequest -Uri $ZabbixUrl -OutFile "C:Tempzabbix_agent2.zip"
Step 2: Install Zabbix Agent 2
New-Item -ItemType Directory -Path "C:Zabbix" -Force
New-Item -ItemType Directory -Path "C:Zabbixlogs" -Force
New-Item -ItemType Directory -Path "C:Zabbixscripts" -Force
Add-Type -AssemblyName System.IO.Compression.FileSystem
[System.IO.Compression.ZipFile]::ExtractToDirectory("C:Tempzabbix_agent2.zip","C:Tempzabbix_extract")
Copy-Item "C:Tempzabbix_extractbinzabbix_agent2.exe" "C:Zabbix"
Copy-Item "C:Tempzabbix_extractconfzabbix_agent2.conf" "C:Zabbixzabbix_agent2.conf"
Write-Host "Zabbix Agent 2 binaries installed to C:Zabbix"
Step 3: Configure the Agent
Write the agent configuration file. This is the most critical step — the configuration defines which Zabbix server to connect to, the agent’s listen address, log file location, hostname, and enabled plugins:
$ZabbixServerIP = "192.168.1.10" # Your Zabbix server IP or hostname
$ZabbixHostname = $env:COMPUTERNAME # Uses the server's own computer name
$AgentConfig = @"
# Zabbix Agent 2 Configuration
# Windows Server 2012 R2
#--- General settings ---
PidFile=C:Zabbixzabbix_agent2.pid
LogFile=C:Zabbixlogszabbix_agent2.log
LogFileSize=10
DebugLevel=3
#--- Passive mode (Zabbix server polls agent) ---
Server=$ZabbixServerIP
ListenPort=10050
ListenIP=0.0.0.0
#--- Active mode (agent pushes to Zabbix server) ---
ServerActive=$ZabbixServerIP
Hostname=$ZabbixHostname
HostMetadata=WS2012R2,Windows,Production
#--- Buffer settings ---
BufferSize=100
BufferSend=5
#--- Connection timeout ---
Timeout=10
#--- User parameters (custom checks) ---
# UserParameter=custom.check[*],powershell -NonInteractive -Command "..."
#--- Plugin settings ---
Plugins.SystemRun.EnableRemoteCommands=0
#--- Windows-specific: Performance Counters ---
PerfCounter=cpu.queue.length,"SystemProcessor Queue Length",1
PerfCounter=disk.queue.length,"PhysicalDisk(_Total)Current Disk Queue Length",1
PerfCounter=network.bandwidth,"Network Interface(*)Bytes Total/sec",60
"@
Set-Content -Path "C:Zabbixzabbix_agent2.conf" -Value $AgentConfig -Encoding ASCII
Write-Host "Zabbix Agent configuration written"
Step 4: Install and Start the Windows Service
# Install as Windows service
& "C:Zabbixzabbix_agent2.exe" --config "C:Zabbixzabbix_agent2.conf" --install
# Set to automatic startup
Set-Service "Zabbix Agent 2" -StartupType Automatic
# Start the service
Start-Service "Zabbix Agent 2"
# Verify
Get-Service "Zabbix Agent 2" | Select-Object Name, Status, StartType
Step 5: Open Firewall Ports
# Passive checks: Zabbix server polls agent on 10050
New-NetFirewallRule `
-DisplayName "Zabbix Agent Passive (10050)" `
-Direction Inbound `
-Protocol TCP `
-LocalPort 10050 `
-Action Allow `
-RemoteAddress $ZabbixServerIP
Write-Host "Zabbix firewall rules created"
Step 6: Add Custom User Parameters for Windows-Specific Checks
User parameters allow you to run PowerShell scripts as Zabbix checks, returning values that Zabbix can trend, alert on, and display in dashboards. Add them to the configuration file:
$UserParams = @"
# Custom User Parameters for Windows Server 2012 R2
# Check if a specific Windows service is running (returns 1=running, 0=stopped)
UserParameter=custom.service.running[*],powershell -NonInteractive -Command "try { `$s = Get-Service '$1' -ErrorAction Stop; if (`$s.Status -eq 'Running') { Write-Host 1 } else { Write-Host 0 } } catch { Write-Host 0 }"
# Count failed login events in the last 5 minutes
UserParameter=custom.security.failed_logins,powershell -NonInteractive -Command "try { (Get-EventLog -LogName Security -InstanceId 4625 -After (Get-Date).AddMinutes(-5) -ErrorAction Stop).Count } catch { Write-Host 0 }"
# Get IIS application pool state count (running pools)
UserParameter=custom.iis.apppools.running,powershell -NonInteractive -Command "try { Import-Module WebAdministration; (Get-ChildItem IIS:AppPools | Where-Object { `$_.State -eq 'Started' }).Count } catch { Write-Host 0 }"
# Get available disk space for a specified drive letter
UserParameter=custom.disk.free.pct[*],powershell -NonInteractive -Command "try { `$d = Get-WmiObject Win32_LogicalDisk -Filter "DeviceID='`$1:'"; Write-Host ([Math]::Round((`$d.FreeSpace / `$d.Size) * 100, 1)) } catch { Write-Host -1 }"
# Get pending Windows Updates count
UserParameter=custom.windows.updates.pending,powershell -NonInteractive -Command "try { `$searcher = New-Object -ComObject Microsoft.Update.Searcher; `$results = `$searcher.Search('IsInstalled=0 and IsHidden=0'); Write-Host `$results.Updates.Count } catch { Write-Host -1 }"
"@
Add-Content -Path "C:Zabbixzabbix_agent2.conf" -Value $UserParams
Restart-Service "Zabbix Agent 2"
Write-Host "User parameters added"
Step 7: Add the Host in the Zabbix Web Interface
In the Zabbix web frontend, navigate to Configuration > Hosts > Create host. Fill in the following:
- Host name: Must match exactly the Hostname value in zabbix_agent2.conf
- Groups: Add to “Windows servers” group
- Interface: Click Add, select Agent, enter the server’s IP address, port 10050
- Templates: Click Select and add “Windows by Zabbix agent” template — this provides 150+ pre-configured checks and triggers for Windows hosts
Click Add to save the host. Zabbix will begin collecting data immediately. Green status indicators on the host page confirm successful agent communication.
Step 8: Configure Active Mode for Firewall-Restricted Environments
If the Zabbix server cannot initiate connections to the agent (e.g., due to firewalls), configure active mode where the agent initiates outbound connections to the Zabbix server on port 10051:
# Confirm active mode is configured (ServerActive= directive in conf)
Select-String "ServerActive" "C:Zabbixzabbix_agent2.conf"
# In active mode, add outbound firewall rule from agent to server
New-NetFirewallRule `
-DisplayName "Zabbix Agent Active (10051 outbound)" `
-Direction Outbound `
-Protocol TCP `
-RemotePort 10051 `
-Action Allow `
-RemoteAddress $ZabbixServerIP
Step 9: Test Agent Communication
From the Zabbix server, use zabbix_get to query the agent directly and verify specific items are working:
# On the Zabbix Linux server:
zabbix_get -s ws2012r2-server.domain.local -p 10050 -k "system.hostname"
zabbix_get -s ws2012r2-server.domain.local -p 10050 -k "system.cpu.util[,idle]"
zabbix_get -s ws2012r2-server.domain.local -p 10050 -k "vm.memory.util[pavailable]"
zabbix_get -s ws2012r2-server.domain.local -p 10050 -k "custom.service.running[W3SVC]"
zabbix_get -s ws2012r2-server.domain.local -p 10050 -k "custom.windows.updates.pending"
Step 10: Verify Agent Logs and Troubleshoot
Get-Service "Zabbix Agent 2" | Select-Object Name, Status
Get-Content "C:Zabbixlogszabbix_agent2.log" -Tail 30
netstat -ano | findstr ":10050"
Common issues: hostname mismatch between the agent config and the Zabbix web UI (must match exactly, case-sensitive); firewall blocking port 10050; the Zabbix server IP not matching the Server= directive (passive mode only allows connections from listed IPs as a security control).
Summary
Zabbix Agent 2 is now installed and operational on Windows Server 2012 R2, configured for both passive and active check modes. The configuration includes the standard agent setup with log rotation, custom user parameters for Windows service monitoring, pending updates count, IIS application pool status, and security event log analysis. The “Windows by Zabbix agent” template in the Zabbix web interface provides 150+ pre-built checks, triggers, and graphs that immediately populate once the host is registered, giving you comprehensive visibility into the WS2012 R2 server’s performance, availability, and security posture within minutes of agent installation.