Ad Widget

Collapse

Remote Commands - Windows

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SRH
    Junior Member
    • Oct 2009
    • 12

    #1

    Remote Commands - Windows

    Hi all

    I'm trying to use the remote commands on Windows Machines, but it doesn't work.
    The configurations are:

    zabbix_agentd.conf:
    EnableRemoteCommands=1
    LogRemoteCommands=1
    TimeOut=15

    zabbix_server.conf:
    TimeOut=15

    Actions:
    Event source: Trigger
    Operations: Remote Command
    Remote Command: Test01:c:\windows\system32\shutdown.exe –r –f

    Log entries (Agent):
    3320:20100823:131820.832 Requested [system.run[c:\windows\system32\shutdown.exe –r –f,nowait]]
    3320:20100823:131820.832 Executing command 'c:\windows\system32\shutdown.exe –r –f'
    3320:20100823:131820.832 Execute command 'cmd /C "c:\windows\system32\shutdown.exe –r –f"'
    3320:20100823:131820.848 Sending back [1]

    The Zabbix-Agent on the Windows Machine has admin permission and is in passiv mode (also tested with active - no difference).

    At the moment i have no idea why it doesn't work and other forum entries/solutions brings no difference.
    Someone a tip?

    Thanks in advance and grz
    SRH


    Zabbix Server (Ubuntu 8.04): 1.8.2
    Zabbix Agent (XP): 1.8.2
  • NOB
    Senior Member
    Zabbix Certified Specialist
    • Mar 2007
    • 469

    #2
    Hi

    please try a simpler remote command, like "net start 'Print Spooler' " or another
    mostly unnecessary service or something along those lines. Just to check
    whether it is a problem related to the agent or to the command you are trying
    to execute.

    Best regards

    Norbert.

    Comment

    • SRH
      Junior Member
      • Oct 2009
      • 12

      #3
      Hi NOB (unter üs - au gseit "Hi Bärner" gel ;-))

      I have tested that with the services Zabbix Agent and Windwos Installer (MSIServer) and it works.
      So in this case, i can't use the shutdown command?

      Log:
      3804:20100825:083718.743 Requested [system.run[net stop "MSIServer",nowait]]
      3804:20100825:083718.743 Executing command 'net stop "MSIServer"'
      3804:20100825:083718.743 Execute command 'cmd /C "net stop "MSIServer""'
      3804:20100825:083718.759 Sending back [1]
      2360:20100825:083718.759 Processing request.
      2360:20100825:083718.868 Requested [system.run[net stop "Zabbix Agent",nowait]]
      2360:20100825:083718.868 Executing command 'net stop "Zabbix Agent"'
      2360:20100825:083718.868 Execute command 'cmd /C "net stop "Zabbix Agent""'
      1440:20100825:083718.868 In send_buffer('Test01','10051')
      1440:20100825:083718.868 Values in the buffer 0 Max 100
      1440:20100825:083718.884 Sleeping for 1 seconds
      3084:20100825:083718.884 In collect_cpustat()
      2360:20100825:083718.884 Sending back [1]
      1440:20100825:083719.884 In free_active_metrics()
      1440:20100825:083719.884 zabbix_agentd active check stopped
      3084:20100825:083720.071 In close_cpu_collector()
      3084:20100825:083720.071 zabbix_agentd collector stopped
      2532:20100825:083720.071 thread [0] is terminated

      Thanks and by
      (Danke dir und Gruss aus Zürich)
      SRH
      Last edited by SRH; 25-08-2010, 08:42.

      Comment

      • NOB
        Senior Member
        Zabbix Certified Specialist
        • Mar 2007
        • 469

        #4
        Hi SRH

        (ja vo Bärn)

        I've seen a lot of problems with the Windows shutdown from remote.
        That's why I think this is a not very useful test whether remote commands
        work or not.

        In our previous monitoring environment we used an ssh connection
        to the server and experienced the same sort of problems.
        A simple pop-up window open on a RDP-connection or other
        subtle stuff prevents windows from a shutdown (and, of course,
        a reboot).
        We used the psshutdown command and even with option "-f" (for
        force) it took either a very long time to shutdown or it didn't
        happen, at all.

        I am no real Windows expert and can't tell what the reason really was
        but I wouldn't bet on a working remote shutdown.

        Perhaps other people in this forum know other tools which definitely
        work every time or in some special cases not covered by the shutdown.exe
        or psshutdown.exe. I know, I wouldn't want to guarantee for a working
        reboot.

        Added: What comes to mind is that we have a problem with restarting
        the Zabbix agent via the remote command on Linux. The problem is
        that the agent is still running, although you killed it. Because one thread (or process)
        is still executing the command and at the time the (then second) agent is started, the port (10050) is
        still in use.
        Perhaps a shutdown on a Windows system has a similar sort of problem.
        The agent running the command might not stop because the command
        is not finished and prevent Windows from a shutdown ? This is just a guess.
        As I wrote, I am not a Windows internals expert.

        We tried several things to disconnect the script from the Zabbix agent
        under Linux but without any success.

        Best regards

        Norbert.
        Last edited by NOB; 25-08-2010, 10:36. Reason: corrected a typo / added some thoughts why this could be a hard problem to solve

        Comment

        • GArmao
          Zabbix Certified Specialist
          Zabbix Certified Trainer
          Zabbix Certified Specialist
          • Mar 2010
          • 135

          #5
          are you running zabbix agent as a Service? If so, you can try to enable the "allow this service to interact with desktop" option, you can find it opening the Zabbix Agent service properties under the "Log on" tab.
          Something else you can try is to change the "Log on as" setting, from "local system account" which is the default, to a specified account (i.e. your administrator user)

          Comment

          • SRH
            Junior Member
            • Oct 2009
            • 12

            #6
            Hi all

            The Zabbix-Agent runs at the moment not under the system account, it runs under the admin account. It makes no difference if i run the service under the system or admin account.

            A easy workaround is to but all commands into a batch or vbs file. Store the file under c:\[BatName].bat or what ever and in the zabbix/action use the remote command {Hostname}:start c:\[BatName].bat -> shutdown and all other commands will execute fine. I think the best and quickest solution and will work fine.

            Thanks for help and by
            SRH
            Last edited by SRH; 25-08-2010, 13:29.

            Comment

            • SRH
              Junior Member
              • Oct 2009
              • 12

              #7
              Hi

              Last update...
              You can execute the "shutdown" command. In the manual is a mistake. You've only to define: {Hostname}:shutdown -r
              Never but the path c:\windows\system32 in the command. Define only the command that is enough.

              By
              SRH

              Comment

              Working...