Ad Widget

Collapse

Importing templates from xml won't work

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sebelk
    Member
    • Nov 2007
    • 72

    #1

    Importing templates from xml won't work

    Hi, I've tried to import templates from a XML file and it seems that MySQL ignoress completely. At first glance, I thought that it was because I had to create the empty templates and then update them with XML files, but that wasn't the case....

    Web pages stays loading nothing at all...


    debugging log is as follows:

    26746:20080508:091612 Query [select i.itemid,i.key_,h.host,h.port,i.delay,i.descriptio n,i.nextcheck,i.type,i.snmp_community,i.snmp_oid,h .useip,h.ip,i.history,i.lastvalue,i.prevvalue,i.ho stid,h.status,i.value_type,h.errors_from,i.snmp_po rt,i.delta,i.prevorgvalue,i.lastclock,i.units,i.mu ltiplier,i.snmpv3_securityname,i.snmpv3_securityle vel,i.snmpv3_authpassphrase,i.snmpv3_privpassphras e,i.formula,h.available,i.status,i.trapper_hosts,i .logtimefmt,i.valuemapid,i.delay_flex,h.dns,i.para ms from hosts h, items i where i.nextcheck<=1210248972 and i.status in (0,3) and i.type not in (2,7,9) and h.status=0 and h.disable_until<=1210248972 and h.errors_from=0 and h.hostid=i.hostid and (h.proxy_hostid=0 or i.type in (5)) and mod(i.itemid,5)=0 and i.key_ not in ('status','icmpping','icmppingsec','zabbix[log]') and h.hostid between 000000000000000 and 099999999999999 order by i.nextcheck]
    26750:20080508:091612 In get_values()
    26748:20080508:091612 In get_values()
    26750:20080508:091612 Query [select i.itemid,i.key_,h.host,h.port,i.delay,i.descriptio n,i.nextcheck,i.type,i.snmp_community,i.snmp_oid,h .useip,h.ip,i.history,i.lastvalue,i.prevvalue,i.ho stid,h.status,i.value_type,h.errors_from,i.snmp_po rt,i.delta,i.prevorgvalue,i.lastclock,i.units,i.mu ltiplier,i.snmpv3_securityname,i.snmpv3_securityle vel,i.snmpv3_authpassphrase,i.snmpv3_privpassphras e,i.formula,h.available,i.status,i.trapper_hosts,i .logtimefmt,i.valuemapid,i.delay_flex,h.dns,i.para ms from hosts h, items i where i.nextcheck<=1210248972 and i.status in (0,3) and i.type not in (2,7,9) and h.status=0 and h.disable_until<=1210248972 and h.errors_from=0 and h.hostid=i.hostid and (h.proxy_hostid=0 or i.type in (5)) and mod(i.itemid,5)=4 and i.key_ not in ('status','icmpping','icmppingsec','zabbix[log]') and h.hostid between 000000000000000 and 099999999999999 order by i.nextcheck]
    26748:20080508:091612 Query [select i.itemid,i.key_,h.host,h.port,i.delay,i.descriptio n,i.nextcheck,i.type,i.snmp_community,i.snmp_oid,h .useip,h.ip,i.history,i.lastvalue,i.prevvalue,i.ho stid,h.status,i.value_type,h.errors_from,i.snmp_po rt,i.delta,i.prevorgvalue,i.lastclock,i.units,i.mu ltiplier,i.snmpv3_securityname,i.snmpv3_securityle vel,i.snmpv3_authpassphrase,i.snmpv3_privpassphras e,i.formula,h.available,i.status,i.trapper_hosts,i .logtimefmt,i.valuemapid,i.delay_flex,h.dns,i.para ms from hosts h, items i where i.nextcheck<=1210248972 and i.status in (0,3) and i.type not in (2,7,9) and h.status=0 and h.disable_until<=1210248972 and h.errors_from=0 and h.hostid=i.hostid and (h.proxy_hostid=0 or i.type in (5)) and mod(i.itemid,5)=2 and i.key_ not in ('status','icmpping','icmppingsec','zabbix[log]') and h.hostid between 000000000000000 and 099999999999999 order by i.nextcheck]
    26749:20080508:091612 End get_values()
    26749:20080508:091612 Query [select count(*),min(nextcheck) from items i,hosts h where mod(i.itemid,5)=3 and h.status=0 and h.disable_until<=1210248972 and h.errors_from=0 and h.hostid=i.hostid and i.status in (0,3) and i.type not in (2,7,9) and (h.proxy_hostid=0 or i.type in (5)) and i.key_ not in ('status','icmpping','icmppingsec','zabbix[log]') and h.hostid between 000000000000000 and 099999999999999]
    26749:20080508:091612 No items to update for minnextcheck.
    26746:20080508:091612 End get_values()
    26749:20080508:091612 Poller spent 0.001962 seconds while updating 0 values. Nextcheck: -1 Time: 1210248972
    26746:20080508:091612 Query [select count(*),min(nextcheck) from items i,hosts h where mod(i.itemid,5)=0 and h.status=0 and h.disable_until<=1210248972 and h.errors_from=0 and h.hostid=i.hostid and i.status in (0,3) and i.type not in (2,7,9) and (h.proxy_hostid=0 or i.type in (5)) and i.key_ not in ('status','icmpping','icmppingsec','zabbix[log]') and h.hostid between 000000000000000 and 099999999999999]
    26749:20080508:091612 Sleeping for 5 seconds
    26750:20080508:091612 End get_values()
    26750:20080508:091612 Query [select count(*),min(nextcheck) from items i,hosts h where mod(i.itemid,5)=4 and h.status=0 and h.disable_until<=1210248972 and h.errors_from=0 and h.hostid=i.hostid and i.status in (0,3) and i.type not in (2,7,9) and (h.proxy_hostid=0 or i.type in (5)) and i.key_ not in ('status','icmpping','icmppingsec','zabbix[log]') and h.hostid between 000000000000000 and 099999999999999]
    26747:20080508:091612 End get_values()
    26747:20080508:091612 Query [select count(*),min(nextcheck) from items i,hosts h where mod(i.itemid,5)=1 and h.status=0 and h.disable_until<=1210248972 and h.errors_from=0 and h.hostid=i.hostid and i.status in (0,3) and i.type not in (2,7,9) and (h.proxy_hostid=0 or i.type in (5)) and i.key_ not in ('status','icmpping','icmppingsec','zabbix[log]') and h.hostid between 000000000000000 and 099999999999999]
    26750:20080508:091612 No items to update for minnextcheck.
    26746:20080508:091612 No items to update for minnextcheck.
    26750:20080508:091612 Poller spent 0.002664 seconds while updating 0 values. Nextcheck: -1 Time: 1210248972
    26746:20080508:091612 Poller spent 0.002618 seconds while updating 0 values. Nextcheck: -1 Time: 1210248972
    26750:20080508:091612 Sleeping for 5 seconds
    26746:20080508:091612 Sleeping for 5 seconds
    26747:20080508:091612 No items to update for minnextcheck.
    26747:20080508:091612 Poller spent 0.003194 seconds while updating 0 values. Nextcheck: -1 Time: 1210248972
    26748:20080508:091612 End get_values()
    26747:20080508:091612 Sleeping for 5 seconds
    26748:20080508:091612 Query [select count(*),min(nextcheck) from items i,hosts h where mod(i.itemid,5)=2 and h.status=0 and h.disable_until<=1210248972 and h.errors_from=0 and h.hostid=i.hostid and i.status in (0,3) and i.type not in (2,7,9) and (h.proxy_hostid=0 or i.type in (5)) and i.key_ not in ('status','icmpping','icmppingsec','zabbix[log]') and h.hostid between 000000000000000 and 099999999999999]
    26748:20080508:091612 No items to update for minnextcheck.
    26748:20080508:091612 Poller spent 0.003767 seconds while updating 0 values. Nextcheck: -1 Time: 1210248972

    what can I do ??
    Last edited by sebelk; 08-05-2008, 14:23.
  • Aly
    ZABBIX developer
    • May 2007
    • 1126

    #2
    Thanks for reporting it. Server side is nothing to do with that..

    Try to apply this diff:
    Attached Files
    Zabbix | ex GUI developer

    Comment

    • sebelk
      Member
      • Nov 2007
      • 72

      #3
      Originally posted by Aly
      Thanks for reporting it. Server side is nothing to do with that..

      Try to apply this diff:
      And it continues doing nothing despite the patch

      Comment

      • sebelk
        Member
        • Nov 2007
        • 72

        #4
        Just in case:

        I restarted apache and zabbix.... please what can I do?

        Comment

        • Aly
          ZABBIX developer
          • May 2007
          • 1126

          #5
          You don't need to restart httpd server or zabbix..

          What the browser is showing after it stops loading?

          Also check Apache error logs..
          Zabbix | ex GUI developer

          Comment

          • sebelk
            Member
            • Nov 2007
            • 72

            #6
            Originally posted by Aly
            You don't need to restart httpd server or zabbix..
            What the browser is showing after it stops loading?

            It shows nothing... just mouse pointer showing that is waiting....[/QUOTE]

            Also check Apache error logs..

            /var/log/httpd/ssl_error_log

            [Thu May 08 11:27:28 2008] [error] [client 10.30.0.101] File does not exist: /var/www/html/favicon.ico
            [Thu May 08 11:32:26 2008] [warn] RSA server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
            [Thu May 08 11:32:26 2008] [warn] RSA server certificate CommonName (CN) `localhost.localdomain' does NOT match server name!?

            /var/log/httpd/ssl_access_log
            10.30.0.101 - - [08/May/2008:12:51:46 -0300] "POST /zabbix-1.5/dashboard.php?output=html HTTP/1.1" 200 320
            10.30.0.101 - - [08/May/2008:12:51:46 -0300] "POST /zabbix-1.5/dashboard.php?output=html HTTP/1.1" 200 328
            10.30.0.101 - - [08/May/2008:12:52:41 -0300] "GET /zabbix-1.5/exp_imp.php HTTP/1.1" 200 7785
            10.30.0.101 - - [08/May/2008:12:52:44 -0300] "GET /zabbix-1.5/items.php HTTP/1.1" 200 8985
            10.30.0.101 - - [08/May/2008:12:53:00 -0300] "GET /zabbix-1.5/items.php?showdisabled=1 HTTP/1.1" 200 9137
            10.30.0.101 - - [08/May/2008:12:53:02 -0300] "GET /zabbix-1.5/items.php?showdisabled=0 HTTP/1.1" 200 9137
            10.30.0.101 - - [08/May/2008:12:53:12 -0300] "GET /zabbix-1.5/authentication.php HTTP/1.1" 200 7886
            10.30.0.101 - - [08/May/2008:12:53:14 -0300] "GET /zabbix-1.5/items.php HTTP/1.1" 200 8985
            10.30.0.101 - - [08/May/2008:12:58:57 -0300] "GET /zabbix-1.5/exp_imp.php HTTP/1.1" 200 7776
            10.30.0.101 - - [08/May/2008:12:59:03 -0300] "POST /zabbix-1.5/exp_imp.php HTTP/1.1" 200 7890

            And this the import.inc.php

            <?php
            /*
            ** ZABBIX
            ** Copyright (C) 2000-2005 SIA Zabbix
            **
            ** This program is free software; you can redistribute it and/or modify
            ** it under the terms of the GNU General Public License as published by
            ** the Free Software Foundation; either version 2 of the License, or
            ** (at your option) any later version.
            **
            ** This program is distributed in the hope that it will be useful,
            ** but WITHOUT ANY WARRANTY; without even the implied warranty of
            ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
            ** GNU General Public License for more details.
            **
            ** You should have received a copy of the GNU General Public License
            ** along with this program; if not, write to the Free Software
            ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
            **/
            require_once "include/defines.inc.php";
            include_once "include/hosts.inc.php";
            ?>
            <?php
            class CZabbixXMLImport{
            function CZabbixXMLImport(){
            global $USER_DETAILS;

            $this->main_node= null;
            $this->sub_node = null;
            $this->data = null;
            $this->host = array('exist' => 0, 'missed' => 0);
            $this->template = array('exist' => 0, 'missed' => 0);
            $this->item = array('exist' => 0, 'missed' => 0);
            $this->trigger = array('exist' => 0, 'missed' => 0);
            $this->graph = array('exist' => 0, 'missed' => 0);

            $this->available_groups = get_accessible_groups_by_user($USER_DETAILS, PERM_READ_WRITE, PERM_RES_IDS_ARRAY, get_current_nodeid());

            $this->available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_WRITE, PERM_RES_IDS_ARRAY, get_current_nodeid());

            $this->available_nodes = get_accessible_nodes_by_user($USER_DETAILS, PERM_READ_WRITE, null, PERM_RES_IDS_ARRAY, get_current_nodeid());
            }

            function CharacterData($parser, $data) {
            $this->element_data .= html_entity_decode($data);
            }

            function StartElement($parser, $name, $attrs) {
            $this->element_data = '';

            if(!isset($this->root)){
            if($name == XML_TAG_ZABBIX_EXPORT)
            if(isset($attrs['version']))
            if($attrs['version'] == '1.0'){
            $this->root = true;
            return;
            }
            else{
            error(S_UNSUPPORTED_VERSION_OF_IMPORTED_DATA);
            }
            error(S_UNSUPPORTED_FILE_FORMAT);
            $this->root = false;
            }
            else if(!$this->root){
            return false;
            }

            $data = &$this->data[$name];

            foreach($attrs as $id => $val)
            $attrs[$id] = html_entity_decode($val);

            switch($name){
            case XML_TAG_HOST:
            $this->main_node= array($name);
            $this->sub_node = null;
            $data = $attrs;
            $data['groups'] = array();
            $data['skip'] = false;

            if($host_data = DBfetch(DBselect('select hostid from hosts'.
            ' where host='.zbx_dbstr($data['name']).
            ' and '.DBin_node('hostid',get_current_nodeid(false)))))
            { /* exist */
            if($this->host['exist']==1) /* skip */{
            $data['skip'] = true;
            info('Host ['.$data['name'].'] skipped - user rule');
            break; // case
            }


            Thanks in advance

            Comment

            • Aly
              ZABBIX developer
              • May 2007
              • 1126

              #7
              If the mouse shows waiting than it's obviously that the browser haven't stopped loading page yet. Wait till the browsers status bar will show 'Done'.

              P.S. anybody else having problem with import after applying the diff?
              Zabbix | ex GUI developer

              Comment

              • sebelk
                Member
                • Nov 2007
                • 72

                #8
                Originally posted by Aly
                If the mouse shows waiting than it's obviously that the browser haven't stopped loading page yet. Wait till the browsers status bar will show 'Done'.

                P.S. anybody else having problem with import after applying the diff?
                Hi Aly, Are you serious? How many hours should I wait?

                I've repeated again and again the operation, but unless I am
                hallucinating...

                As I said earlier, it's doing nothing, is the same situation before the patching....


                I checked if changing from root to apache as owner of frontend files, but it didn't work either

                Again, part of zabbig logs:


                3442:20080509:085522 Query [select count(*),min(nextcheck) from items i,hosts h where mod(i.itemid,5)=3 and h.status=0 and h.disable_until<=1210334122 and h.errors_from=0 and h.hostid=i.hostid and i.status in (0,3) and i.type not in (2,7,9) and (h.proxy_hostid=0 or i.type in (5)) and i.key_ not in ('status','icmpping','icmppingsec','zabbix[log]') and h.hostid between 000000000000000 and 099999999999999]
                3439:20080509:085522 End get_values()
                3439:20080509:085522 Query [select count(*),min(nextcheck) from items i,hosts h where mod(i.itemid,5)=0 and h.status=0 and h.disable_until<=1210334122 and h.errors_from=0 and h.hostid=i.hostid and i.status in (0,3) and i.type not in (2,7,9) and (h.proxy_hostid=0 or i.type in (5)) and i.key_ not in ('status','icmpping','icmppingsec','zabbix[log]') and h.hostid between 000000000000000 and 099999999999999]
                3441:20080509:085522 No items to update for minnextcheck.
                3441:20080509:085522 Poller spent 0.022574 seconds while updating 0 values. Nextcheck: -1 Time: 1210334122
                3441:20080509:085522 Sleeping for 5 seconds
                3443:20080509:085522 No items to update for minnextcheck.
                3440:20080509:085522 End get_values()
                3443:20080509:085522 Poller spent 0.022497 seconds while updating 0 values. Nextcheck: -1 Time: 1210334122
                3440:20080509:085522 Query [select count(*),min(nextcheck) from items i,hosts h where mod(i.itemid,5)=1 and h.status=0 and h.disable_until<=1210334122 and h.errors_from=0 and h.hostid=i.hostid and i.status in (0,3) and i.type not in (2,7,9) and (h.proxy_hostid=0 or i.type in (5)) and i.key_ not in ('status','icmpping','icmppingsec','zabbix[log]') and h.hostid between 000000000000000 and 099999999999999]
                3442:20080509:085522 No items to update for minnextcheck.
                3443:20080509:085522 Sleeping for 5 seconds
                3439:20080509:085522 No items to update for minnextcheck.
                3439:20080509:085522 Poller spent 0.019516 seconds while updating 0 values. Nextcheck: -1 Time: 1210334122
                3439:20080509:085522 Sleeping for 5 seconds
                3440:20080509:085522 No items to update for minnextcheck.
                3442:20080509:085522 Poller spent 0.023202 seconds while updating 0 values. Nextcheck: -1 Time: 1210334122
                3440:20080509:085522 Poller spent 0.020044 seconds while updating 0 values. Nextcheck: -1 Time: 1210334122
                3442:20080509:085522 Sleeping for 5 seconds
                3440:20080509:085522 Sleeping for 5 seconds

                ----

                I am attaching xml file...

                Comment

                • sebelk
                  Member
                  • Nov 2007
                  • 72

                  #9
                  Is there a limit for import?

                  I've found that editing xml file and importing only one template I could import. But believe me that mysql was doing nothing before that. Original xml file has 2.4 M, the trimmed file 757K...

                  Comment

                  • Aly
                    ZABBIX developer
                    • May 2007
                    • 1126

                    #10
                    In my tests, importing 3M xml file took about 2min, with no problem.
                    Zabbix | ex GUI developer

                    Comment

                    Working...