Ad Widget

Collapse

Need help executing remote commands on windows

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • TechPsycho
    Junior Member
    • May 2017
    • 1

    #1

    Need help executing remote commands on windows

    Hello,

    Still a beginner with Zabbix but I must say, so far... for what it's worth... it's beyond the best. Okay so I'm having a bit of trouble and I have searched the forms and have read the docs but can seem to get this to work.

    I have successfully created a trigger to look for a running application... in this case we will call it program.exe. The trigger works and alerts go out. I'm trying to have a remote command go out in attempt that the agent server will fix itself.

    So I have a bat file named "program.bat" on the agent server that has the following in it:
    HTML Code:
    @echo off
    start "" "C:\Users\Winbin\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\ProgramName\program.exe"
    exit
    The bat file does exactly what it needs to do on the agent server. However when executed remotely it does absolutely nothing.

    I ran it in command line on the zabbix host to make sure it connects
    zabbix_get -s IP -p 10050 -k "system.run[C:\program.bat]"
    and it seems to do it... but the application doesn't start on the agent machine

    Commands are enabled on the agent server and I tested to make sure it was working with:
    zabbix_get -s IP -p 10050 -k "system.run[mkdir C:\testcommand]"
    and that works just fine.

    As an extra precaution I turned on debugging on the agent server and I do see the following in the log file.
    3584:20170525:132905.211 Executing command 'C:\program.bat'
  • ovas
    Senior Member
    Zabbix Certified Trainer
    Zabbix Certified SpecialistZabbix Certified Professional
    • Apr 2017
    • 138

    #2
    Hello TechPsycho!

    By default, I believe, Zabbix agent server is being run as "Local system account" - https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx
    Therefore, all the remote commands are launched from that account as well, which may lack the permissions to run the specified program.bat file.
    Can you please check this, or change the account used to launch Zabbix agent (Control Panel -> Administrative Tools -> Services -> Zabbix Agent (properties) -> Log on) and give necessary permissions to run the program.bat from it?

    Comment

    • jameskirsop
      Member
      • Jul 2018
      • 32

      #3
      Originally posted by ovas
      Can you please check this, or change the account used to launch Zabbix agent (Control Panel -> Administrative Tools -> Services -> Zabbix Agent (properties) -> Log on) and give necessary permissions to run the program.bat from it?
      It seems like this can't be done (cleanly) on Server 2016. If I create a service account to run Zabbix Agent, the service will not start and in researching the error, it seems like this is by design and workarounds like this one aren't endorsed by Microsoft.

      This results in a similar issue to the one the OP states - in that cmdlets requiring specific permissions within a PowerShell script (which I've provided to the service account) don't complete because the Agent runs as SYSTEM.

      Comment

      Working...