Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-11576

Impossible to update existing items on child template via Zabbix API

    XMLWordPrintable

Details

    • Incident report
    • Status: Closed
    • Major
    • Resolution: Cannot Reproduce
    • 3.2.1
    • None
    • API (A), Templates (T)
    • None

    Description

      This appears to be similar to ZBX-10238 and ZBX-10254, but instead of importing templates we are using the Zabbix API to update our templates and items.

      /Library/Ruby/Gems/2.0.0/gems/zabbixapi-2.4.9/lib/zabbixapi/client.rb:90:in `_request': Server answer API error (ZabbixApi::ApiError)
       {
        "code": -32602,
        "message": "Invalid params.",
        "data": "Item with key \"curl[http://169.254.169.254/latest/meta-data/ami-id]\" already exists on \"zabbix-templates_aws_ec2-metadata\"."
      }
       on request:
       {
        "method": "item.update",
        "params": [
          {
            "name": "ami-id",
            "description": "Captures the AMI ID from AWS and adds it to the host inventory under the "OS (Short)" tag.",
            "key_": "curl[http://169.254.169.254/latest/meta-data/ami-id]",
            "delay": 60,
            "type": 7,
            "value_type": 1,
            "history": 7,
            "trends": 365,
            "inventory_link": 7,
            "hostid": 11025,
            "applications": [
              4319
            ],
            "itemid": "243200"
          }
        ],
        "id": 80144,
        "jsonrpc": "2.0",
        "auth": "07bbd994e8b2fa057348ebca8592ee74"
      }
      

      My understanding is that our item.update is failing because the template for this item is linked as a child to a number of other templates.

      This appears to be causing a number of duplicate items to be created in the database, which then causes the SQL query in CItemGeneral.php to flag this as a duplicate item key when updating via the API.

      There appears to be a duplicate item generated in the database for each host that has this template added (one with the host's id and one with the template's id). With 500+ hosts in our db this results in some 500+ copies of this item in the db).

      Here's a subset of those items from the db showing the duplicates:

      itemid key_ hostid host
      242104 curlhttp://169.254.169.254/latest/meta-data/ami-id 11025 zabbix-templates_aws_ec2-metadata
      242396 curlhttp://169.254.169.254/latest/meta-data/ami-id 11025 zabbix-templates_aws_ec2-metadata
      242450 curlhttp://169.254.169.254/latest/meta-data/ami-id 11025 zabbix-templates_aws_ec2-metadata
      242497 curlhttp://169.254.169.254/latest/meta-data/ami-id 11025 zabbix-templates_aws_ec2-metadata
      242544 curlhttp://169.254.169.254/latest/meta-data/ami-id 11025 zabbix-templates_aws_ec2-metadata
      242591 curlhttp://169.254.169.254/latest/meta-data/ami-id 11025 zabbix-templates_aws_ec2-metadata
      242638 curlhttp://169.254.169.254/latest/meta-data/ami-id 11025 zabbix-templates_aws_ec2-metadata
      242685 curlhttp://169.254.169.254/latest/meta-data/ami-id 11025 zabbix-templates_aws_ec2-metadata
      242822 curlhttp://169.254.169.254/latest/meta-data/ami-id 11025 zabbix-templates_aws_ec2-metadata
      242869 curlhttp://169.254.169.254/latest/meta-data/ami-id 11025 zabbix-templates_aws_ec2-metadata
      242916 curlhttp://169.254.169.254/latest/meta-data/ami-id 11025 zabbix-templates_aws_ec2-metadata
      242963 curlhttp://169.254.169.254/latest/meta-data/ami-id 11025 zabbix-templates_aws_ec2-metadata
      243010 curlhttp://169.254.169.254/latest/meta-data/ami-id 11025 zabbix-templates_aws_ec2-metadata
      243057 curlhttp://169.254.169.254/latest/meta-data/ami-id 11025 zabbix-templates_aws_ec2-metadata
      243104 curlhttp://169.254.169.254/latest/meta-data/ami-id 11025 zabbix-templates_aws_ec2-metadata
      243200 curlhttp://169.254.169.254/latest/meta-data/ami-id 11025 zabbix-templates_aws_ec2-metadata

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jrbeilke Jon Beilke
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: