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

hosts import fails when containing hosts assigned to different proxies

    XMLWordPrintable

Details

    • Team C
    • Sprint 82 (Nov 2021)
    • 0.25

    Description

      Have an export file with 2 hosts assigned to different proxies.
      Importing this file fails with error:

      Proxy "1st test" for host "one" does not exist. [zabbix.php:22 → require_once() → ZBase->run() → ZBase->processRequest() → CController->run() → CControllerPopupImport->doAction() → CApiWrapper->__call() → CFrontendApiWrapper->callMethod() → CApiWrapper->callMethod() → CFrontendApiWrapper->callClientMethod() → CLocalApiClient->callMethod() → CConfiguration->import() → CConfigurationImport->import() → CConfigurationImport->processHosts() → CHostImporter->import() → CHostImporter->resolveHostReferences() in include/classes/import/importers/CHostImporter.php:63]
      

      This wrong SQL is generated during import. Note "AND" in list of proxy names:

      SELECT h.hostid,h.host FROM hosts h WHERE h.status IN (5,6) AND ((UPPER(h.host) LIKE '%1ST TEST%' ESCAPE '!' AND UPPER(h.host) LIKE '%2ND TEST%' ESCAPE '!'))
      

      (also, I'm not sure is this ok to use % around names. why not an exact match is used?)

      Here is proposed patch:

      --- ui/include/classes/import/CImportReferencer.php	2021-10-25 13:42:22.862473343 +0200
      +++ ui/include/classes/import/CImportReferencer.php.new	2021-10-25 13:42:16.234474134 +0200
      @@ -1405,6 +1405,7 @@
       		$this->db_proxies = API::Proxy()->get([
       			'output' => ['host'],
       			'search' => ['host' => array_keys($this->proxies)],
      +			'searchByAny' => true,
       			'preservekeys' => true
       		]);
       
      

      Attachments

        Issue Links

          Activity

            People

              sasha Alexander Vladishev
              zalex_ua Oleksii Zagorskyi
              Votes:
              2 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated: