[ZBX-15988] Zabbix agent will not install under PowerShell function Created: 2019 Apr 13  Updated: 2020 Jun 22  Resolved: 2020 Jun 22

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

Type: Incident report Priority: Trivial
Reporter: MArk Assignee: Kristians Pavars
Resolution: Won't fix Votes: 0
Labels: Install, agent, config, configfile, installation, powershell, scripts, zabbix_agentd, zabbix_agentd.exe
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows Server 2008 R2 Standard



 Description   

Steps to reproduce:

I have created a PowerShell script to install Zabbix Agent on a Windows server 2008. I can execute zabbix agent commands whitin CMD with no problem, but when I try to start the "--install -c <configuration_file>"  on my script it fails.

My script stops and uninstall zabbix agent successfully. But, when I try to install it again, it gives an error showing

"zabbix_agentd.exe [5952]: unrecognized option `--install --config C:\zabbix\conf\zabbix_agentd.conf'"

  1. I have Zabbix Agent installed on C:\zabbix\
  2. Configuration file is located at C:\zabbix\conf\zabbix_agentd.conf

 

My script:

 

$agenteZabbix    = "C:\zabbix\bin\zabbix_agentd.exe"

function PulaLinha {
    timeout /T 1 /NOBREAK > $null
    Write-Host "`n`n"
    }

function ZabbixComando ($comando) {
    & $agenteZabbix $comando
    
    PulaLinha
    }

ZabbixComando -comando '--stop'
ZabbixComando -comando '--uninstall'
ZabbixComando -comando '--install --config C:\zabbix\conf\zabbix_agentd.conf'
ZabbixComando -comando '--start'

 

 

Result:

zabbix_agentd.exe [20144]: service [Zabbix Agent] stopped successfully

zabbix_agentd.exe [13196]: service [Zabbix Agent] uninstalled successfully
zabbix_agentd.exe [13196]: event source [Zabbix Agent] uninstalled successfully

zabbix_agentd.exe [18176]: unrecognized option `--install --config C:\zabbix\conf\zabbix_agentd.conf'
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

zabbix_agentd.exe [15944]: ERROR: cannot open service [Zabbix Agent]: [0x0000042
4] The specified service does not exist as an installed service.

Expected:
When I do it all manually, it gives me no errors

C:\zabbix\bin>zabbix_agentd.exe --stop
zabbix_agentd.exe [21260]: service [Zabbix Agent] stopped successfully

C:\zabbix\bin>zabbix_agentd.exe --uninstall
zabbix_agentd.exe [19888]: service [Zabbix Agent] uninstalled successfully
zabbix_agentd.exe [19888]: event source [Zabbix Agent] uninstalled successfully

C:\zabbix\bin>zabbix_agentd.exe --install -c C:\zabbix\conf\zabbix_agentd.conf
zabbix_agentd.exe [5968]: service [Zabbix Agent] installed successfully
zabbix_agentd.exe [5968]: event source [Zabbix Agent] installed successfully

C:\zabbix\bin>zabbix_agentd.exe --start
zabbix_agentd.exe [22328]: service [Zabbix Agent] started successfully


 Comments   
Comment by Kristians Pavars [ 2020 Jun 18 ]

Hi markfree

 

Thanks for reaching out to public bug tracker. I tested your script and can confirm the behavior, however I think it is something Powershell related rather than Zabbix, thus this is not really a bug. Invoking the command directly works as expected, the problem arises when you try to pass multiple parameters in the -comando argument so there is something going on there internally. Using the example below it works fine.

ZabbixComando -comando '--stop'
ZabbixComando -comando '--uninstall'
& "C:\Program Files\Zabbix Agent\zabbix_agentd.exe" --install -c 'C:\Program Files\Zabbix Agent\zabbix_agentd.conf'
#ZabbixComando -comando '-c C:\Program Files\Zabbix Agent\zabbix_agentd.conf --install'
ZabbixComando -comando '--start'

 

Please be advised that this section of the tracker is for bug reports only. The case you have submitted can not be qualified as one, so please reach out to [email protected] for commercial support or consultancy services. Alternatively, you can also use our IRC channel or community forum (https://www.zabbix.com/forum) for assistance. With that said, we are closing this ticket. Thank you for understanding. 

 

Thanks,
Kristiāns

Generated at Sat Apr 20 08:04:42 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.