Ad Widget

Collapse

Key with parameters, is this possible?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tuo
    Junior Member
    • Feb 2010
    • 18

    #1

    Key with parameters, is this possible?

    Hello Zabbix Forum,

    I currently have a question about the way keys of items are handled. Maybe I am misunderstanding this topic.

    I want to tie a custom items value to another parameter in the key, for example a measurement value to a given input value. I thought I could define the key like this:

    mykey[input]

    in my custom item.

    and then supply values to this item of a host like this

    mykey[10] = 1.1
    mykey[20] = 2.7

    etc.

    but either I am misunderstanding the key structure of zabbix (I red the documentation now a couple of times, and I am no longer sure if what I want to do is possible).

    The problem is, when I define the key like above, and then use zabbix_sender like this:

    zabbix_sender -z myserver -s myhost -k mykey[10] -o 1.1

    the server won't process the value.

    Am I misunderstanding the key structure or am I doing something wrong when calling zabbix_sender?

    any help is greatly appreciated

    best regards

    Ulrik
  • MrKen
    Senior Member
    • Oct 2008
    • 652

    #2
    In your Item set up, is your Item type 'Zabbix trapper'?

    Also, in your zabbix_sender command you can add -vv for verbose output which may help in troubleshooting.

    MrKen
    Disclaimer: All of the above is pure speculation.

    Comment

    • tuo
      Junior Member
      • Feb 2010
      • 18

      #3
      Hello MrKen,

      yes, the item is configured as zabbix trapper. if I remove the paramter from the key, everything works.

      here is how I call zabbix_sender from a windows machine:

      zabbix_sender.exe -vv -z myzabbixserver -s testhost -k mykey[10] -o 1

      response is:

      zabbix_sender.exe [11104]: DEBUG: Answer [{
      "response":"success",
      "info":"Processed 0 Failed 1 Total 1 Seconds spent 0.000031"}]

      The server log shows nothing.

      best regards

      Ulrik

      Comment

      • ghoz
        Senior Member
        • May 2011
        • 204

        #4
        Strange, i have the same kind of trapper items setup, and it works...


        Code:
        zabbix_sender -vv -z <zabbix-host> -s <testhost> -k  mysql.queries[delete] -o 348933
        zabbix_sender [21073]: DEBUG: Answer [{
                "response":"success",
                "info":"Processed 1 Failed 0 Total 1 Seconds spent 0.000056"}]
        Info from server: "Processed 1 Failed 0 Total 1 Seconds spent 0.000056"
        sent: 1; skipped: 0; total: 1
        could you try with a textual parameter ?
        can you try using another syntax like 'mykey.10'
        are you sure the item key is exactly the same in the GUI (no space after or before ) ?
        are you using the same command line between failing and working items ? (hostname exactly the one setup in the gui etc ...? )

        Comment

        • tuo
          Junior Member
          • Feb 2010
          • 18

          #5
          I kinda found the problem.

          I had to completely unlink and clear the template from the host, then add it again. now I was able to send values, but I think I am still not understanding the parameters in the keys correctly.

          what I want to achieve is an item for which I can capture values for different parameters WITHOUT having to define each item in the template.

          actually, I have to link the value of the item to an x and y coordinate. so my idea was to define an item with a key like this:

          key[x, y]

          and then send values like this:

          zabbix_sender -z server -s host -k key[0,0] -o 1
          zabbix_sender -z server -s host -k key[0,1] -o 2
          zabbix_sender -z server -s host -k key[0,3] -o 3
          zabbix_sender -z server -s host -k key[0,4] -o 4

          and then have in the "latest data" for each coordinate the correpsonding data, graph etc.

          when I define the key like above, I only get the following to work:

          zabbix_sender -z server -s host -k key[x, y] -o 4

          which is not what I intended. I tried changing the key to

          key[*, *]

          with the same result (I thought the * is a wildcard in this case)

          Is this possible with Zabbix, or do I misunderstand the meaning of the parameters in a key?

          best regards and thanks for all your help

          Ulrik

          Comment

          • untergeek
            Senior Member
            Zabbix Certified Specialist
            • Jun 2009
            • 512

            #6
            Do you have items defined for each possible key/value pair? Zabbix will work that way but you will need to define each key/value pair manually.

            In other words, if you want to store these, you can't just have a single item like, key[*] defined in Zabbix and expect it to auto-extend like some hash. If you want a key[10] and a key[20] sent back to work, you'll need to define each possible n for key[n] as its own item.

            Comment

            • tuo
              Junior Member
              • Feb 2010
              • 18

              #7
              Ah, okay, then I simply misunderstood the mechanics behind the parameters.

              Will need a script then to define the key/value-pairs, as they are a couple of hundreds.

              best regards and many thanks for the help and time

              Ulrik

              Comment

              Working...