Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-20351

Parameter nowait with Zabbix Agent 2 doesn't work

XMLWordPrintable

    • Icon: Problem report Problem report
    • Resolution: Duplicate
    • Icon: Minor Minor
    • None
    • 5.4.7, 5.4.8
    • Agent (G)
    • None
    • Zabbix 5.4
      Zabbix Agent 2 only
      Windows Server 2012R2/2016/2019
    • Sprint 83 (Dec 2021)

      Hi !

      With the new Zabbix Agent 2 (the problem is not present with the "classic" agent zabbix_agentd and worked before upgrading to agent 2), the powershell scripts started with the parameter nowait example : 

      system.run[powershell -NoProfile -ExecutionPolicy Bypass -File "C:\Program Files\Zabbix Agent 2\{_}scriptname.ps1{_}",{*}nowait{*}]

      starts (visible on the task manager) but stops after 30s (For the test zabbix_server.cnf and zabbix_agent2.conf are configure with Timeout=30).

      The result of:

      system.run[powershell -NoProfile -ExecutionPolicy Bypass -File "C:\Program Files\Zabbix Agent 2\{_}scriptname.ps1{_}",{*}nowait{*}]

       is correct : '1' but he finally stops before the end.

      If I call a batch file who call the powershell script the problem isn't present example :

       system.run["C:\Program Files\Zabbix Agent 2\\\{_}scriptname.bat\\{_}",\\{*}nowait\\{*}]

       

       

      1. Steps to reproduce (powershell) :

      1. Create script : testps.ps1 : 

       

      Start-Sleep -seconds 60
      cd 'C:\Program Files\Zabbix Agent 2'
      .\zabbix_sender.exe -c .\zabbix_agent2.conf -k TestTrapper -o 'ok'

       

      2. Create element : 

      system.run[powershell -NoProfile -ExecutionPolicy Bypass -File "C:\Program Files\Zabbix Agent 2\testps.ps1",nowait]

      Result:

      Element 'system.run[powershell -NoProfile -ExecutionPolicy Bypass -File "C:\Program Files\Zabbix Agent 2\testps.ps1",nowait]' return '1', script stops after 30s and inevitably nothing in my element trapper.

       

      2. Steps to reproduce (batch) :

      1. Create a batch script that runs the same Powershell script : testbatch.bat : 

      cmd /C "powershell -NoProfile -ExecutionPolicy Bypass -File "C:\Program Files\Zabbix Agent 2\testps.ps1""

      2. Create element : 

      system.run[powershell -NoProfile -ExecutionPolicy Bypass -File "C:\Program Files\Zabbix Agent 2\testbatch.bat",nowait]

      Result:

      Element 'system.run["C:\Program Files\Zabbix Agent 2\testbatch.bat",nowait]' return '1', the script continues its execution after 30s and I receive 'ok' in my trapper element

       

      Expected:
      To be able to recover the same operation as with the classic zabbix agent.
      Temporarily I cheat with .bat for all my Powershell scripts but it's not really a durable solution.

      Edit : If I modify the powershell script with "Start-Sleep -seconds 20", I get the value in the trapper element with system.run directly in powershell.

      Thank you in advance.

            asestakovs Aleksejs Sestakovs
            romain.si159 Romain SICAUD
            Team B
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: