Ad Widget

Collapse

zabbix_sender: resolution of item key names

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Pada
    Senior Member
    • Apr 2012
    • 236

    #16
    Ai.

    The Zabbix 1.8 documentation is misleading, because it says that user macro's are supported for item key's when it is in fact not supporting it.

    This same "bug" was fixed for SNMP items' keys ( https://support.zabbix.com/browse/ZBXNEXT-355 ) back in 1.8.4, but for some strange reason not for general Zabbix items - like Zabbix trapper items.

    Being unable to use user macro's in item keys and not allowing the same template to be used multiple times on a single host is really annoying and wasting a lot of my time.

    I've already modified my scripts that make use of zabbix_sender to send the key-value pairs (from the same host) to multiple hosts referencing the same template, just to make Zabbix administration faster.

    I'm nearing a point where I'm going to attempt write a patch that would allow the sample template to be used multiple times on a single host. This would only be possible if all the items in that template makes use of user macro's in their keys - but first user macro's has to work on item keys!

    So for example for using the template once, you'll use the user macro: {$VALUE} => Value1
    For using the template twice, you'll use the user macro's: {$VALUE[0]} => Value1, {$VALUE[1]} => Value2

    Comment

    • richlv
      Senior Member
      Zabbix Certified Trainer
      Zabbix Certified SpecialistZabbix Certified Professional
      • Oct 2005
      • 3112

      #17
      documentation is not misleading. it is important to understand a core principle of zabbix - item keys being unique per host.
      another important principle is having an item per data source. you can not send data for multiple items when one item only exists. i believe this misunderstanding is causing all the confusion here
      Zabbix 3.0 Network Monitoring book

      Comment

      • Pada
        Senior Member
        • Apr 2012
        • 236

        #18
        Thank you richlv.

        I just felt that the documentation was misleading in the sense that it said that user macro's may be used in item keys, where it should've perhaps mentioned (in a note) that it does not work for Zabbix trapper items...

        I know the internal workings of Zabbix fairly well, seeing I've already modified the database to suit my needs a few times.

        I did realize that the item keys has to be unique for the host. My issue is that even though you assign an user macro for it, the key should still be unique - unless you made a mistake by assigning the macro in such a way that the key now features twice (once due the the one with the user macro and one without).

        I'm really in need of some way of re-using templates for the same host, because we're still in development phase with our applications. This means that we regularly change the items that are being monitored, and we're running multiple instances of the same application on a single host.

        At this moment I've added the host multiple times, each ending with a unique suffix and making use of user macro's for the item names (and not keys) - and then I use it like you'd use VirtualHosts with Apache HTTPd server

        My company actually wanted some of us to go for Zabbix training, but I'm not sure if training would solve any of the advanced issues that we have at this moment - and I don't see any up and coming English training courses yet (I know there was one a week or so ago).

        Comment

        • richlv
          Senior Member
          Zabbix Certified Trainer
          Zabbix Certified SpecialistZabbix Certified Professional
          • Oct 2005
          • 3112

          #19
          i'm not sure whether i can get a really fresh explanation, but let's try with a bit lower level one

          when you send data to zabbix using zabbix sender, it looks up the item by the item key. once it has this connection, it puts data like history and trends in corresponding tables. this data is associated with the specific item (that we identified by the item key) with the item id.

          if you would resolve user macros in item keys and treat incoming values for a single item as if they were for multiple items, this wouldn't work. the only way i can see this being envisioned is pretty much creating some sort of automatic item creation based on incoming data from the sender, but i can see more issues than benefits there (just to start with, you can't create items like that unless you remove key uniqueness criteria, which breaks custom graphs, all item references, trigger configuration...), and even if that is somehow magically solved, you still have issues like typo in the key creating items that you have no way of getting rid of.

          it's like reimplementing lld from a totally different angle, just much harder.
          Zabbix 3.0 Network Monitoring book

          Comment

          • Yello
            Senior Member
            • Apr 2011
            • 309

            #20
            Originally posted by Pada

            I'm really in need of some way of re-using templates for the same host, because we're still in development phase with our applications. This means that we regularly change the items that are being monitored, and we're running multiple instances of the same application on a single host.

            At this moment I've added the host multiple times, each ending with a unique suffix and making use of user macro's for the item names (and not keys) - and then I use it like you'd use VirtualHosts with Apache HTTPd server
            I've tackled the same problem a while back and concluded that it wasn't a zabbix problem for thew reasons richlv has explained. At a high level here's what I do:

            1. Provision items via the api as agreed with development.
            2. Uniquely identify item categories, ie. to account for similar but different apps on the same server.
            3. Build a config file to aid with data retrieval and updating items via zabbix_sender. That is queries and item udates will be built dynamically from this config info.
            4. Write a scipt to do the heavy lifting and write back to zabbix.
            5. Make the new script capable of adding items that don't exist.
            6. When "new" but "different" applications are added to the server add supporting data to the config file.
            7. When the monitoring script runs it will add the relevant item categories and items via the api. This could be split out and run as a manual job if you wish. I went with close coupling because I was monitoring a database who's geometry could change on the fly.

            So, as a result I don't bother with macros for this type of work. In a way I store and resolve the macro values outside of zabbix. That was right for me because the complexity of what I was doing made it so.

            Whether that will work for you I don't know. But it sounds like some variation on it may do so.

            Regards,
            David

            Comment

            • Pada
              Senior Member
              • Apr 2012
              • 236

              #21
              Thank you Yello for your in depth explanation.

              Using the API is definitely in our pipeline. We're busy creating RPM's for our installations and the developer actually said that he wants to use the API to insert the hosts and items into Zabbix.

              Comment

              • richlv
                Senior Member
                Zabbix Certified Trainer
                Zabbix Certified SpecialistZabbix Certified Professional
                • Oct 2005
                • 3112

                #22
                api is definitely a valid approach. in some cases custom lld might be even easier.
                Zabbix 3.0 Network Monitoring book

                Comment

                • Yello
                  Senior Member
                  • Apr 2011
                  • 309

                  #23
                  Originally posted by richlv
                  api is definitely a valid approach. in some cases custom lld might be even easier.
                  Yes. I've not worked on 2.0 yet though.

                  Comment

                  • Pada
                    Senior Member
                    • Apr 2012
                    • 236

                    #24
                    Thanks. I completely forgot about LLD (Low-Level Discovery). It would definitely help us when we're adding new hosts with known services like Apache HTTPd, MySQL and file system monitoring.

                    Unfortunately I'll have to schedule a few hours of downtime to upgrade our system from 1.8 to 2.0, since I'll have to upgrade the proxies first and then the 10's of GB's of history tables BUT I reckon it would be worth it in the long run...
                    My other concern is that I'll have to port my Zabbix frontend patches to 2.0 too.

                    Anyway, thanks for all the assistance! It is much appreciated.

                    Comment

                    Working...