Ad Widget

Collapse

can't create image in 1.8

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • simonc
    Member
    • Jul 2009
    • 73

    #16

    Comment

    • bcomv
      Junior Member
      • Dec 2009
      • 2

      #17
      Looks like problem is somewhere in database, server's log is full of messages like:
      Code:
      zabbix:/var/log/zabbix-server# tail zabbix_server.log
       20712:20091211:120130.376 [Z3005] Query failed: [1146] Table 'zabbix.hosts' doesn't exist [select distinct i.itemid,i.key_,h.host,h.port,i.delay,i.description,i.type,h.useip,h.ip,i.history,i.lastvalue,i.prevvalue,i.hostid,i.value_type,i.delta,i.prevorgvalue,i.lastclock,i.units,i.multiplier,i.formula,i.status,i.valuemapid,h.dns,i.trends,i.lastlogsize,i.data_type,i.mtime from hosts h,items i, functions f where h.hostid=i.hostid and h.status=0 and i.status=0 and f.function in ('nodata','date','dayofweek','time','now') and i.itemid=f.itemid and (h.maintenance_status=0 or h.maintenance_type=0) and h.hostid between 000000000000000 and 099999999999999]
      Recreating database solves the problem with images, but I'm unable to import old xml with hosts and templates

      Comment

      • simonc
        Member
        • Jul 2009
        • 73

        #18
        Originally posted by bcomv
        Looks like problem is somewhere in database, server's log is full of messages like:
        Code:
        zabbix:/var/log/zabbix-server# tail zabbix_server.log
         20712:20091211:120130.376 [Z3005] Query failed: [1146] Table 'zabbix.hosts' doesn't exist [select distinct i.itemid,i.key_,h.host,h.port,i.delay,i.description,i.type,h.useip,h.ip,i.history,i.lastvalue,i.prevvalue,i.hostid,i.value_type,i.delta,i.prevorgvalue,i.lastclock,i.units,i.multiplier,i.formula,i.status,i.valuemapid,h.dns,i.trends,i.lastlogsize,i.data_type,i.mtime from hosts h,items i, functions f where h.hostid=i.hostid and h.status=0 and i.status=0 and f.function in ('nodata','date','dayofweek','time','now') and i.itemid=f.itemid and (h.maintenance_status=0 or h.maintenance_type=0) and h.hostid between 000000000000000 and 099999999999999]
        Recreating database solves the problem with images, but I'm unable to import old xml with hosts and templates

        I have no such errors in my logs.

        Comment

        • nessatse
          Junior Member
          • Dec 2009
          • 2

          #19
          Originally posted by simonc
          I have no such errors in my logs.
          Neither have I. No errors in any logs, zabbix or apache

          Comment

          • Vedmak
            Member
            • Feb 2009
            • 34

            #20
            For people who has no errors but image importing doesn't work, try to change images.inc.php:102 to be following

            Code:
            ' VALUES ('.$imageid.','.zbx_dbstr($name).','.$imagetype.',"'.addslashes($image).'")');
            Not sure it helps, but it's easy to try and check.

            Comment

            • simonc
              Member
              • Jul 2009
              • 73

              #21
              Originally posted by Vedmak
              For people who has no errors but image importing doesn't work, try to change images.inc.php:102 to be following

              Code:
              ' VALUES ('.$imageid.','.zbx_dbstr($name).','.$imagetype.',"'.addslashes($image).'")');
              Not sure it helps, but it's easy to try and check.

              No change for me. Always the same problem.

              Comment

              • kleytonn
                Junior Member
                • Dec 2009
                • 17

                #22
                Hi,

                This zabbix version is handsome!!! My MySQL Database load down much with this new version!! Congratulations for all!!

                I have this same problem. I upgrade from 1.6.6 for 1.8 with instructions from de zabbix manual ( backup, drop indexes... ) but a can't upload any image.

                Thank's

                Comment

                • kleytonn
                  Junior Member
                  • Dec 2009
                  • 17

                  #23
                  Originally posted by simonc
                  No change for me. Always the same problem.
                  Hi,

                  This solution resolve to me. Now the image upload works fine!

                  Thank's people!

                  Comment

                  • rgg
                    Junior Member
                    Zabbix Certified Specialist
                    • Nov 2009
                    • 4

                    #24
                    Originally posted by Vedmak
                    For people who has no errors but image importing doesn't work, try to change images.inc.php:102 to be following

                    Code:
                    ' VALUES ('.$imageid.','.zbx_dbstr($name).','.$imagetype.',"'.addslashes($image).'")');
                    Not sure it helps, but it's easy to try and check.

                    Solution also didn't work for me.

                    Comment

                    • brian
                      Member
                      • Dec 2009
                      • 45

                      #25
                      Originally posted by rgg
                      Solution also didn't work for me.


                      change line 102 in include/images.inc.php to:
                      ' VALUES ('.$imageid.','.zbx_dbstr($name).','.$imagetype.', 0x'.bin2hex($image).')');

                      Change line 163 to:
                      $sql='UPDATE images SET name='.zbx_dbstr($name).',imagetype='.zbx_dbstr($i magetype).',image='.'0x'.bin2hex($image).

                      Comment

                      • Palmertree
                        Senior Member
                        • Sep 2005
                        • 746

                        #26
                        We are having the same issue where images are not getting saved to the BLOB field in the images table. The hack below works but sometimes causes issues with some PNG icon images where they do not show up when you have a background image. If we import the same png icon in older versions of Zabbix and then use the 1.8 GUI everything works fine.

                        Is bin2hex a supported solution?

                        Originally posted by brian
                        https://support.zabbix.com/browse/ZBX-1494

                        change line 102 in include/images.inc.php to:
                        ' VALUES ('.$imageid.','.zbx_dbstr($name).','.$imagetype.', 0x'.bin2hex($image).')');

                        Change line 163 to:
                        $sql='UPDATE images SET name='.zbx_dbstr($name).',imagetype='.zbx_dbstr($i magetype).',image='.'0x'.bin2hex($image).

                        Comment

                        • richlv
                          Senior Member
                          Zabbix Certified Trainer
                          Zabbix Certified SpecialistZabbix Certified Professional
                          • Oct 2005
                          • 3112

                          #27
                          Originally posted by Palmertree
                          Is bin2hex a supported solution?
                          it's not. however, finding that it works fine with previous versions with same db/php versions is relevant - please add that to the bugreport, thanks.
                          Zabbix 3.0 Network Monitoring book

                          Comment

                          • Palmertree
                            Senior Member
                            • Sep 2005
                            • 746

                            #28
                            Using bin2hex causes some png images not to display correctly when you have a background image. The png images are getting placed behind the background.

                            Comment

                            • richlv
                              Senior Member
                              Zabbix Certified Trainer
                              Zabbix Certified SpecialistZabbix Certified Professional
                              • Oct 2005
                              • 3112

                              #29
                              this is indeed an important problem, but there are some issues with it.

                              1. developers can't reproduce it;

                              2. according to the debugging output posted on the issue, zabbix frontend is sending a correct request to the db to store the image... and receiving incorrect data back later.

                              maybe somebody is interested enough to find exact revision where it started to have problems for them ?
                              Zabbix 3.0 Network Monitoring book

                              Comment

                              • Palmertree
                                Senior Member
                                • Sep 2005
                                • 746

                                #30
                                Problem Solved

                                Problem Solved

                                In Summary:
                                This problem of storing images is not a Zabbix code problem, but how the database default character set is setup on the Zabbix database and the image table.

                                This fixed my issue:
                                Code:
                                USE zabbix;
                                ALTER DATABASE zabbix charset=utf8;
                                ALTER TABLE images charset=utf8;
                                How Resolution was determined:
                                After looking at HEX dumps on the blob column of the images, I was able to figure out what was going on between the previous versions of Zabbix and the current version.

                                Current version of Zabbix sets the characters sets for SQL queries to UTF8
                                Time:0.000779 SQL: SET NAMES utf8
                                Time:0.000552 SQL: SET CHARACTER SET utf8
                                while older versions did not. Which makes sense since 1.8 is utf8 aware now.

                                If UTF8 default character set is not set for the database and the image table, hex 3F is stored because of an invalid translation between the client and the SQL server. Comparing a good image save and a bad one, I could see a lot of 3F hex codes when viewing the blob field.

                                Code:
                                Determine the hexadecimal value of the character or characters that are not being displayed correctly.
                                
                                You can obtain this information for a column column_name in the table table_name using the following query:
                                
                                SELECT HEX(column_name)
                                FROM table_name;
                                
                                3F is the encoding for the ? character; this means that ? is the character actually stored in the column. This most often happens because of a problem converting a particular character from your client character set to the target character set.
                                In the Zabbix documentation it tells us to create the database so it supports UTF8. I think the issue is that people running previous versions did not change the default character set of the database to UTF8. I found that changing the table "images" to UTF8 character set alone was not good enough but you also have to change the default character set of the database itself. Maybe a MySQL UTF8 check can be done on the config screen where the php version, GD version, etc is checked? Just a thought. :-)

                                This MySQL setup will have problems storing images correctly into MySQL:
                                Code:
                                [FONT=Courier New]mysql> SHOW VARIABLES LIKE 'char%';
                                
                                +--------------------------+--------------------------------+
                                | Variable_name            | Value                          |
                                +--------------------------+--------------------------------+
                                | character_set_client     | utf8                           |
                                | character_set_connection | utf8                           |
                                | character_set_database   | latin1                         |
                                | character_set_filesystem | binary                         |
                                | character_set_results    | utf8                           |
                                | character_set_server     | latin1                         |
                                | character_set_system     | utf8                           |
                                | character_sets_dir       | /var/lib/mysql/mysql/charsets/ |
                                +--------------------------+--------------------------------+[/FONT]
                                8 rows in set
                                This setup will work and will store images correctly into MySQL:
                                Code:
                                [FONT=Courier New]mysql> SHOW VARIABLES LIKE 'char%';
                                
                                +--------------------------+--------------------------------+
                                | Variable_name            | Value                          |
                                +--------------------------+--------------------------------+
                                | character_set_client     | utf8                           |
                                | character_set_connection | utf8                           |
                                | character_set_database   | utf8                           |
                                | character_set_filesystem | binary                         |
                                | character_set_results    | utf8                           |
                                | character_set_server     | latin1                         |
                                | character_set_system     | utf8                           |
                                | character_sets_dir       | /var/lib/mysql/mysql/charsets/ |
                                +--------------------------+--------------------------------+
                                8 rows in set[/FONT]
                                Curious if this fixed anyone else having the same issue.
                                Last edited by Palmertree; 24-01-2010, 04:15.

                                Comment

                                Working...