Zabbix Agent Installation - robedi/PowerShell GitHub Wiki
Overview
This manual provides a detailed guide for automating the installation and configuration of the Zabbix Agent on domain-joined Windows machines using a PowerShell script. The script automates various steps, including downloading the correct Zabbix Agent version, managing its service, and configuring its settings. It is designed to be used in environments where Zabbix is already in use, either with a Zabbix server or a Zabbix proxy.
Script: Install-ZabbixAgent.ps1
Prerequisites
Before using the script, ensure that:
-
PowerShell is installed and has the appropriate execution policy to run scripts. You can bypass restrictions using:
PowerShell -ExecutionPolicy ByPass -File "\\FQDN\SHARE\Install-ZabbixAgent.ps1" -
Network Configuration: You have the correct IP addresses for the Zabbix server and proxy, and you are familiar with the subnet of the systems to which the Zabbix agent will be assigned.
-
File Shares and Paths: Ensure that the file shares are properly configured for the system to access the script and Zabbix configuration file.
-
Permissions: The user running the script must have administrative privileges on the target machine to manage services and install the Zabbix Agent.
Updating the Zabbix Agent Version
In the script, the $version variable defines the version of the Zabbix Agent that will be downloaded and installed. This variable needs to be updated whenever a new version of the Zabbix Agent is released.
Instruction:
-
Locate the
$versionvariable: In the script, find the line where$versionis defined. The current value might look like this:$version = "7.0.4" -
Update the version: Replace the existing value with the new version number that Zabbix has published. You can find the latest version on the official Zabbix website or download page.
-
Example: If the new version is
7.0.5, modify the line as follows:$version = "7.0.5"
By ensuring that the $version variable is updated with each new release, the script will always install the latest stable version of the Zabbix Agent. This ensures compatibility with the Zabbix server and helps maintain security and performance improvements provided by the updates.
Remember to test the script in a non-production environment after any version changes to confirm the installation process functions correctly with the new Zabbix Agent version.
Adjustments Required Before Running the Script
To make the script work for your specific environment, you must adjust the following values before running it:
-
File Location of PowerShell Script and Configuration File:
- Replace
\\FQDN\SHAREwith the location where your PowerShell script (Install-ZabbixAgent.ps1) and Zabbix Agent configuration file (template_zabbix_agentd.conf) are stored. - Example: If the file is on a file server called
Server1in a shared folder calledZabbixInstall, the path would be:\\Server1\ZabbixInstall\Install-ZabbixAgent.ps1
- Replace
-
Zabbix Server IP Address:
- Replace
[Zabbix_Server_IP]with the actual IP address of your Zabbix server. - This IP address is used for passive checks and communication between the agent and the server.
- Replace
-
Zabbix Proxy IP Address:
- Replace
[Zabbix_Proxy_Server_IP]with the IP address of your Zabbix proxy (if applicable). - The proxy is used when a machine’s subnet dictates communication via a proxy instead of directly with the Zabbix server.
- Replace
-
Subnets for Zabbix Proxy or Server Assignment:
- Replace
10.145and10.30with the actual subnets where your machines are located.- 10.145 Subnet: Machines in this subnet will be assigned to the Zabbix proxy.
- 10.30 Subnet: Machines in this subnet will be assigned to the Zabbix server.
- These subnets are used to determine which Zabbix instance (server or proxy) the agent will communicate with.
- Replace
-
Zabbix HostMetadata:
- The metadata allows Zabbix to categorize hosts automatically upon registration. Modify the following:
- Replace
Windows clientswith a descriptive tag for client machines. This metadata is used during autoregistration. - Replace
Windows serverswith a descriptive tag for server machines.
- Replace
- This metadata helps Zabbix apply appropriate monitoring templates automatically.
- The metadata allows Zabbix to categorize hosts automatically upon registration. Modify the following:
Step-by-Step Guide to Using the Script
-
Download the Script: Copy the script to a shared file location accessible by the target Windows machine(s).
-
Edit the Script:
- Open the script in a text editor.
- Adjust the required parameters:
- File path for script and configuration (
\\FQDN\SHARE). - Zabbix server and proxy IP addresses.
- Subnets and host metadata values.
- File path for script and configuration (
- Save the changes.
-
Run the Script:
- Open a PowerShell session as Administrator.
- Run the script using the following command:
PowerShell -ExecutionPolicy ByPass -File "\\YourFilePath\Install-ZabbixAgent.ps1"
-
Monitor the Output:
- The script will output status messages as it progresses through the installation, service management, and configuration updates.
- Ensure the Zabbix Agent service stops, installs, and starts correctly without errors.
-
Verify Installation:
- After running the script, verify that the Zabbix Agent is running on the target machine.
- You can check the service status in PowerShell with:
Get-Service -Name 'Zabbix Agent'
-
Review the Zabbix Agent Configuration:
- Ensure the Zabbix Agent configuration file (
zabbix_agentd.conf) is correctly updated with the required server, proxy, and metadata information.
- Ensure the Zabbix Agent configuration file (
Conclusion
This script automates the installation and configuration of the Zabbix Agent on Windows machines, making it easier to deploy Zabbix monitoring across multiple systems. By adjusting the server IPs, subnets, and metadata as outlined, you can tailor the script to suit your infrastructure and ensure it works effectively in your environment.