Ad Widget

Collapse

system.run versus remote command

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rbarrero
    Junior Member
    • Mar 2007
    • 21

    #1

    system.run versus remote command

    Hi all;

    I'm having a problem with Remote Commands (via Actions) but using the system.run function works perfectly from the server.

    - RHEL ES 4.4
    - zabbix 1.1.4
    - debug level is set to 4
    - sudo is configured properly for user 'zabbix' (tested thoroughly)
    - EnableRemoteCommands=1

    This works:
    ###
    ./bin/zabbix_get -s www.domain.com -p 10050 -k system.run["sudo /cluster/cluster-scripts/init.d/httpd-zabbix start"]
    ###

    However, my Remote Command Action does NOT work.
    "www.domain.com:sudo /cluster/cluster-scripts/init.d/httpd-zab start"

    Here is the log from the server:
    ###
    007031:20070302:000226 Run remote commands START [actionid:7]
    007031:20070302:000226 run_remote_command START [hostname: 'www.domain.com', command: 'sudo /cluster/cluster-scripts/init.d/httpd-zab start']
    007031:20070302:000226 run_remote_command [result:-2]
    007031:20070302:000226 Run remote commands END
    ###

    Seems like the result = -2. Does anyone know what this means?

    We have taken a lot of time to make sure that init scripts return zabbix friendly output, permissions are correct, sudo is setup properly and we can execute remote commands as well. We have tested with the system.run()( command and it functions properly too.

    Any help would be greatly appreciated.

    Thank you!
  • Alexei
    Founder, CEO
    Zabbix Certified Trainer
    Zabbix Certified SpecialistZabbix Certified Professional
    • Sep 2004
    • 5654

    #2
    Didi you try to specify full path to sudo?
    Alexei Vladishev
    Creator of Zabbix, Product manager
    New York | Tokyo | Riga
    My Twitter

    Comment

    • rbarrero
      Junior Member
      • Mar 2007
      • 21

      #3
      Yes, I tried using the full path but still does not work. Here is the output from the zabbix_server log file:

      ###
      007215:20070302:205312 Run remote commands START [actionid:7]
      007215:20070302:205312 run_remote_command START [hostname: 'web.site.com', command: '/usr/bin/sudo /etc/init.d/httpd-zabbix start']
      007215:20070302:205312 run_remote_command [result:-2]
      007215:20070302:205312 Run remote commands END
      ###

      Any other ideas?

      Thank you!

      Comment

      • rbarrero
        Junior Member
        • Mar 2007
        • 21

        #4
        Note: system.run() still works from zabbix server to the agent server.

        Thanks,

        Comment

        • rbarrero
          Junior Member
          • Mar 2007
          • 21

          #5
          Update

          Hi;

          Wondering if this helps... I found this error in the logs and thought it might be helpful in debugging.

          "...
          Type of received value [1] is not sutable for [system.run["sudo /etc/init.d/httpd-zabbix start",nowait]@www.site.com] having type [7233048]
          ..."

          Ideas anyone?

          Here are the raw log entries:


          ###
          011533:20070302:233957 get_next_command START [command_list: 'www.site.com:"sudo /etc/init.d/httpd-zabbix start"']
          011533:20070302:233957 Result of get_next_command [alias:www.site.com, is_group:0, command:"sudo /etc/init.d/httpd-zabbix start"]
          011533:20070302:233957 run_remote_command START [hostname: 'www.site.com', command: '"sudo /etc/init.d/httpd-zabbix start"']
          011533:20070302:233957 get_value_agent: host[www.site.com] ip[] key [system.run["sudo /etc/init.d/httpd-zabbix start",nowait]]
          011533:20070302:233957 Sending [system.run["sudo /etc/init.d/httpd-zabbix start",nowait]
          011533:20070302:233957 Type of received value [1] is not sutable for [system.run["sudo /etc/init.d/httpd-zabbix start",nowait]@www.site.com] having type [7233048]
          ###

          Comment

          • rbarrero
            Junior Member
            • Mar 2007
            • 21

            #6
            ...more info and clarification

            Hi again;

            I just wanted to clarify something... my init script "httpd-zabbix" outputs only a "0" (success) or "1" (failure) to the screen. Is this correct?

            Also, this works from the zabbix server:

            /usr/local/zabbix/bin/zabbix_get -s www.site.com -p 10050 -k system.run["sudo /etc/init.d/httpd-zabbix start"]

            Any reason why it doesn't work from the automatic action? Which in turn uses system.run()?

            Thanks!

            Comment

            • rbarrero
              Junior Member
              • Mar 2007
              • 21

              #7
              "nowait" vs "wait"

              How can I specify "wait" or "nowait" for these system.run() commands via the Web Interface?

              Using 'nowait' returns 1 while 'wait' returns 0... wondering if this makes a difference and how I can test with with the PHP interface.

              Comment

              • rbarrero
                Junior Member
                • Mar 2007
                • 21

                #8
                Interesting find...

                I see this in the zabbix_agentd.log file

                "sh: sudo /etc/init.d/httpd-zabbix start: No such file or directory"

                So it tries to execute the command with nowait, but it fails from the shell.

                This file exists... so does the path. I have tried with /usr/bin/sudo and with just sudo.

                Why is the shell failing on this when calling this command manually works?

                Thanks!

                Comment

                • rbarrero
                  Junior Member
                  • Mar 2007
                  • 21

                  #9
                  Resolved

                  This was resolved by executing a remote command with no spaces.


                  Script Contents:

                  ########
                  #!/bin/bash
                  sudo /etc/rc.d/init.d/httpd-zabbix start
                  RETVAL="0"
                  echo $RETVAL
                  exit $RETVAL
                  ########

                  Comment

                  Working...