[ZBX-22591] Error on start agent2 for windows as service Created: 2023 Mar 27  Updated: 2024 Jan 31

Status: Open
Project: ZABBIX BUGS AND ISSUES
Component/s: Agent (G)
Affects Version/s: 6.2.7
Fix Version/s: None

Type: Incident report Priority: Trivial
Reporter: Dmitry Khenkin Assignee: Victor Breda Credidio
Resolution: Unresolved Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows systems


Attachments: Zip Archive zabbix_agent2-6-2-6.zip     File zabbix_agent2.7z    

 Description   

Steps to reproduce:

  1. HostnameItem=system.run["powershell.exe -NoProfile -ExecutionPolicy Bypass -NonInteractive [System.Net.Dns]::GetHostByName(($env:computerName)).Hostname.ToLower()"]
  2. Restart zabbix agent2 as service

Result:

On version 6.2.7+:

Have a crash on start windows service on some Windows systems. I can't detect any depends from Windows version, but all problem hosts are server's platform.
In log file:
cannot process configuration: cannot get system hostname using "system.run["powershell.exe -NoProfile -ExecutionPolicy Bypass -NonInteractive [System.Net.Dns]::GetHostByName(($env:computerName)).Hostname.ToLower()"]" item specified by "HostnameItem" configuration parameter: Cannot execute command: exec: "cmd": cannot run executable found relative to current directory

Change service start mode from Automatic to Automatic (delay) have no effect.

Agnet2 started correctly when I try to start it as interactive program, not as service.

Agent2 version 6.2.6 and lowest started correctly as service too.

This type of setting I use for get full hostname as "host1.contoso.com" on Windows systems.



 Comments   
Comment by Victor Breda Credidio [ 2023 Mar 31 ]

Hi Dmitry.
Thank you for contacting us.

I was not able to reproduce, but once again, as you said, it seems to be happening only with Windows Servers

Cannot execute command: exec: "cmd": cannot run executable found relative to current directory

Could you please check if you are able to execute the command manually?
Maybe it could be some policy on your Windows Servers that doesn't allow you to execute the command? Remember that Zabbix, by default, runs with the "LOCAL SYSTEM" account, so you need to manually check running with this user as well.

You mentioned that version 6.2.6 was alright.
Could you try to check how your environment behaves while running Zabbix agent 2 version 6.2.9? 

Best regards,
Victor.

Comment by Dmitry Khenkin [ 2023 Mar 31 ]

Hi Victor.

> Could you please check if you are able to execute the command manually?

Yes, I wrote than I can start zabbix-egent2 manually as program. Agent started normally. And sent full hostname to server. And I got error when I try to start Service Zabbix Agent2 manually.

> Could you try to check how your environment behaves while running Zabbix agent 2 version 6.2.9? 

I tried to test 6.2.9 and all work correctly. 

Oddly enough - I checked the problematic hosts today and couldn't reproduce the bug on 6.4.0. Although 25.03 the problem was reproduced 100%. I installed on all problematic hosts 6.2.6 after detected issue and reinstalled 6.4.0 for test today. I don't remember what version was installed on that hosts before my experiments at 25.03. 
I'll take control for the week for this issue and I'll write result.

Comment by Dmitry Khenkin [ 2023 Apr 05 ]

Hi Victor.

I found problem host. It's Win SRV 2012 Standard Version 6.2 ( Build 9200 )

First try - run as service with error. 

Second try : run as program from explorer. Started normally. ( 2023/04/05 21:58:51.777323 Starting Zabbix Agent 2 (6.2.9) )

zabbix_agent2.7z

 

Version 6.2.6 started normally as service . Log below

zabbix_agent2-6-2-6.zip

 

Comment by Dmitry Khenkin [ 2023 Apr 06 ]

Hi Victor.

I try to change conflict command in conf file for Agent2

Old parameters:

HostnameItem=system.run["powershell.exe -NoProfile -ExecutionPolicy Bypass -NonInteractive [System.Net.Dns]::GetHostByName(($env:computerName)).Hostname.ToLower()"]

 

 

New parameters:

 

HostnameItem=system.run["echo TTT.TTT"]  

And I get same effect. 
I get error if I try to start as service but Agent2 started normally when I try to start from CLI. And it wrote that hostname=ttt.ttt.
Powershell is not source for issue.
IMHO Agent2 can't start shell for run command. But why? I don't know.
Environment for user SYSTEM standard 
Path=%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft\Exchange Server\V15\bin;C:\Program Files\Microsoft\Exchange Server\V15\Bin\Search\Ceres\Native\

Comment by Dmitry Khenkin [ 2023 Apr 06 ]

sorry, I remember that bellow

if set HostnameItem=system.hostname all started is fine.

Problem in construction 
HostnameItem=system.run.....

Comment by Allen Sabernick [ 2024 Jan 31 ]

Did you ever find a solution?  We are on agent 5.0.40, same issue, Windows Server 2022.  One thing I see in common, all the hosts having issues are MS Exchange Servers.  Any thoughts?

Generated at Wed Apr 30 06:19:21 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.