Ad Widget

Collapse

v 1.8.1 Insert image into maps

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sergio.cricca
    Member
    • Mar 2008
    • 43

    #1

    v 1.8.1 Insert image into maps

    I get problems inserting image into MAPS.

    i need to insert a "internet cloud" between my router hosts as image.
    i uploaded many custom images to zabbix and a cloud image too.

    when i try to insert the element like "image" (not as "host" or "host group" since anything is related to that image, but it should be only a visual element) into my map, i get the default one and cannot change it (even if i change it on the form...)

    I cannot change "image" element label as well...

    zabbix is v1.8.1

    How can i fix it?
    thank you in advance
  • sergio.cricca
    Member
    • Mar 2008
    • 43

    #2
    Found the problem:

    mysql> select * from sysmaps_elements where elementtype='4';
    +------------+----------+-----------+-------------+------------+-----------+----------------+-------------+----------------+-----+-----+-----+-----------------+--------------------+
    | selementid | sysmapid | elementid | elementtype | iconid_off | iconid_on | iconid_unknown | label | label_location | x | y | url | iconid_disabled | iconid_maintenance |
    +------------+----------+-----------+-------------+------------+-----------+----------------+-------------+----------------+-----+-----+-----+-----------------+--------------------+
    | 41 | 5 | 0 | 4 | 31 | 0 | 0 | New Element | 0 | 552 | 166 | | 0 | 0 |
    +------------+----------+-----------+-------------+------------+-----------+----------------+-------------+----------------+-----+-----+-----+-----------------+--------------------+
    1 row in set (0.00 sec)


    mysql> update sysmaps_elements set elementid='60' where elementtype='4';
    Query OK, 1 row affected (0.05 sec)
    Rows matched: 1 Changed: 1 Warnings: 0

    mysql> select * from sysmaps_elements where elementtype='4';
    +------------+----------+-----------+-------------+------------+-----------+----------------+-------------+----------------+-----+-----+-----+-----------------+--------------------+
    | selementid | sysmapid | elementid | elementtype | iconid_off | iconid_on | iconid_unknown | label | label_location | x | y | url | iconid_disabled | iconid_maintenance |
    +------------+----------+-----------+-------------+------------+-----------+----------------+-------------+----------------+-----+-----+-----+-----------------+--------------------+
    | 41 | 5 | 60 | 4 | 31 | 0 | 0 | New Element | 0 | 552 | 166 | | 0 | 0 |
    +------------+----------+-----------+-------------+------------+-----------+----------------+-------------+----------------+-----+-----+-----+-----------------+--------------------+
    1 row in set (0.00 sec)

    mysql>



    In first "select" you can see elementid = 0
    when i change elementid field to something != 0 then i can configure image item into map!

    Probably something in PHP is not assigning the right ID to image items...

    Will check it later :-)

    Comment

    • sergio.cricca
      Member
      • Mar 2008
      • 43

      #3
      Found the problem.

      in js/class.cmap.js it's not well managed the APPLY button when elementid = 0

      if i click on APPLY on a IMAGE item i got no result into javascript debugger.
      if i click on APPLY on any other item i get something like:
      ZBX_SYSMAPS[0].map.add_selement({selementid: "19", sysmapid: "2", elementid: "6", elementtype: "3", iconid_off: "7", iconid_on: "0", iconid_unknown: "0", label: "asdasdasdas", label_location: "2", x: "129", y: "61", url: "", iconid_disabled: "0", iconid_maintenance: "0", elementName: "TEST Group", image: "7"});


      looking for the bugged function... :-)

      Comment

      • kiselev
        Junior Member
        • Feb 2010
        • 10

        #4
        Very well, but I not see patch?!

        Comment

        • sergio.cricca
          Member
          • Mar 2008
          • 43

          #5
          i'm looking for the bugged function... it's not so easy... when i get the point i will post the patch we need :-)

          Comment

          • Aly
            ZABBIX developer
            • May 2007
            • 1126

            #6
            It would be much easier just to upgrade only frontned to pre 1.8.2, or you're getting fun by understanding js for maps?

            P.S. the other way could be looking into svn changes that fixes this problem.
            Last edited by Aly; 02-03-2010, 12:56.
            Zabbix | ex GUI developer

            Comment

            • sergio.cricca
              Member
              • Mar 2008
              • 43

              #7
              i got the point...
              LINE 2449-2461 (file: js/class.cmap.js)


              if((params.elementid == 0) && (params.elementtype.toString() != '4' )){
              switch(params.elementtype.toString()){
              //host
              case '0': this.info('Host is not selected.'); break;
              //map
              case '1': this.info('Map is not selected.'); break;
              //tr
              case '2': this.info('Trigger is not selected.'); break;
              //hg
              case '3': this.info('Host group is not selected.'); break;
              // image
              //case '4':
              //default:

              }

              return false;
              }

              the original code was trying to show error (and return false) if there was a problem by adding a map/trigger/host/host group to the map.
              the error is that case '4' means image item and it was always seen as error without any popup (code:
              case '4':
              default:
              )
              In that way in any case item '4' (image) would return false.

              by using if control:
              if((params.elementid == 0 && params.elementtype.toString() != '4' )){

              you can skip checking image items for errors (since images don't have any particular info needed!!)

              Comment

              • sergio.cricca
                Member
                • Mar 2008
                • 43

                #8
                released patch file here: https://support.zabbix.com/browse/ZBX-2097

                posting it here as well
                Attached Files

                Comment

                • sergio.cricca
                  Member
                  • Mar 2008
                  • 43

                  #9
                  Originally posted by Aly
                  It would be much easier just to upgrade only frontned to pre 1.8.2, or you're getting fun by understanding js for maps?

                  P.S. the other way could be looking into svn changes that fixes this problem.
                  upsss... i saw this too late since i didn't refreshed page until now :P

                  But really i got fun understanding all those JS code inside there

                  Comment

                  • kiselev
                    Junior Member
                    • Feb 2010
                    • 10

                    #10
                    I apply patch, but it's not working. See attachment.
                    Attached Files

                    Comment

                    • sergio.cricca
                      Member
                      • Mar 2008
                      • 43

                      #11
                      probably is caused by old JS cached in your browser cache :-)

                      i got same problem while testing it.

                      you need to clear cache and temp files from browser

                      Comment

                      • kiselev
                        Junior Member
                        • Feb 2010
                        • 10

                        #12
                        I clear my cache and my ploblem resolved. Thx

                        Comment

                        • sergeyfromkomi
                          Senior Member
                          • Dec 2009
                          • 126

                          #13
                          Originally posted by kiselev
                          I clear my cache and my ploblem resolved. Thx
                          Добрый день! увы мне этот пач не помог... что я делел не верно...?

                          php5-5.2.12
                          apache-2.0.63_3


                          mybsd2# patch class.cmap.js class.cmap.js.patch
                          Hmm... Looks like a new-style context diff to me...
                          The text leading up to this was:
                          --------------------------
                          |*** js/class.cmap.js 2010-03-02 15:51:24.000000000 +0100
                          |--- js/class.cmap_mod.js 2010-03-02 15:51:25.000000000 +0100
                          --------------------------
                          Patching file class.cmap.js using Plan A...
                          Hunk #1 succeeded at 2445.
                          Hunk #2 succeeded at 2457.
                          done
                          #



                          Администрирование->Изображения->Создать Изображение

                          а так zabbix 1.8.1.2 мне нравится... freebsd 8.0 (многие ошибки вроде исправили..)

                          спасибо....

                          Comment

                          • radamand
                            Member
                            • Aug 2008
                            • 89

                            #14
                            After applying the patch, I cant open any of my maps under "Configuration -> Maps".

                            they're all listed there, but if I try to open one to edit it, I get nothing.

                            backing out of the patch, I can open my maps again, but still cant add images obviously.

                            Comment

                            • radamand
                              Member
                              • Aug 2008
                              • 89

                              #15
                              i must have had a typo, its working now...

                              Comment

                              Working...