No announcement yet.

Items return multiple values?

  • Filter
  • Time
  • Show
Clear All
new posts

    Items return multiple values?


    I would like to know if it's possible to return multiple values from a custom zabbix check.

    Let's say I want to monitor fields A, B and C.

    At the moment, I achieve my goals as follows:.

    - I create a script for each field "zabbix.get_A.php", "zabbix.get_B.php" and "zabbix.get_C.php". Each script connects to the database and returns 1 zabbix_value.
    - For each value, I add a line to zabbix_agentd.conf:
    UserParameter=get_A,/usr/local/bin/php /checks/zabbix.get_A.php
    UserParameter=get_B,/usr/local/bin/php /checks/zabbix.get_B.php
    UserParameter=get_C,/usr/local/bin/php /checks/zabbix.get_C.php

    Result: 3 values A, B, C are monitored and I can see actual and historical values in Zabbix. After that I can do anything else I want with the items.

    But isn't there a more easy way?

    My goal is to be able to view multiple items for different hosts in one overview screen, but I'd like to just configure once: get values from query from host and then the result should be displayed. I don't know if this is possible in Zabbix though ...

    Thanks in advance for advice.

    You would do it that way:

    1) create your different items, use trapper as type
    2) create one item as "control item" which accepts 0|1 (true|false) as return values

    Now have a script on your agent(s) which has "control-item" defined as a user parameter and is executable via the zabbix agent.

    "control-item" is a script which just returns "true" on success (or "false" on error).
    Then it checks all your in 1) defined parameters and sends the results via "zabbix_send" (that is: trapper items) back to your zabbix server.

    Basically that means that with one item call (your control-item) you will get back different item values (sent as trapper items).

    After that you can do what you want with your items:

    "select, i.key, i.lastvalue from items i, hosts h where i.temid = h.itemid and = "$HOST" and i.key_ like "%your_item_keys%"

    This, of course, will be a "char" or "text" value item since results are sent in ASCII. "char" is <256 bytes while "text" is ~4096 bytes IIRC.

    Recently I've done some more work on that by extracting and aggregating several collected items into HTML tables (that is: HP Proliant SNMP, VMWare ESXi SNMP and API, other stuff).


      Hi Steveboyson,

      Thanks for your reply.

      Your solution seems like an alternative way to display host data in Zabbix.

      It is similar to the solution in my first post that:
      • you have to define an item for each value
      • you have to create a script for each user parameter
      • The result is that different items (values) are being monitored in Zabbix and you can do whatever you want with them after that.

      The difference is that my solution uses php calls for each item of type Zabbix agent; your solution calls a script 'control-item' which then users zabbix-send to send values to trapper items in Zabbix.

      Please correct me if I'm wrong but this doesn't seem like a faster way to get the desired result though it may be a better solution.

      My goal is to be able to view the current status for different values on a host, like in the link you posted but I'd like it if I don't have to create 10 scripts for 10 items.

      My ideal solution would be if I could create 1 script which returns 1 resultset (array) of x values; then Zabbix can take care of the rest. So the steps to take would be:
      • Create item:
        • A php script is called which gets values from the database and returns the values (comma separated for example)
        • Description: 'example_resultset'
        • type: 'Zabbix-agent'
        • type of information: resultset (array?)
        • data type: string
      • Create php script 'zabbix.example_resultset'
        • connect to database
        • select concat(a,b,c,d,e,f,g,h) from table LIMIT 1;
        • return values in a string (assuming Zabbix requires a string though any return type is ok as long as Zabbix understands).
      • Create Zabbix screen
        • show resultset for each host

      So I think I can summarise my question in a different way: is it possible in an easy way to zend a resultset (array) and display the resultset in Zabbix without creating an item for each returned field?

      I 'm still going to try your solution though; probably things will become more clear after that.

      Again, thanks for any advice / suggestions.


        What I've seen so far is that zabbix always expects ONE (and exactly ONE) result per item.

        There is only one exception: LLD (discovery items).
        But these do not deliver item values but macros to create new item definitions (in zabbix slang: they are "item prototypes").

        Means, it will not help you very much in your approach.

        Surely you can use LLD to "autocreate" your different items. But again, you need to run these auto-defined items "one-per-one" to get back the proper results into the corresponding database fields (unless you feed the database directly which I would strictly not recommend as you will quite definitely break things more or less badly).


          Oh, and you don't have to create 10 scripts for 10 items. You will just have 10 "item fetches" for 10 items. They all written into the database and you can "extract" their lastvalue via one (specific and elaborate) script.

          You may want to have a look here:


            I tried your solution. A big improvement compared to the solution from my first post is, like you said, that I can now fetch all my values together and zend them to Zabbix. Instead of x times executing the same query for x fields in the same table (or some query), now I execute the query only once and then send the different fields to Zabbix. For large queries this is ofcourse very good for the performance.

            Thanks again.


              Cheers, U R welcome.


                I am looking for a similar solution

                Originally posted by steveboyson View Post
                Oh, and you don't have to create 10 scripts for 10 items. You will just have 10 "item fetches" for 10 items. They all written into the database and you can "extract" their lastvalue via one (specific and elaborate) script
                Your link is no longer active, any change you would share your knowledge once more. Thanks in advance for sharing your knowledge.


                  What *exactly* are you interested in?
                  Im not too sure what scripts I had in the owncloud. Pls. describe what you're trying to achive.


                    I have the zabbix agent run a script, that take a while to run, it will result in multiple interesting numbers (actually 3 different values).

                    So i would want to run the script and return 3 values that can be graphed in zabbix.

                    From the context of the thread, it looked to me as that was something similar that you had responded to in this thread.


                      Ah, now ;-)


                      This is an example of testing apache web servers.

                      It is a single call to a "UserParameter" script which sends trapper items back to zabbix and finally returns the script status.


                        New link?

                        Any chance of a similar link? Expired again... Quite interested in this too. Any general link to the conecpt would be great too. Dont really want many seperate checks either!