Ad Widget

Collapse

LLD with zabbix_sender

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • r.salamanna
    Junior Member
    • Jul 2013
    • 11

    #1

    LLD with zabbix_sender

    Hi everybody

    I managed to make custom low level discovery work as described in the documentation using zabbix agent. The problem i now have is that i would like to use this same feature with trapper, making use of zabbix_sender. how can i send a JSON file with zabbix_sender? Is it possible? Thanks in advance for your help.

    Riccardo
    Last edited by tchjts1; 12-07-2013, 15:19.
  • r.salamanna
    Junior Member
    • Jul 2013
    • 11

    #2
    P.S.

    I managed to generate the JSON, right now i am trying to make it work like this:

    zabbix_sender -z xxx.xxx.xxx.xxx -s HOST -k key -o `cat file.json`

    Also, my JSON contains 2 macros, and i still can't find information about how to discover both macros and use the values in one item prototype, using the first macro for the name and the second for the numeric value of the item itself. If you could just give me a hint that would be much appreciated, thank you!

    Riccardo

    Comment

    • ArtemK
      Senior Member
      • May 2013
      • 232

      #3
      Hello,


      I'm writing JSON to tmp file, and the push data to server with sender

      file with json data:
      Code:
      [root@mustasuohaukka ~]# cat /tmp/raid-discovery-zsend-data.tmp
      - intel.raid.discovery.pdisks { "data":[{ "{#ENCLOSURE_ID}":"252", "{#PDRIVE_ID}":"1", "{#ADAPTER_ID}":"0" },{ "{#ENCLOSURE_ID}":"252", "{#PDRIVE_ID}":"3", "{#ADAPTER_ID}":"0" },{ "{#ENCLOSURE_ID}":"252", "{#PDRIVE_ID}":"0", "{#ADAPTER_ID}":"0" },{ "{#ENCLOSURE_ID}":"252", "{#PDRIVE_ID}":"2", "{#ADAPTER_ID}":"0" }]}
      command to send data to zabbix:
      Code:
      [root@mustasuohaukka ~]# zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -i /tmp/raid-discovery-zsend-data.tmp
      And I'm able to use all values with defined macros names in item and trigger prototypes. Maybe your JSON is not valid?

      What sender reports, when you push data to server?

      Comment

      • r.salamanna
        Junior Member
        • Jul 2013
        • 11

        #4
        Thanks!

        That's fantastic i can just use the -i parameter for JSON too! Very good.

        Unfortunately I now have another problem: I can send the data, and it is recognized, what i dunno how to do is how to use 2 values into one item. I try to explain myself: the item vfs.fs.discovery has all the information about mounted file systems, {#FSNAME} and {#FSTYPE} macros. I can then create items to run functions on these, like pfree or total to actually gather information. But how can I do that with custom LLD items? the actual data is not included in the JSON, only the tags are.

        I am sorry, I may have gone a bit off topic but it would really help me a lot to get this thing going. Thank you again.

        Comment

        • ArtemK
          Senior Member
          • May 2013
          • 232

          #5
          I'm not sure, what do you mean saying that "the actual data is not included in the JSON, only the tags are."?

          Can you post your JSON, which you are sending to server?

          i.e. in my example every macros have associated value, which is used in item and trigger prototypes. What you want to get, if there are only tags in JSON? How server will use it, when it substitute macros without data in prototype?

          Comment

          • r.salamanna
            Junior Member
            • Jul 2013
            • 11

            #6
            I'll use your JSON as example: you have

            Code:
            "{#ENCLOSURE_ID}":"252", "{#PDRIVE_ID}":"1", "{#ADAPTER_ID}":"0" }
            So you can create a discovery rule for each of this macros, then create items for each one and use the macro in the name, that would be replaced with the value you got on the JSON. But, what about the about the acutal value of that item, the ones you gather and you build triggers and graphs on.

            Another example: if I run zabbix_get -s xxx.xxx.xxx.xxx -p 10050 -k vfs.fs.discovery i get as an answer

            Code:
            {"data":[{"{#FSNAME}":"\/","{#FSTYPE}":"rootfs"},{"{#FSNAME}":"\/proc","{#FSTYPE}":"proc"}, .......
            But these are just the tags. One of the items prototype is vfs.fs.inode[{#FSNAME},pfree]. My question is: where is the pfree function gathering the data from, if no numeric value is specified in the JSON? Maybe from the agent? But if so, how can I specify values with custom LLD items? I hope i made myself clear.... Thank you for your precious help

            Riccardo

            Comment

            • ArtemK
              Senior Member
              • May 2013
              • 232

              #7
              I don't create discovery rule for macros. I have rules for key, in my case intel.raid.discovery.pdisks. And this key receives that JSON. Each piece of data contains
              Code:
              "{#ENCLOSURE_ID}":"252", "{#PDRIVE_ID}":"1", "{#ADAPTER_ID}":"0" }
              So, for every item and trigger prototype it's possible to use 3 macros. You can use macros not only in name, but in key also.

              see screenshot

              Item will be created for each piece of json data, received in json object, using specified macros, so you don't need any numeric value, if this is what you mean.

              example:
              Code:
              "{#ENCLOSURE_ID}":"252", "{#PDRIVE_ID}":"1", "{#ADAPTER_ID}":"0" }
              prototype
              Code:
              intel.raid.physical_disk[{#ADAPTER_ID},{#ENCLOSURE_ID},{#PDRIVE_ID},"firmware_state"]
              Zabbix will create item with key
              Code:
              intel.raid.physical_disk[0,252,1,"firmware_state"]
              so every macros will be substituted by it's value, provided in JSON object.

              intel.raid.physical_disk is userparameter defined in agent configuration, vfs.fs.inode is predefined function of zabbix agent.
              Last edited by ArtemK; 15-07-2013, 12:01.

              Comment

              • r.salamanna
                Junior Member
                • Jul 2013
                • 11

                #8
                Amazing design, thanks it will help me a lot. That solves any doubt i had about the key naming.

                And, for the value question, I understand that even if I use zabbix_sender I have to define the key I need in the agent config to be able to send data over those keys i create with the macros. Please correct me if i am wrong...

                intel.raid.physical_disk is userparameter defined in agent configuration, vfs.fs.inode is predefined function of zabbix agent.

                Comment

                • ArtemK
                  Senior Member
                  • May 2013
                  • 232

                  #9
                  Of course, if you use custom checks you will define them as userparameters in agent config, but if you use discovery for example to list windows services and then want to check them with agent - you don't need to define anything in agent configuration, as service checking is supported by agent out of the box.

                  Comment

                  • r.salamanna
                    Junior Member
                    • Jul 2013
                    • 11

                    #10
                    Perfect! I'll give it a try and many many thanks to you!

                    It sounds counter intuitive as I am going to use trapper that I need to define the userparameter. But I will try to implement it today. I'll let you know how that turns out

                    BR
                    Riccardo

                    Comment

                    • ArtemK
                      Senior Member
                      • May 2013
                      • 232

                      #11
                      You don't need to define discovery key in agent configuration, you should make sure, that agent knows how to deal with keys, used in item prototypes.

                      Comment

                      • r.salamanna
                        Junior Member
                        • Jul 2013
                        • 11

                        #12
                        Ok... I'm lost again. How do I do that? would you mind posting me how did you do for your intel.raid.physical_disk userparameter?

                        Comment

                        • ArtemK
                          Senior Member
                          • May 2013
                          • 232

                          #13
                          heh,

                          okay

                          so, discovery key [trapper item] you are using to send JSON to zabbix in zabbix_sender. There is no need to define it in agent configuration.

                          Then, your server receives JSON and creates tons of items from prototypes. In prototype you define another key with macros from JSON. That key will be used by server to actually check something. If this key [item's prototype key] is predefined and supported by agent, all is ok, nothing to define in zabbix agent.

                          However, if item's prototype key is something unknown for the agent (i.e. not supported out of the box), you will need to define this in agent configuration. And, certainly, my intel.raid.physical_disk is not supported out of the box, so
                          Code:
                          zabbix_agentd.win.conf
                          ...
                          UserParameter=intel.raid.physical_disk[*],C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File "C:\Program Files\zabbix_agent\raid_check.ps1" -mode pdisk -item $4 -adapter $1 -enc $2 -pdisk $3

                          Comment

                          • r.salamanna
                            Junior Member
                            • Jul 2013
                            • 11

                            #14
                            Ok so I think that for the moment I'll do like that: discovery as a trapper and prototype item as a active check. Even though i would really like to be able to implement it as trapper as well. If anybody has a solution, I'll be pleased to listen!

                            BR
                            Riccardo

                            Comment

                            • ArtemK
                              Senior Member
                              • May 2013
                              • 232

                              #15
                              Well, just define prototype as trapper, what's the problem? You will need only to send then data to all items, created from prototype from host with zabbix_sender, IMHO, not really usable, as you will need to know all items beforehand, what's the point to use LLD then?

                              Comment

                              Working...