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

Template Import / Export

XMLWordPrintable

    • Icon: Incident report Incident report
    • Resolution: Won't fix
    • Icon: Minor Minor
    • None
    • 2.2.13
    • API (A), Frontend (F)
    • Ubuntu 14.04.4 LTS 64Bit, Zabbix built from source, MySQL 5.5.49-0ubuntu0.14.04.1, PHP 5.5.9-1ubuntu4.17, Apache 2.4.7-1ubuntu4.10.

      Hi.

      I'm having issues exporting templates from one of our zabbix servers and importing them on another node. On the node where the template is imported, the template has no triggers. I have hacked a solution to a part of the problem but not all.

      We are still using Zabbix 2.2 and it's DM.

      With the debugging enabled in the GUI I noticed that (what I think is) the SQL query to see if the trigger already exists looks only for triggers that match the name and expression. In our DM environment this query running on the "master" returns an identical trigger that exists on one of the "child" nodes. It then fails to create the triggers in the template on the "master" node. Sorry if I'm explaining this poorly.

      What I see is the "SELECT t.trigger,t.expression...." (CImportReferencer.php:732) query run and then the subsiquent queries refer to the trigger by a triggerid that is in the wrong range of IDs (2xxxxxxxxxxxxxx instead of 1xxxxxxxxxxxxxx). If I hand edit the template XML so that the trigger name is unique, the triggers are created properly.

      I hacked in a solution that involves changing the above query. I've never done any Zabbix coding before and I'm an amateur at PHP at best so please excuse the ugliness. I think that this would also stop non-template imports from working properly. Anyway....

      In "include/classes/import/CImportReferencer.php", in the "selectTriggers()" function at about line 724 I did this:
      ```
      $templateid = array_pop($this->templatesRefs);
      $sql = 'SELECT t.triggerid,t.expression,t.description'.
      ' FROM triggers t'.
      ' WHERE triggerid IN (SELECT triggerid FROM functions WHERE itemid IN (SELECT itemid FROM items WHERE hostid = '.$templateid.')) AND '.dbConditionString('t.description', array_keys($this->triggers));
      ```

      With this change, the normal triggers successfully import. The trigger prototypes attached to discovery rules still fail to import.

      There is one more oddity that might be related. Some triggers are not synchronising from the child nodes to the master node. Since this synchronisation is done by the zabbix_server processes themselves, I can't see an obvious way they could be related but I thought I'd mention it here anyway, just in case.

      Please let me know if you need any further clarification on any points.

      Thanks.
      Shaun.

            Unassigned Unassigned
            shaun.maher@mach.com.au Shaun Maher
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: