Ad Widget

Collapse

Adding host inside a big template

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nala
    Junior Member
    • Jan 2023
    • 2

    #1

    Adding host inside a big template

    Hello,

    I am trying to add new host in a given hostgroup with a linked template.
    The issue is that this linked template will create automatically somes Applications, triggers, graphs and more than 20k+ items.

    The GUI zabbix can not support such a heavy creation.

    I am creating a pythons script in order to do several request in order to do it.
    The issue is that I am able to collect all the Item created from a current host, but I am blocked in the creation of this item on my new host but got some conflicts on it. I am working on it in order to fix it.
    Let's assume that I managed to fix it,
    Will I be able ,once all my Application/triggers/graph/items created, to linked it to my template normally ?

    I have tried to increase to timeout but with a big template it is still not working well.

    I am using a legacy zabbix server3.4 with zabbix_api on Python 3.6

    How would you work on it ?

    Kindly regards.
  • nala
    Junior Member
    • Jan 2023
    • 2

    #2
    Well I have some issue to get all the item from a given host.

    I managed to get all the item from a host with these function :
    def get_total_items_by_template(template_id): #Works fine, to be used to set up other
    response = zapi.item.get({
    "output": "extend",
    "templateids": template_id,
    "countOutput": True
    })
    return response​

    But I can not parse all the item by batch from the template.
    I try it with a function like this


    def get_items_by_template_batching(template_id, total_items):
    total_items = int(total_items)
    items = []
    start = 0
    limit = 500
    while True:
    print("Items from ", start, " - ", limit+start , "over ",total_items)
    response = zapi.item.get({
    "output": "extend",
    "templateids": template_id,
    "limit": limit,
    "start": start
    })
    items += [item["itemid"] for item in response]
    start += limit
    if (len(items) >= total_items):
    break
    return items[:total_items]​

    But it returns me a list of item

    Comment

    Working...