Ad Widget

Collapse

Zabbix API 3.4 -- Configuration.Import not working for images

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Zabbix API 3.4 -- Configuration.Import not working for images

    Hi,

    We just upgraded from zabbix 3.2 to 3.4.11. We are using the same code to import images from a XML file. I only changed the version number in the XML file to be 3.4:
    <version>3.4</version>

    I put lots of messages to print request, dump, response. Here is the request (python):

    with open('/etc/images.xml','r') as myfile:
    data = myfile.read().replace('\n',' ').replace('\r',' ')
    req = {"jsonrpc":"2.0","method":"configuration.import "," id":1,"auth":auth,"params":{"format":"xml","rule s" :{"images":{"createMissing":True,"updateExisting ": True}},"source":data}}
    dump = json.dumps(req)


    --- When I print the value of dump I see my XML into the "dump" string, all in 1 line but with 8 <image> nodes; it is supposed to create 8 images in the "images" table.

    request = urllib2.Request('http://localhost/zabbix/api_jsonrpc.php',dump,{'Content-Type': 'application/json'})
    response = urllib2.urlopen(request)
    res = json.load(response)


    --- when I print the value of res I get: {u'jsonrpc': u'2.0', u'result': True, u'id':1}

    Both the req and res look correct to me according to https://www.zabbix.com/documentation...uration/import

    However, the zabbix images table stays empty. If I manually add data to this table, then run the code above again, the images table gets truncated, no data.

    Any ideas why? Please I've been dealing with this issue since last week and I do not know how to solve it.

    I used the same code with Zabbix API 3.2 and it worked perfectly.
    Also note that I am able to create/load these images into the "images" table using psql: \copy images FROM '/etc/images.csv' delimiter ',' csv
    where I created the csv file from the zabbix 3.2 website when exporting a map.

    Your help with this issue will be very appreciated!
    Last edited by rk325; 14-08-2018, 16:43.

    #2
    Note: I mispelled "rule s" instead of "rules" in the req example above; that happened when I paste & copy the example to this ticket. However my code is correct with "rules" and it is still not adding images to the "images" table.

    Comment


      #3
      What I did noticed is: the API and its examples (https://www.zabbix.com/documentation...uration/import) say to use true not True, and XML not xml (see the case). I am using True and xml:

      "params":{"format":"xml","rules" :{"images":{"createMissing":True,"updateExisting ": True}},"source":data}

      But if I switch these, format value to XML, and the other 2 Booleans to true, I get errors, for example format can only take values xml, json, not XML. Or True is invalid.

      I am reading that validation in configuration.import is very strict: ZBX-3783 added strict validation of input parameters for import() and export() methods

      1 node in my data looks like this (there are more <image> nodes). Is it that the / (forward slash) inside <encodedImage> makes it to fail validation? Do I need to escape it?
      Thanks,


      <?xml version="1.0" encoding="UTF-8"?>
      <zabbix_export>
      <version>3.4</version>
      <date>2018-08-13T15:20:11Z</date>
      <images>
      <image>
      <name>Rackmountable_2U_server_2D_(64)</name>
      <imagetype>1</imagetype>
      <encodedImage>iVBORw0KGgoAAAANSUhEUgAAAEAAAAAJCAYA AACCPip6AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAG7AAABu wBHnU4NQAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9y Z5vuPBoAAARcSURBVEiJrVZLbyNFEP7G4/E7fsd2SGzHSQjerJFYDhwwiBNXEOLGkQuXvfA/+BOcOCGtOMGKC+wKpMjsgsgS80iiZUNix6+x4zz8mDFV5ZnJZM UpbEnt6a6u7qr66tFWAHxA4510Ov3Sa3de//Dlctk8Pz+HkKLIxwNcWztLF8/e8WoaPB7nBPiumcys3xmu08y1a7olgVAoiNhCRNH14bFhTA28A Kpt/5ja3d19EIvFRpFI5Fu2++nGxkZhOByi3W7jjbfeho+Y4XAIXq/XOejz+TCZTGCaJtk8g6qqwptOp7LmeTKVwpP676i+WcXw7AydX g/Hz54iEgqJvPsuwzDkLiaFQAyRzHg8lrv8fj8ymQwe7zzBykoej aM2TlonUDwKbkqaV8PZ6Sl+2/kJq6urKBaL6Ha7z9hDbXNzEzs7OwgEApiRUfqgj3Q6hYuLC+cC NogOCAhMDA7zGIBGo4G1tTXhe8hRxcNRJJAoE9onJ8hsbYEBti mZTMr68vLSuSuXy0kAdF3H+vq6AKa4Mi6zlMVibkl4Nt+ee0k2 m82Ivn+Ojuf7sgfcebUiwbj/9Tfo97rX/On3+wYD8CWhfvfw8PAylUoF+PCAkGJyR200GlFWhB0AOIJseKv VkvXe3p444aHzU8rWCQ1FVdDpdCSyLDuz0p3XHHEbAObzOCNDO Sv29/fJoSzc8U7FFrCcTlglp1gfRWTY8bBfg0HByCVjlvPz08O+jvFk jDCVk2HOq6jZbPbokyCwv2AAajRMTdOawWCwyA6kF7M4ajSv6p s+HYqMg7xl2qOff5kXvxiioNnuUNwV1P/8S5QZhomV1RJana4rfRX0BqdXzlmT2qPHznwwPMMJ36VeleDRc UfG/yHTmANAPWpAvsQpwHWvFQHKXLVIAEgDCwb9WF5aupa21DAk3e2 oMRUKBSkLjq5dEjUCZeuVTap/XeQnwwHisZiTOUzUgKQ52jxVUjgrPM4sLsUl0v/Dds05k0mGcbtyW/R3CdBbt8q4d+8rDAaD/3RWUTWUinl8+ut9fPLRZ/AcUlD2/5A96kFF9pP1MgDvMpPTmwFQyZF2s4H88jISiYSTtrzPGfB8LXP 9c0pXKhVJYecFoHM85/3M4qKcdwPAumwwWY4B5jU7xA1KGqSrBvwkz6+C6lFJbgQ/gVRaX0MsGqPHw0SPAC/Rue8fPKSUn0oJ+gM+fJcrINB+CM/pCLpVAhws9oVsep8BiDCDGyE76yVjuAx61ME5EnaUuAdEo1FpU jaxwXwRO1Cv1xGPxx0AuAS8lMIXVlTlObTAZOdYp/uuRQKJmy6VovST53vAgMqm09VJhkDq99GmLOAS4xdjRAFQSZdG c2OmzPsPdeKePsQ4ocHr26USjJDeOQDlcln0ky6DdbxXrVY/J0dVakwLhVLJmBCC08nkRm9OMBQywxRNm9qtlkKe3+iuSDRqph LxF/Y/oNk89te2t5P0wv2dz+dnBwcHH/8LA/gbUW7Q6sEAAAAASUVORK5CYII=</encodedImage>
      </image>
      </images>
      </zabbix_export>

      Comment

      Announcement

      Collapse
      No announcement yet.
      Working...
      X