Ad Widget

Collapse

Retrieving The RESOLVED Item Name From Database?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rrm74001
    Junior Member
    • Nov 2012
    • 9

    #1

    Retrieving The RESOLVED Item Name From Database?

    I am trying to extract some raw data from the backend MySQL database. All I would like to do is print an item name, and the values associated with that item name over a given time period. To get the name of the item, it seems logical to do:

    Code:
    SELECT name FROM items
    WHERE itemid = xxxxx;
    However, for items that are discovered / have placeholders in their name, the names come up as:

    Code:
    Total disk space on $1
    Used disk space on $1
    When I am expecting:

    Code:
    Total disk space on /mnt/xxx/
    Used disk space on /mnt/yyy/
    Is there any way to get the resolved item names?
  • rrm74001
    Junior Member
    • Nov 2012
    • 9

    #2
    I just tried it though the Zabbix API (instead of straight SQL) and I am getting the same '$1' placeholders. The example 'item.get' in the API documentation shows the same problem.

    Is there no way to do this?

    Comment

    • Pavels
      Member
      • Oct 2011
      • 83

      #3
      When it comes to items, there's currently no way to resolve item macros in the API. In the frontend it's done using the PHP function itemName() and a quite complex item key parser. If you're developing in PHP, may be you can just use those.

      Comment

      • rrm74001
        Junior Member
        • Nov 2012
        • 9

        #4
        Originally posted by Pavels
        When it comes to items, there's currently no way to resolve item macros in the API. In the frontend it's done using the PHP function itemName() and a quite complex item key parser. If you're developing in PHP, may be you can just use those.
        Thanks for the reply.

        I switched to PHP, and using the itemName() function, and I am able to get the name of the items that do NOT have macros in them. However, when it attempts to get the name of an item that DOES have a macro, I get the error:

        Code:
        Fatal error: Call to undefined function zbx_strpos() in /var/www/zabbix/include/items.inc.php on line 506
        Line 506 appears to be inside of a function that attempts to resolve the macros inside an item key. Is it as simple as me failing to 'require' a file from the include folder?

        Comment

        • Pavels
          Member
          • Oct 2011
          • 83

          #5
          Yeah, you just need the zbx_strpos() function from include/func.inc.php and may be some more functions from other libraries.

          Comment

          • rrm74001
            Junior Member
            • Nov 2012
            • 9

            #6
            Originally posted by Pavels
            Yeah, you just need the zbx_strpos() function from include/func.inc.php and may be some more functions from other libraries.
            Thanks Pavels. I "required" include/item.inc.php, include/func.inc.php, and /api/classes/CItemKey.php and the names are resolving!

            Thanks for your help!

            Comment

            Working...