Ad Widget

Collapse

Item prototype with LLD macros

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • corak
    Junior Member
    • Aug 2018
    • 2

    #1

    Item prototype with LLD macros

    Hi everyone,

    I'm using a custom script that provides data in LLD format and using that information in Zabbix 3.2.11 which is running on Ubuntu. The data script outputs is in following format:
    Code:
    {
      "data": [
        {
          "{#JSONDESCRIPTION}": "DB check",
          "{#JSONCOMPLETEKEY}": "com.foobar.dbcheck",
          "{#JSONISHEALTHY}": true,
          "{#JSONNAME}": "Database"
        },
        {
          "{#JSONDESCRIPTION}": "Lucene check",
          "{#JSONCOMPLETEKEY}": "com.foobar.indexcheck",
          "{#JSONISHEALTHY}": true,
          "{#JSONNAME}": "Lucene index"
        }
      ]
    }
    I have created a discovery rule that uses the external script and created an item prototype for it. The item prototype is as follows:
    Code:
    Name: {#JSONDESCRIPTION}
    Type: Calculated
    Key: health[{#JSONCOMPLETEKEY}]
    Formula: {#JSONISHEALTHY}.str("true")
    Then the discovery rule reports an error:
    Cannot update an item: no value for macro "{#JSONISHEALTHY}"
    . I think I'm using the calculated item prototype in a wrong way, but I guess you can get a hint what I'm trying to implement.

    Zabbix can parse the JSON data fine, as I'm able to get the correct items if I set the formula e.g to: now

    The script I'm using, just in case you're interested is a modified version of this script: https://gist.github.com/dav3860/bdc658da6e7579d385d3

    Thanks for reading! Any help appreciated!
  • Linwood
    Senior Member
    • Dec 2013
    • 398

    #2
    Yes, a calculated item is calculated from other items. Discovery rules create items, they do not populate items with data.

    To do what you want you have a few options. one is to let the discovery create an item that's SNMP or some other type, which can poll for the healthy status. If there's an easy way to poll for that.

    If you really need the discovery rule to return the value in addition, you can - let the LLD rule create the item as a zabbix trapper type, then let the LLD also do a zabbix send back to the trapper item. The very first time it runs the send won't be recorded as the LLD rule won't yet have created the item, but from them on each discovery run will find the same discovered item prototypes, and they will just continue to exist and the send into the trapper will populate the data. That's sort of cheating as it's both an external LLD and also an external check of sorts (not a regular external check which is polled, it's a zabbix trap which is pushed).

    Comment

    • corak
      Junior Member
      • Aug 2018
      • 2

      #3
      Thanks! I used the trapper as you described to implement this.

      Comment

      • SuNova
        Junior Member
        • Oct 2018
        • 1

        #4
        I think adding such feature is great when working with ODBC LLD.
        Consider following LLD query:
        ```
        select name as disk_name, mount_status, header_status, mode_status, os_mb, total_mb, free_mb, name, state from v$asm_disk_stat;
        ```
        Now if we could use {#TOTAL_MB} and {#FREE_MB} in item prototypes, there was no need to writing separate queries for items "ASM disk: {#DISK_NAME}: total space" and "ASM disk: {#DISK_NAME}: free space"

        Comment

        Working...