Ad Widget

Collapse

Remote command

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • maruscya
    Senior Member
    Zabbix Certified Specialist
    • Jul 2007
    • 129

    #1

    Remote command

    Hello Guys.. .

    One little question about "remote command"

    I have created a action like this

    Name : test remote command
    Source : trigger
    Condition : Trigger = TRUE
    Operations : send message AND
    Remote command : {HOSTNAME}:c:\windows\notepad.exe

    How i can check if command will be run ??

    I try increase log... without result....on server and client side...
    No message appear into zabbix log...
  • cstackpole
    Senior Member
    Zabbix Certified Specialist
    • Oct 2006
    • 225

    #2
    I am not sure if I understand your question.
    Are you asing how to know if Zabbix ran the action?

    Under Monitoring->Actions there should be a field called Type under which you should see "Script" listed. At least it shows up there for me.

    Or are you asking how to make Zabbix run the Action?

    Make sure that you have the
    Code:
    EnableRemoteCommands=1
    enabled in the zabbix_agentd.conf.

    Make sure that you can run the command as the zabbix user.

    If all that works then one thing you might want to try is running a script that will leave you a clue that it ran. I have set up quite a few scripts and have started putting
    Code:
    echo 1 > /tmp/out;
    just so that I would know for certain that Zabbix not only executed it, and sent it on to the computer but also that it ran properly. Once you know it runs, you can take it out. *Side note: I run my scripts under Linux and I am not sure if that will run under Windows. At very least it probably should point to c:\temp\out. Someone who knows DOS commands better might be able to figure out an equivelent.*

    I hope this answers your question but if I completly misunderstood you I apologize.

    Have Fun!

    Comment

    • maruscya
      Senior Member
      Zabbix Certified Specialist
      • Jul 2007
      • 129

      #3
      Hello !!

      Thanks for your help...
      I try follow your instruction.... and add a simple remote command like

      echo 1 > /tmp/test.txt
      But i can't find a new file on remote system under /tmp directory...

      Enable command are setted to 1 on zabbix_agend.conf.

      UPDATE: Under Monitoring -> Action "remote command" are not displayed. Only email delivered are displayed

      UPDATE PART 2: When the action start, on zabbix server log appear this line.
      13790:20080321:121915 Get value from agent failed. Error: Cannot resolve []
      Zabbix server try send command directly to remote host, but remote host are behind a firewall in a remote lan. If i understand right.. zabbix agent download command and execute it localy. But seems that server try contat agent and execute command !
      Last edited by maruscya; 21-03-2008, 13:23.

      Comment

      • cstackpole
        Senior Member
        Zabbix Certified Specialist
        • Oct 2006
        • 225

        #4
        Sorry about not posting in a couple of days. Easter weekend was prety busy for me.

        OK, now on to solve your problem!
        I don't think the firewall is your problem. Not if you are already monitoring the system. If the host and server are already talking then this should work. If you are not getting any data from the host, then that needs to be resovled first.

        Here is what I did to setup a test:
        1) I found a Linux box for me to test on. It already had Zabbix monitoring.
        2) Configuration->Items->select your Linux box->Create Item
        ___a) Description: test
        ___b) Type: Zabbix trapper
        ___c) Key: test
        ___d) Type of Information: Numeric (Integer 64bit)
        ___e) Left everything else as default: save
        3) Configuration->Items->select your Linux box->Create Trigger
        ___a) Name: test
        ___b) Expression: {LinuxBox:test.last(0)}=0
        ___c) Leave everything else as default and save
        4) Configuration->Items->select your Linux box->Create Action
        ___a) Name: test
        ___b) Event Source: Triggers
        ___c) Type of Calculation: AND/OR
        ___d) Conditions: Trigger="test" AND Trigger Value='TRUE'
        ___e) Operations: Run Remote Command
        ___f) If you are running Linux, that field should have in it:
        ______{HOSTNAME}:echo 0 > /tmp/test.txt
        ____ If you are running Windows, that field should have in it:
        ______{HOSTNAME}:echo 0 > c:\temp\test.txt
        ____ I do not have a windows box to test this on at the moment, but if need be I can get one.
        ___g) Save the command and save the Action (you said you setup a second action to send an email. That is OK)
        5) You have already verified that EnableRemoteCommands=1 in the zabbix_agentd.conf so also verify that /tmp/test.txt or c:\temp\test.txt does not exist or at least does not have a 0 already in it. If all of that is good, now we can test.
        6) zabbix_sender -z YourZabbixServerIP -p 10051 -s YourLInuxBox -k test -o 0
        and you should get a message: sent: 1; failed: 0; total: 1
        7) Now check your file: cat /tmp/test.txt. Hopefully you have a 0 in it.


        That should be everything. At least, that is all I do for the basic method. I typically configure other items so that my Monitoring->Actions reports Script. I was wrong in thinking that it does that automatically (at least 1.4 doesn't) so it makes sense that you would not see that.

        If this configuration is what you have and it doesn't work then I have a couple of other things to try.

        Have fun!

        [EDIT]: Just found a windows box that is being monitored but not being used at the moment. I just tried out the same steps with the windows version of the command and it worked on the first try.
        Last edited by cstackpole; 24-03-2008, 16:12.

        Comment

        • maruscya
          Senior Member
          Zabbix Certified Specialist
          • Jul 2007
          • 129

          #5
          Hello man !!!

          I do some test yesterday.... i follow all steps, but i can't use remote command.

          When i run "zabbix_sender" , on server appear into log file this message

          Get value from agent failed. Error: Cannot resolve []
          I don't understand if server try to contact client. At the moment my client is located in a remote lan behind a firewall. In this week try repeat the same steps with a client inside the same lan.

          One question about remote command: do you know if Server try send command to client, or client get a command from server and execute it localy ??

          Comment

          • maruscya
            Senior Member
            Zabbix Certified Specialist
            • Jul 2007
            • 129

            #6
            Hello Man

            I have found the solution...
            Please check this link...



            Zabbix server try to reach agent when action is "remote command" ...

            Comment

            • bbrendon
              Senior Member
              • Sep 2005
              • 870

              #7
              I could have told you that.... Wait, I think I did...
              Unofficial Zabbix Expert
              Blog, Corporate Site

              Comment

              • pierre-hoffmann
                Senior Member
                • Jan 2008
                • 133

                #8
                Hi,

                i've try to use action with this syntax in 'Run remote command':

                {HOSTNAME}:command


                But this doesn't work it seem that {HOSTNAME} macro doesn't work in 'Run remote commands' ?

                The only syntaxe work is

                hostname:command

                so you must create an action for every host .... !!!!

                Do you know this problem ?? it's planed to be correct in 1.6 ?? Actions storage in templates ???

                Regards,
                Pierre.
                Last edited by pierre-hoffmann; 13-05-2008, 23:47.
                P.Hoffmann
                System & Network Admin.
                __________________________
                Zabbix version 1.8.1
                Hosts monitored 1300
                OS Novell SLES 10 SP2
                __________________________

                Comment

                • cstackpole
                  Senior Member
                  Zabbix Certified Specialist
                  • Oct 2006
                  • 225

                  #9
                  {HOSTNAME}:cmd
                  works for me in 1.4.4 and 1.4.5.

                  Comment

                  • pierre-hoffmann
                    Senior Member
                    • Jan 2008
                    • 133

                    #10
                    Hi,

                    Yes it work (Zabbix 1.4.5), but i found some problems:

                    * Zabbix Aix agent don't get user [Zabbix] environement (why ? ... - it work with Linux Agent)
                    so i must give complete path to system binary or script to run

                    * If Action was on one host trigger and put condition
                    Trigger = "mytrigger" AND Trigger Value="TRUE"
                    it work.
                    But if Trigger come from a Template it doesn't work ...
                    i must use condition
                    Trigger description like "mytrigger" AND Trigger Value="TRUE"

                    It's a bug or not ?

                    And the big problem was there's no display of triggered Action type "Run remote commands" in Monitoring/Actions !

                    Regards,
                    Pierre.
                    Last edited by pierre-hoffmann; 14-05-2008, 14:46.
                    P.Hoffmann
                    System & Network Admin.
                    __________________________
                    Zabbix version 1.8.1
                    Hosts monitored 1300
                    OS Novell SLES 10 SP2
                    __________________________

                    Comment

                    • cstackpole
                      Senior Member
                      Zabbix Certified Specialist
                      • Oct 2006
                      • 225

                      #11
                      Ah OK. Yes I understand what you are saying.
                      When you set up your trigger, you supplied the template trigger thinking that if any hosts with that template triggered, the action would trigger. However, it doesn't work quite that way. When you select the template, it litterally is waiting for the template to trigger.

                      There is a big discussion with Alexi about this some where else on the forum. I believe that this is to be addressed in 1.6, however, I can not find that discussion at the moment. I will look around and see if I can find it. If I do I will post back.

                      Comment

                      Working...