Ad Widget

Collapse

About the Efficiency of Zabbix Agent UserParameters

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zjerryj
    Junior Member
    • Mar 2013
    • 16

    #1

    About the Efficiency of Zabbix Agent UserParameters

    Hi,

    I'm looking at some extra scripts about how to get information from iostat, nginx, etc., and I'm wondering about the efficiency of running the same script multiple times within one interval.

    Like this nginx script:
    Zabbix custom scripts and auto-install . Contribute to zbal/zabbix development by creating an account on GitHub.


    And it's corresponding UserParameters setting will be:
    UserParameter=nginx[*], bash /usr/share/zabbix/scripts/zabbix_nginx_check.sh $1 $2

    Does this mean if the server wanna get all seven items from this script, it need to be run seven times?

    This script includes a wget, so I think it's fairly cheap. So is the iostat script, it only reads from the plain text file, which is generated periodically by cron job. When running multiple times, it seems all fine.

    But how about a heavy operation? To get multiple items it'll be too expensive.

    For instance, I want to get JVM info through a port number. First I grep the output of netstat command and get the pid, then run jstat and get ec, eu, etc. But use UserParameters, this procedure will be performed multiple times. Also it's not very practical to list all jvm's info into a plain text file, cause the port comes and goes.

    In Cacti there's no such problem, 'cause user defined items could be fetched through a single line, like "ec:123 eu:456".

    How to deal with this scenario in Zabbix?

    Thanks.
  • heaje
    Senior Member
    Zabbix Certified Specialist
    • Sep 2009
    • 325

    #2
    Does this mean if the server wanna get all seven items from this script, it need to be run seven times?
    Yes.

    How to deal with this scenario in Zabbix?
    You can change the way your script works. For instance, if you already know all the items you will want to get from the script, try this:

    1. Change the item type for the items from the script to "Zabbix Trapper".
    2. Change your script so that when it is called it collects the necessary data, writes the data to a file in the format for zabbix_sender, and then uses zabbix_sender to send the file to zabbix.

    Comment

    • zjerryj
      Junior Member
      • Mar 2013
      • 16

      #3
      trapper item is a solution, but I need to setup crontab for it too. When I add a port, I need to adjust the script as well.

      Another solution I can think of is use externel check, but also it only supports one item.

      Any more ideas?

      Comment

      • heaje
        Senior Member
        Zabbix Certified Specialist
        • Sep 2009
        • 325

        #4
        Using the trapper doesn't require crontab. Just make a zabbix agent item that calls the script. The trapper items will then get their data.

        Comment

        • zjerryj
          Junior Member
          • Mar 2013
          • 16

          #5
          Originally posted by heaje
          Using the trapper doesn't require crontab. Just make a zabbix agent item that calls the script. The trapper items will then get their data.
          According to the manual, I need to use zabbix_sender to submit data to trapper items, which requires a cronjob.

          Or the following steps are what you mean:

          1. Write a script that will collect the data and send trappers to server.
          2. Include the script in agent's user parameter.
          3. Add an item to make the server check this user parameter, thus execute the script.

          Correct me if I misunderstood. Thanks.

          Comment

          • heaje
            Senior Member
            Zabbix Certified Specialist
            • Sep 2009
            • 325

            #6
            the steps you listed are correct No cronjob needed. for all intents and purposes, the zabbix server calling the user parameter is your "cronjob".

            Comment

            • zjerryj
              Junior Member
              • Mar 2013
              • 16

              #7
              It's a brilliant solution. Thanks~

              Comment

              • BDiE8VNy
                Senior Member
                • Apr 2010
                • 680

                #8
                A drawback of zabbix_sender is it lacks of any kind of queuing or buffering. This might be okay but I want to throw in another (upcoming) option:
                ZBXNEXT-1550 Loadable module(s) to extend the functionality of Zabbix agent [...]

                This feature wouldn't reduce the count of data collection but provides a highly efficient way (requiring proper programming skills) to extend Zabbix in the same manner of User-parameter.

                Comment

                • zjerryj
                  Junior Member
                  • Mar 2013
                  • 16

                  #9
                  Originally posted by BDiE8VNy
                  ZBXNEXT-1550 Loadable module(s) to extend the functionality of Zabbix agent [...]
                  This seems fun, but it seems to require c programming skill.

                  Looking forward to it~

                  Comment

                  • bhowerter
                    Junior Member
                    • Sep 2013
                    • 22

                    #10
                    Originally posted by BDiE8VNy
                    A drawback of zabbix_sender is it lacks of any kind of queuing or buffering.
                    Actually, zabbix_sender (2.0) will buffer item values for up to 1 second if it is optioned to read from Standard Input.

                    Comment

                    Working...