Ad Widget

Collapse

Count Zabbix Items per host/hostgroup

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jefersonantonio
    Junior Member
    • Jul 2017
    • 3

    #1

    Count Zabbix Items per host/hostgroup

    Hi,

    How can i count the numbers of items per host/hostgroup? Is it possible?

    For example, i have this items below and i need the sum of this items

    Item example 1 - (23)
    Item example 2 - (5)


    sum=28

    You can find more info the image attached.
    Attached Files
  • batchenr
    Senior Member
    • Sep 2016
    • 440

    #2
    Originally posted by jefersonantonio
    Hi,

    How can i count the numbers of items per host/hostgroup? Is it possible?

    For example, i have this items below and i need the sum of this items

    Item example 1 - (23)
    Item example 2 - (5)


    sum=28

    You can find more info the image attached.
    yes,

    go to zabbix GUI-> Configuration -> Hosts
    at the host screen you will see all ur host and there item
    choose one host and press on its items tab
    then you will get to 'item' screen

    there in the filter delete the host name
    and in Name chose the item you want to count name or key under
    key filter

    Comment

    • jefersonantonio
      Junior Member
      • Jul 2017
      • 3

      #3
      Thanks batchenr!
      How can i do that by sql(mysql)? Do you know?

      Comment

      • batchenr
        Senior Member
        • Sep 2016
        • 440

        #4
        Originally posted by jefersonantonio
        Thanks batchenr!
        How can i do that by sql(mysql)? Do you know?
        Hey yes-
        what i did to get it is to run :
        Code:
        watch "mysql -e \"SELECT COMMAND,TIME,STATE, INFO  FROM information_schema.processlist WHERE COMMAND='Query'\""
        and then run the search and see how zabbix run it in the DB.



        the quary should be : change '%ITEM.NAME%' to your item name.
        Code:
        use zabbixdb;
        Code:
        SELECT i.itemid,i.type,i.hostid,i.name,i.key_,i.delay,i.history,i.trends,i.status,i.value_type,i.error,i.templateid,i.flags,i.state FROM items i WHERE i.type<>9 AND i.flags IN (0,4) AND ( (  UPPER(i.name)  LIKE [B]'%ITEM.NAME%'[/B] ESCAPE '!' ) ) ORDER BY i.status LIMIT 1001 OFFSET 0;

        Comment

        • janssenreis
          Member
          • May 2010
          • 64

          #5
          Better to use an API than to do SQL queries.

          Comment

          • Rudlafik
            Senior Member
            • Nov 2018
            • 144

            #6
            {
            "jsonrpc": "2.0",
            "method": "host.get",
            "params": {
            "output": ["hostid"],
            "groupids": "No of Host Group",
            "countOutput": true
            },
            "auth": "Your Auth Key",
            "id": 1
            }

            Comment

            Working...