Ad Widget

Collapse

Remote Commands (yet again!)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bbrendon
    Senior Member
    • Sep 2005
    • 870

    #1

    Remote Commands (yet again!)

    Okay, I see some people have magically gotten this to work.

    As you can see below, the basic command executes according to the server, but that file doesn't exist. I even double checked permissions on /tmp.

    Code:
    029667:20070324:165954 Run remote commands START [actionid:34]
    029667:20070324:165954 run_remote_command START [hostname: 'company.server', command: 'touch /tmp/asdf']
    029667:20070324:165954 run_remote_command [result:-3]
    029667:20070324:165954 Run remote commands END
    Could this have something to do with the fact that I ONLY use active checks?

    My next option is to write a cron job against the database. I looked into this, but I can't figure out how to detect a trigger based on severity level and host group. It appears I have to decode the expression row column in the triggers table.

    AhhhhH!
    Unofficial Zabbix Expert
    Blog, Corporate Site
  • bbrendon
    Senior Member
    • Sep 2005
    • 870

    #2
    Wow. Ok, so this is now a FEATURE request and notice to everyone else.

    REMOTE COMMANDS REQUIRE THE ZABBIX SERVER TO CONTACT THE AGENT.

    So if your agents are behind a firewall, then you're SOL. Also, if you can't telnet to port 10050 of the hostname or IP as configured in the Zabbix server hosts, it will not work.

    Improperly configured Remote Commands can segfault your zabbix server, so tread carefully and test.
    Unofficial Zabbix Expert
    Blog, Corporate Site

    Comment

    • bbrendon
      Senior Member
      • Sep 2005
      • 870

      #3
      One finaly note, you want a result code of "-2" in the zabbix server logs which I guess means success.

      Good:
      Code:
      029666:20070324:170951 run_remote_command [result:-2]
      Bad:
      Code:
      029666:20070324:170951 run_remote_command [result:-3]
      Unofficial Zabbix Expert
      Blog, Corporate Site

      Comment

      • Niels
        Senior Member
        • May 2007
        • 239

        #4
        Originally posted by infinity005
        REMOTE COMMANDS REQUIRE THE ZABBIX SERVER TO CONTACT THE AGENT.
        Has this been fixed? The newest manual doesn't mention it.

        Comment

        • spetznaz
          Junior Member
          • May 2008
          • 5

          #5
          Have you Enabled Remote Commands in zabbix agent conf ???



          # Enable remote commands for ZABBIX agent. By default remote commands disabled.

          EnableRemoteCommands=1

          Comment

          • Niels
            Senior Member
            • May 2007
            • 239

            #6
            @spetznaz: The issue here is active / inactive, not enabled / disabled.

            Comment

            • stanko12
              Junior Member
              • Nov 2011
              • 4

              #7
              Remote command Active host

              so is this changed or not? can remote command be used with active host behind a firewall? I've been trying to get this to work for days now but it does not and i get that
              "End run_remote_command(result:-3)"

              i fixed sudoers and have remote commands enabled (set to 1) in conf file

              Comment

              • nelsonab
                Senior Member
                Zabbix Certified SpecialistZabbix Certified Professional
                • Sep 2006
                • 1233

                #8
                Remote commands are *NOT* related to items and their configuration be it active or passive. Remote commands require that the Zabbix Server process be able to connect with the agent (in a manner similar to passive items, but it's still not the same). If the Server can connect with the agent and the appropriate configuration entry "EnableRemoteCommands" has been enabled then remote commands will work. If they aren't check the log file on the agent.

                Thus if you cannot communicate from the server to the agent, remote commands don't work.
                RHCE, author of zbxapi
                Ansible, the missing piece (Zabconf 2017): https://www.youtube.com/watch?v=R5T9NidjjDE
                Zabbix and SNMP on Linux (Zabconf 2015): https://www.youtube.com/watch?v=98PEHpLFVHM

                Comment

                • stanko12
                  Junior Member
                  • Nov 2011
                  • 4

                  #9
                  by active host i mean a host that is behind a firewall and uses active checks to communicate with server so the server does note have it's ip.
                  this is addressed here:


                  so i guess my answer is NO that remote command will not work in my case

                  Comment

                  • nelsonab
                    Senior Member
                    Zabbix Certified SpecialistZabbix Certified Professional
                    • Sep 2006
                    • 1233

                    #10
                    That is correct. If the server cannot connect to the agent you cannot user remote commands at this time. If something like AQMP were implemented then concepts like active/passive would become moot and it would then be possible in your environment. But AQMP and Zabbix is just a dream right now. :-)
                    RHCE, author of zbxapi
                    Ansible, the missing piece (Zabconf 2017): https://www.youtube.com/watch?v=R5T9NidjjDE
                    Zabbix and SNMP on Linux (Zabconf 2015): https://www.youtube.com/watch?v=98PEHpLFVHM

                    Comment

                    • stanko12
                      Junior Member
                      • Nov 2011
                      • 4

                      #11
                      well if actions could activate and deactivate items all would be solved.
                      item with system.run
                      event (ftp down) trigers action which activates item which sends a command which changes state (ftp up) which trigers action to deactivate item.

                      Comment

                      • nelsonab
                        Senior Member
                        Zabbix Certified SpecialistZabbix Certified Professional
                        • Sep 2006
                        • 1233

                        #12
                        You can enable/disable items right now, but you will need to do a little programming to make it happen. Write an external script which takes an item name as the parameter. Tie that script to an action and subsequently a trigger. When a trigger activates, and the script get's called you can have that script use the API to enable/disable items as you need to. Is it pretty, no, but can you do what you want now, yes.
                        RHCE, author of zbxapi
                        Ansible, the missing piece (Zabconf 2017): https://www.youtube.com/watch?v=R5T9NidjjDE
                        Zabbix and SNMP on Linux (Zabconf 2015): https://www.youtube.com/watch?v=98PEHpLFVHM

                        Comment

                        • stanko12
                          Junior Member
                          • Nov 2011
                          • 4

                          #13
                          so i have solved it without script.
                          Client -Zabbix agentd active mode behind a firewall
                          Server - has also zabbix agentd running but in passive mode

                          so on my client sshd goes down, an Item collects that data and rises a trigger which invokes an action that executes a remote command on the Zabbix server where this command (sql command directly into database)changes the status of my "Custom Item" to active. My custom item using system.run puts a command to restart sshd in the data which zabbix_agentd collects. next time it collects data it gets the command to restart sshd. Once sshd is restarted Item collects that data which rises another trigger which starts another action which sets the status of my "Custom Item" to disabled.

                          Comment

                          Working...