Announcement

Collapse
No announcement yet.

(v2rc1) Question about agent side external scripts

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    (v2rc1) Question about agent side external scripts

    I'd like to try out this new functionality but I've got some questions that aren't answered by the documentation (granted, it'll probably be added in the future).

    1. The documentation states that external scripts can impact the performance of the Zabbix server, if used too much. Is this still the case if the script is executing on the agent and not the server?

    2. I'm only monitoring Windows systems (active checks). What kinds of scripts can I execute using this new feature? Does the agent always default to the standard shell? (cmd, for example, as oppsed to powershell).

    3. Do we still place the scripts to be executed on the server? Does the server then upload the script to the agent?

    4. If the server does indeed upload the script to the agent, does it re-upload every time the item is checked? Or, does it cache the script on the agent?

    Thanks,
    Brent

    #2
    hmm. there is no new functionality called external scripts, it's a pretty old one.
    btw, if a custom command is called on the agent side, it is called "user parameter" instead. (and that's also an old functionality)
    Zabbix 3.0 Network Monitoring book
    Zabbix tips and inspiration (blog)

    Comment


      #3
      From the v2 "What's new" documentation:

      Ability to execute scripts on Zabbix agent

      Before Zabbix 2.0, user scripts could be executed on the Zabbix server only. Starting with 2.0, a script can be configured to be executed on the agent instead. For this feature to work, agent must be configured to allow remote commands.
      Am I missing something? :-)

      Comment


        #4
        oh, these are only the scripts you configure in administration -> script and then manually execute from the frontend (from example, from the maps )

        remote commands, external checks & userparams are oooold
        Zabbix 3.0 Network Monitoring book
        Zabbix tips and inspiration (blog)

        Comment


          #5
          Well, my questions still stand then. If the script is now being executed on the agent side, is it getting copied there every time it runs? What is the performance impact on the server if the script is run client side? Same questions apply. I understand that scripts and user params are not new, but this particular ability is new (again, see the release notes).

          The problem I'm looking to overcome is that I need to replicate some of the functionality that Xymon (aka 'hobbit') has before I can propose that we move to Zabbix (which is a no-brainer to me, but I have to make my case). In particular, Xymon can also run 'external' scripts on the agent side (without a timeout) and use the returned data as an item. This effectively makes the xymon agent double as a task scheduler.

          I could do this easily with a trapper item and that's probably what I'll end up doing... the issue with trappers is you are now relying on an external task scheduler to do the work. Cron for all you linux guys, but Windows Task Scheduler for the rest of the world. Windows tasks sched works find but I now have to worry about scheduling a bunch of trappers manually on each monitored system. Basically what we really need are user parameters that can execute a client side script but not wait for it to finish (bypassing the 30second timeout).

          Comment


            #6
            bypassing 30 second timeout for a check ?
            i'd classify that as "not reasonable" - as in, something's wrong with your approach...
            several approaches might work :

            a) hack the source, increase the timeout. usually a bad idea;
            b) have something else (script, whatever) output to files, just parse the files with the zabbix agent;
            c) use sender - either via crontab or via another zabbix agent item that just launches the processing, then disconnects. the script works, gathers the data and pushes it to zabbix using the sender.

            again, if your script really takes > 30 seconds to finish, it is somewhat suspect of not being the best source for monitoring
            Zabbix 3.0 Network Monitoring book
            Zabbix tips and inspiration (blog)

            Comment


              #7
              Thanks for the ideas.

              The script in question can take over a minute as it connects to Windows Updates in order to log available updates for the server.

              I agree - I understand why the limit is there. I'm just trying to work around it without having to load another task scheduling agent. I'll try triggering the script with a remote command item and then returning the results as a trapper.

              Comment


                #8
                Well, that might not work either. It appears that trapper items can't receive multi-line text, rather, zabbix_sender doesn't appear to let you do it. Is this correct?

                So, about the only option left is to have my scripts dump their output into a text file and use the new item type that lets you get the contents of a file.

                This makes doing checks with WMI (via vbscript or Powershell) more painfull than I had hoped, unless of course the data you're attempting to get is only numeric or a short text string.

                Comment


                  #9
                  Originally posted by BrentN View Post
                  Well, that might not work either. It appears that trapper items can't receive multi-line text, rather, zabbix_sender doesn't appear to let you do it. Is this correct?
                  not. zabbix sender should support sending multiline values just fine
                  Zabbix 3.0 Network Monitoring book
                  Zabbix tips and inspiration (blog)

                  Comment


                    #10
                    I tried piping the output from a command to the sender (used the "-" option for hostname so it got all info from the config file I specified) and it tried to send each line of the output as a separate item. This is on a windows agent. Based on the documentation, it sounds like sender will always consider each line, whether that be in a text file or pipe, to be an item. Granted, the documentation for sender is less than adequate so I could be missing a flag or something.

                    Comment


                      #11
                      could you please specify what you mean by "sending each line as item" ?

                      also, what do you consider to be missing from the sender documentation ? it was improved some time ago, and i considered it to be pretty great by now
                      Zabbix 3.0 Network Monitoring book
                      Zabbix tips and inspiration (blog)

                      Comment


                        #12
                        Couple updates:

                        I stand corrected Richlv, I got the sender to send multiple line values from my powershell script. The syntax is still a bit confusing though. It doesn't clearly state how to get the host name from the conf file. It talks about it in the last example but it should explain it better than just an example. Also, the bit about getting sender to use stdin is sort of confusing. The order of the switches also appears to matter. Here's the only way I could get sender to use the conf file for all info and send a multi-line value (at the powershell prompt):

                        Code:
                         .\zabbix_sender.exe -c zabbix_agentd.conf - -T -k trapperTest -o ($Result)
                        Would be a bit less confusing if when specifying a config file and no "-h" option, sender would default to the hostname in the config...


                        Ok - All of this brings me back to my original post. I've been able to use user parameters to cover most of the scripts I need to run, but there are a few that still need additional time to process and I don't want to resort to using the Windows Task Schedular or a 3rd party tool. Zabbix schedules things all the time (so to speak) - this should work.

                        So, I tried using an item with system.run to run the script in question (with the nowait switch) and the script can use sender (which now works as I'd like) to send the result back to another key. There ya go! I scheduled the script with Zabbix! Only.... Now I find out that system.run doesn't work on an agent that is purely using active checks. Darn.

                        Based on other threads I've found, it looks like this functionality has been requested but isn't on the short list, which is unfortunate. However - consider the following: Add that "nowait" option to user parameters. We'd still have to use sender to get data back into Zabbix, but at least we'd be able to execute longer running scripts without having to use yet another task scheduler.

                        :-)

                        Comment


                          #13
                          Originally posted by BrentN View Post
                          Couple updates:

                          I stand corrected Richlv, I got the sender to send multiple line values from my powershell script. The syntax is still a bit confusing though. It doesn't clearly state how to get the host name from the conf file. It talks about it in the last example but it should explain it better than just an example. Also, the bit about getting sender to use stdin is sort of confusing. The order of the switches also appears to matter. Here's the only way I could get sender to use the conf file for all info and send a multi-line value (at the powershell prompt):

                          Code:
                           .\zabbix_sender.exe -c zabbix_agentd.conf - -T -k trapperTest -o ($Result)
                          hmm. are we talking about the same sender ?

                          did you try the example from the manpage ?

                          echo "- hw.serial.number 1287872261 SQ4321ASDF" | zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -T -i -

                          Send a timestamped value from the commandline to Zabbix server, specified in the agent daemon configuration file. Dash in the input data indicates that hostname also should be used from the same configuration file.

                          Originally posted by BrentN View Post
                          Would be a bit less confusing if when specifying a config file and no "-h" option, sender would default to the hostname in the config...
                          -h, --help
                          Display this help and exit.

                          Originally posted by BrentN View Post
                          So, I tried using an item with system.run to run the script in question (with the nowait switch) and the script can use sender (which now works as I'd like) to send the result back to another key. There ya go! I scheduled the script with Zabbix! Only.... Now I find out that system.run doesn't work on an agent that is purely using active checks. Darn.
                          where did you see that system.run doesn't work as an active check ?
                          note... not remote commands. system.run item.
                          Zabbix 3.0 Network Monitoring book
                          Zabbix tips and inspiration (blog)

                          Comment


                            #14
                            You are correct, -h is help, I meant to say -s. All I'm saying is it could be made a little bit less confusing with some simple tweaks as I outlined in my previous reply.

                            You are also correct about system.run. Confusion on my part there. In case anybody comes across this thread while searching for help on system.run on a Windows active agent, here's the item I used to make this work. Note that %ZabbixRoot% is an env. variable with the root directory of our Zabbix agent.

                            This item runs a powershell script. The script returns data using Zabbix_Sender.

                            Code:
                            system.run[powershell.exe -NoLogo -NonInteractive -File "%ZabbixRoot%\scripts\WindowsUpdates.ps1",nowait]

                            Comment

                            Working...
                            X