Ad Widget

Collapse

Windows Agent ls to start only the first time after installation

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • StormScorpion
    Junior Member
    • Feb 2024
    • 22

    #1

    Windows Agent ls to start only the first time after installation

    Hi,
    I created an Ansible role to install and configure the Zabbix Agent on Windows servers.
    This works well beside the fact that the first start after the installation fails. Afterwards, I can start the Zabbix Agent service or reboot the system. It works everytime.

    Based on the logs it fails to start a listener on port 10050 - but its supposed to run in ActiveMode.
    The config file was written at 8:14:14, the service started at 8:14:28 - 14 seconds later. So the write config step was already done at the time the service was started.

    Log:
    Code:
    First start after installation with default config
    
    6140:20240731:081351.378 Starting Zabbix Agent [HOSTNAME]. Zabbix 6.4.17 (revision c12261f00b4).
    6140:20240731:081351.379 **** Enabled features ****
    6140:20240731:081351.381 IPv6 support: YES
    6140:20240731:081351.382 TLS support: YES
    6140:20240731:081351.383 **************************
    6140:20240731:081351.384 using configuration file: C:\Program Files\Zabbix Agent\zabbix_agentd.conf
    6140:20240731:081353.200 agent #0 started [main process]
    10396:20240731:081353.202 agent #1 started [collector]
    9308:20240731:081353.204 agent #2 started[listener #1]
    10744:20240731:081353.206 agent #3 started[listener #2]
    7592:20240731:081353.207 agent #4 started[listener #3]
    7512:20240731:081427.669 Zabbix Agent received stop request.
    7512:20240731:081428.661 Zabbix Agent stopped. Zabbix 6.4.17 (revision c12261f00b4).
    
    First after deployed configuration - failed
    8508:20240731:081428.712 Starting Zabbix Agent [hostname]. Zabbix 6.4.17 (revision c12261f00b4).
    8508:20240731:081428.713 **** Enabled features ****
    8508:20240731:081428.716 IPv6 support: YES
    8508:20240731:081428.719 TLS support: YES
    8508:20240731:081428.720 **************************
    8508:20240731:081428.723 using configuration file: C:\Program Files\Zabbix Agent\zabbix_agentd.conf
    8508:20240731:081428.729 listener failed: bind() for [[-]:10050] failed: [0x00002740] Only one usage of each socket address (protocol/network address/port) is normally permitted.
    8508:20240731:081428.730 Zabbix Agent stopped. Zabbix 6.4.17 (revision c12261f00b4).
    
    Second start - working
    9292:20240731:082810.338 Starting Zabbix Agent [HOSTNAME]. Zabbix 6.4.17 (revision c12261f00b4).
    9292:20240731:082810.340 **** Enabled features ****
    9292:20240731:082810.341 IPv6 support: YES
    9292:20240731:082810.342 TLS support: YES
    9292:20240731:082810.342 **************************
    9292:20240731:082810.343 using configuration file: C:\Program Files\Zabbix Agent\zabbix_agentd.conf
    9292:20240731:082811.023 agent #0 started [main process]
    2756:20240731:082811.024 agent #1 started [collector]
    5480:20240731:082811.025 agent #2 started[listener #1]
    7616:20240731:082811.026 agent #3 started[listener #2]
    9312:20240731:082811.028 agent #4 started[listener #3]
    1540:20240731:082811.029 agent #5 started [active checks #1]

    Config
    Code:
    # This is a configuration file for Zabbix agent service (Windows)
    # To get more information about Zabbix, visit http://www.zabbix.com
    
    ############ GENERAL PARAMETERS #################
    # Logging
    LogFile=C:\Program Files\Zabbix Agent\zabbix_agentd.log
    LogFileSize=1024
    
    ServerActive=zabbixserver.mycorp.local
    Hostname=hostname
    RefreshActiveChecks=60
    Server=127.0.0.1
    
    ############ ADVANCED PARAMETERS #################
    Include=C:\Program Files\Zabbix Agent\zabbix_agentd.d\
    
    # PSK Settings:
    TLSConnect=psk
    TLSAccept=psk
    TLSPSKFile=C:\Program Files\Zabbix Agent\psk.key
    TLSPSKIdentity=hostname
  • Answer selected by StormScorpion at 31-07-2024, 09:08.
    Markku
    Senior Member
    Zabbix Certified SpecialistZabbix Certified ProfessionalZabbix Certified Expert
    • Sep 2018
    • 1781

    Note the really fast start attempt just after the previous instance was stopped:

    7512:20240731:081427.669 Zabbix Agent received stop request.
    7512:20240731:081428.661 Zabbix Agent stopped. Zabbix 6.4.17 (revision c12261f00b4).
    ...
    8508:20240731:081428.712 Starting Zabbix Agent [hostname]. Zabbix 6.4.17 (revision c12261f00b4).
    ...
    8508:20240731:081428.729 listener failed: bind() for [[-]:10050] failed: [0x00002740] Only one usage of each socket address (protocol/network address/port) is normally permitted.


    so maybe the socket listener was not really yet removed during those 50-70 ms?

    Why does it first start the agent and then stop + start immediately again?

    Markku

    Comment

    • Markku
      Senior Member
      Zabbix Certified SpecialistZabbix Certified ProfessionalZabbix Certified Expert
      • Sep 2018
      • 1781

      #2
      Note the really fast start attempt just after the previous instance was stopped:

      7512:20240731:081427.669 Zabbix Agent received stop request.
      7512:20240731:081428.661 Zabbix Agent stopped. Zabbix 6.4.17 (revision c12261f00b4).
      ...
      8508:20240731:081428.712 Starting Zabbix Agent [hostname]. Zabbix 6.4.17 (revision c12261f00b4).
      ...
      8508:20240731:081428.729 listener failed: bind() for [[-]:10050] failed: [0x00002740] Only one usage of each socket address (protocol/network address/port) is normally permitted.


      so maybe the socket listener was not really yet removed during those 50-70 ms?

      Why does it first start the agent and then stop + start immediately again?

      Markku

      Comment

      • Markku
        Senior Member
        Zabbix Certified SpecialistZabbix Certified ProfessionalZabbix Certified Expert
        • Sep 2018
        • 1781

        #3
        Btw, if you are not using passive items, you can disable the listener:



        Set StartAgents to 0.

        (If later using Agent 2, then "Server=" makes the same thing, IIRC.)

        Markku

        Comment

        • StormScorpion
          Junior Member
          • Feb 2024
          • 22

          #4
          Workaround: configured Windows service to restart 5s after failure, now the service stays running after installation

          Comment

          • StormScorpion
            Junior Member
            • Feb 2024
            • 22

            #5
            Originally posted by Markku
            Why does it first start the agent and then stop + start immediately again?
            I install the Agent using chocolatey, it starts the service with default config right after installation. Then I write the config and restart the service.

            But thanks, that was the right hint. I added an explicit stop after install, that solved the issue.

            Comment

            Working...