Install and deploy Zabbix agent on Windows Server (latest version)

Posted by rubbertoad on Wed, 15 May 2019 23:20:22 +0200

Install and deploy Zabbix agent on Windows Server

Download and unzip to the specified directory

Zabbix download page: https://www.zabbix.com/download

# To execute in the directory where zabbix_agents_3.4.0.win.zip is located, the author uses git bash. If not download git, it is recommended to extract it to C disk and rename it zabbix.
 unzip zabbix_agents_3.4.0.win -d C:/zabbix 

  • View the directory structure after zabbix-agent decompression
# Move to Disk C and execute the following commands to view
> cd C:
> tree zabbix

1. The conf directory is the agent configuration file
2. bin Files Store 32-bit and 64-bit Installers under windows

Configure zabbix-agent.win.conf

Find the configuration file zabbix_agent d.win.conf under conf and modify the parameters of LogFile, Server, Server Active and Hostname. The specific configuration is as follows:

# Move to the conf directory in the ZABBIX directory of CD C, edit zabbix_agent d.win.conf, and modify the following parameters
LogFile=C:\zabbix\zabbix_agentd.log

Server=192.168.1.134

ServerActive=192.168.1.134:10051

Hostname=Win-server-2016

  • Parametric implications:
1. The ip address of Server: ZABBIX server.

2. ServerActive: zabbix actively monitors the server's ip address.

3. Both Server and Server Active specify the IP address of zabbix Server. The difference is that the former is passive and the latter is active. That is to say, the Server configuration is used to allow the 172.17.22.155 IP to come and fetch data from me. Server Active's 172.17.22.155 means that the client submits the data to him on its own initiative.

4. Hostname host name must be unique and case-sensitive. Hostname must always be configured on the zabbix web, otherwise the active monitoring of zabbix will not work properly. Because the agent takes this hostname to ask the server, do I have an active monitor? The server takes this hostname to configure the inquiry, and then returns the information.

5. zabbix agent detection can be divided into two forms: active and passive. Active and passive statements are discussed relative to agents.

6. Active: agent requests server to get active list of monitored items, and submits the data needed to be detected in monitored items to server/proxy actively

7. Passive: The server requests the data of the monitoring item from the agent, and the agent returns the data.

zabbix-agent installation

Reference resources: https://www.zabbix.com/documentation/3.4/manual/appendix/install/windows_agent

  • After modifying the configuration file, the Zabbix Agent is installed as a service of Windows system with CMD (with administrator privileges). The following commands are executed under the Windows console:
> C:\zabbix\bin\win64\zabbix_agentd.exe -i -c C:\zabbix\conf\zabbix_agentd.win.conf
  • The console output information is as follows, indicating that the installation was successful:
zabbix_agentd.exe [4864]: service [Zabbix Agent] installed successfully
zabbix_agentd.exe [4864]: event source [Zabbix Agent] installed successfully

Start the zabbix-agent client

> C:\zabbix\bin\win64\zabbix_agentd.exe -c C:\zabbix\conf\zabbix_agentd.win.conf -s
  • The console outputs the following information to indicate that the installation was successful:
zabbix_agentd.exe [11052]: service [Zabbix Agent] started successfully
  • View Windows Port Listening
C:\zabbix\bin\win64>netstat -ano | findstr "10050"

TCP    0.0.0.0:10050          0.0.0.0:0              LISTENING       10624
...
...
... #This is omitted. Details are shown in the figure below.
TCP    [::]:10050             [::]:0                 LISTENING       10624

C:\zabbix\bin\win64>tasklist | findstr "10624"

zabbix_agentd.exe            10624 Services                   0     11,892 K

  • View Task Manager

  • Check the start log of zabbix_agent, zabbix_agent d.log:
 12660:20171218:194616.210 Starting Zabbix Agent [Win-server-2016]. Zabbix 3.4.0 (revision 71462).
 12660:20171218:194616.220 **** Enabled features ****
 12660:20171218:194616.231 IPv6 support:          YES
 12660:20171218:194616.241 TLS support:            NO
 12660:20171218:194616.250 **************************
 12660:20171218:194616.262 using configuration file: C:\zabbix\conf\zabbix_agentd.win.conf
 12660:20171218:194616.282 agent #0 started [main process]
  9412:20171218:194616.295 agent #1 started [collector]
  8968:20171218:194616.306 agent #2 started [listener #1]
 12644:20171218:194616.315 agent #3 started [listener #2]
 11580:20171218:194616.327 agent #5 started [active checks #1]
 12864:20171218:194616.337 agent #4 started [listener #3]
 11580:20171218:194616.360 no active checks on server [192.168.1.134:10051]: host [Win-server-2016] not found
 11580:20171218:194816.501 no active checks on server [192.168.1.134:10051]: host [Win-server-2016] not found

Windows server System Firewall Open 10050 Port

Control Panel - windows Firewall - Advanced Settings - Inbound Rules - New Rules. Detailed steps refer to the following figure:

According to the above steps, add in order to complete the addition of inbound rules

  • Setting up self-startup of zabbix_agent service

win+R, run services.msc, default is automatic

Command description of zabbix_agent d.exe

$ ./zabbix_agentd.exe -h
usage:
  zabbix_agentd.exe [-c config-file]
  zabbix_agentd.exe [-c config-file] -p
  zabbix_agentd.exe [-c config-file] -t item-key
  zabbix_agentd.exe [-c config-file] -i [-m]
  zabbix_agentd.exe [-c config-file] -d [-m]
  zabbix_agentd.exe [-c config-file] -s [-m]
  zabbix_agentd.exe [-c config-file] -x [-m]
  zabbix_agentd.exe -h
  zabbix_agentd.exe -V

A Zabbix daemon for monitoring of various server parameters.

Options:
  -c --config config-file        Path to the configuration file
                                 (default: "C:\zabbix_agentd.conf")
  -f --foreground                Run Zabbix agent in foreground
  -p --print                     Print known items and exit
  -t --test item-key             Test specified item and exit
  -m --multiple-agents           For -i -d -s -x functions service name will
                                 include Hostname parameter specified in
                                 configuration file
Functions:

  -i --install                   Install Zabbix agent as service
  -d --uninstall                 Uninstall Zabbix agent from service
  -s --start                     Start Zabbix agent service
  -x --stop                      Stop Zabbix agent service

  -h --help                      Display this help message
  -V --version                   Display version number

Example: zabbix_agentd -c C:\zabbix\zabbix_agentd.conf

Batch script agent d.bat

The author refers to the script of other people's articles. The following is the Windows batch script zabbix-agent d.bat to install, start, stop and uninstall zabbix_agent D on the client server.

  • Premise:
    • 1. Unzip zabbix_agents_3.4.0.win.zip to the C: ZABBIX directory
    • 2. Manual modification of parameter file c: zabbix conf zabbix_agent d.win.conf

  • The zabbix-agent d.bat script reads as follows:
@echo off

CHCP 65001

echo ****************************************

echo *****Zabbix Agentd Operation************

echo ****************************************

echo ** a. start Zabbix Agentd********

echo ** b. stop Zabbix Agentd********

echo ** c. restart Zabbix Agentd********

echo ** d. install Zabbix Agentd********

echo ** e. uninstall Zabbix Agentd********

echo ** f. exit Zabbix Agentd********

echo ****************************************

:loop

choice /c abcdef /M "please choose"

if errorlevel 6 goto :exit 

if errorlevel 5 goto uninstall

if errorlevel 4 goto install

if errorlevel 3 goto restart

if errorlevel 2 goto stop

if errorlevel 1 goto start

:start

c:\zabbix\bin\win64\zabbix_agentd.exe -c c:\zabbix\conf\zabbix_agentd.win.conf -s

goto loop

:stop

c:\zabbix\bin\win64\zabbix_agentd.exe -c c:\zabbix\conf\zabbix_agentd.win.conf -x

goto loop

:restart

c:\zabbix\bin\win64\zabbix_agentd.exe -c c:\zabbix\conf\zabbix_agentd.win.conf -x

c:\zabbix\bin\win64\zabbix_agentd.exe -c c:\zabbix\conf\zabbix_agentd.win.conf -s

goto loop

:install

c:\zabbix\bin\win64\zabbix_agentd.exe -c c:\zabbix\conf\zabbix_agentd.win.conf -i

goto loop

:uninstall

c:\zabbix\bin\win64\zabbix_agentd.exe -c c:\zabbix\conf\zabbix_agentd.win.conf -d

goto loop

:exit

exit

Create a host in Zabbix Web UI to view monitoring results

Configuration – Hosts – Create hosts

Creating a host and associating templates is relatively simple, I did not make detailed records.

  • View monitoring results


Installation experience

Define zabbix's decompression directory according to your environment, pay attention to firewall and configuration file issues

Topics: Zabbix Windows firewall git