Announcement

Collapse
No announcement yet.

Your company logo to graphs

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Your company logo to graphs

    Some of us might need to distribute graphs to 3rd parties. It would nice to have company logo on the graph, that you don't have to that via photo editor.

    This is not the final solution I'd like to have, but this is working. What would be nice is to upload background/icon to Zabbix, and define by "theme" or by graph-template that attach that uploaded background/icon to every graph. Or add free copyright notice as a text.

    However here is my quick fix.
    • Upload picture to zabbix frontend root-directory. Lets say it is "logo.png", and you can use transparency.
    • Attach following patch to /include/classes/class.cgraphdraw.php. Search function drawLogo() and replace it with following code.


    Code:
            public function drawLogo(){
                    imagestringup($this->im,0,$this->fullSizeX-10,$this->fullSizeY-50, 'http://www.zabbix.com', $this->getCol
                    // Add the company logo
                    $stamp = imagecreatefrompng('logo.png');
                    $sx = imagesx($stamp);
                    $sy = imagesy($stamp);
                    $marge_right = 15;
                    $marge_bottom = 15;
                    imagecopy($this->im, $stamp, imagesx($this->im) - $sx - $marge_right, imagesy($this->im) - $sy - $marge_b
            }
    • Based on your logo size and how you want to position the logo, tune marge_right and marge_bottom to suit your needs. Naturally you can change the calculation base of imagecopy to whatever you like, i.e. to position your logo everywhere.
    • I didn't check the drawing order, if you could even position the graph on top you the figure drawn. Just use a lot of transparency if it is supported by GD library at this drawing state.
    Last edited by jhgrc; 12-02-2010, 11:33. Reason: Wrong title

    #2
    What might be nicer would be to store the photo in the db along with all of the other map images.
    RHCE, author of zbxapi
    Ansible, the missing piece (Zabconf 2017): https://www.youtube.com/watch?v=R5T9NidjjDE
    Zabbix and SNMP on Linux (Zabconf 2015): https://www.youtube.com/watch?v=98PEHpLFVHM

    Comment


      #3
      Originally posted by nelsonab View Post
      What might be nicer would be to store the photo in the db along with all of the other map images.
      Well that was the idea of my 2nd paragraph "What would be nice...".

      But the changes to implement this was too big task so I did it quick way.

      Comment


        #4
        Guys,

        I followed your instructions, but no success here...

        # pwd
        /var/www/html/zabbix

        # ls -l logoaz.png
        -rw-r--r-- 1 zabbix apache 12261 Mar 6 13:28 logoaz.png

        What can be wrong ?

        Comment


          #5
          I see that the original patch line ends are not there so something went wrong when I pasted the patch. I attached patch again and now it is complete.


          Code:
                  public function drawLogo(){
                          //imagestringup($this->im,0,$this->fullSizeX-10,$this->fullSizeY-50, 'http://www.zabbix.com', $this->getColor('Gray'));
                          // Add the company logo
                          $stamp = imagecreatefrompng('logo_rotated.png');
                          $sx = imagesx($stamp);
                          $sy = imagesy($stamp);
                          $marge_right = 1;
                          $marge_bottom = 30;
                          //imagecopy($this->im, $stamp, imagesx($this->im) - $sx - $marge_right, imagesy($this->im) - $sy - $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp));
                          imagecopy($this->im, $stamp, imagesx($this->im) - $sx - $marge_right, $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp));
                  }
          Last edited by jhgrc; 09-03-2010, 08:31.

          Comment


            #6
            Man,

            Thank you ... worked here !

            Comment


              #7
              I just added this, and its great. Just one question, I've been playing around with the code to choose different logo's based on your CSS (or graph background color) but I can't seem to get it to work. Does anyone know which graph property is being used to set the background color?

              Comment


                #8
                Originally posted by danrog View Post
                I just added this, and its great. Just one question, I've been playing around with the code to choose different logo's based on your CSS (or graph background color) but I can't seem to get it to work. Does anyone know which graph property is being used to set the background color?
                Not an expert on this but by quickly looking at the code:

                Theme initialization:
                $this->graphtheme = array(...) and 'public function applyGraphTheme' overrides the defaults set by array by loading user's theme.

                $this->graphtheme['backgroundcolor']

                It could hold the color value. It is easy to create debug..

                Add to drawlogo-function and you should see "Color: [some text or hopefully hex value]" at upper left corner printed on gray.

                Code:
                imagestringup($this->im,0,0,0, "Color: " . $this->graphtheme['backgroundcolor'], $this->getColor('Gray'));
                Or if you don't want to look at theme, you could check colorvalue of background pixel before you draw the logo. This is taken from PHP manual, so you are looking at "imagecolorat"-method. Just replace $im with $this->im to refer correct object and you got the actual colorcode.

                Code:
                <?php
                $im = imagecreatefrompng("php.png"); 
                $rgb = imagecolorat($im, 10, 15);
                $r = ($rgb >> 16) & 0xFF;
                $g = ($rgb >> 8) & 0xFF;
                $b = $rgb & 0xFF;
                
                var_dump($r, $g, $b);
                ?>
                Last edited by jhgrc; 09-03-2010, 09:27.

                Comment


                  #9
                  Thanks again jhgrc. I must have been out of it yesterday. I actually was using the background color mentioned above. I was developing on our dev system but testing it on our prod system. I just tested it on the dev system and it works great. I guess that happens when you don't get much sleep the night before. Sorry to waste your time

                  Code:
                  if ($this->graphtheme['backgroundcolor'] == 'f0f0f0') {
                     .........jhgrc's code
                  }

                  Comment


                    #10
                    It is possible to add the logo of the company in backgroud of a map instead of a graph?

                    Thanks for the reply.

                    Comment


                      #11
                      Originally posted by kiuviddo View Post
                      It is possible to add the logo of the company in backgroud of a map instead of a graph?
                      I am not 100% sure what you might want. As on map properties you have selection "background image" where you can have any image you have uploaded to Zabbix. So you could draw a map-image with your logo? This option is not available to graph - hence the dirty and direct code patch.

                      Or naturally you can embed a another image (a logo) in top of map in software. You can almost directly use my code above, but you need to trace what function draws the "http://www.zabbix.com" to a map, then add the code (and modify if needed) to do the job.

                      Comment


                        #12
                        Hi,
                        Have you made any more progress with this? I assume that the current patch only allows 1 image to be associated with graphs. It would be good if different graphs could have different logos.


                        Regards,
                        David

                        Comment


                          #13
                          Originally posted by Yello View Post
                          Have you made any more progress with this?
                          I don't think there is any development on this. I am not a Zabbix developer.

                          I think this should be filed into Zabbix development-system. As logo per graph is database stuff to store a reference which logo is to which graph.

                          If you go to hacking style you could analyze item information of the graph or graph's name with regexp and with if/then/else or switch/case to load separate logo to graph item.

                          Comment


                            #14
                            You can do that from Configure Maps.
                            Below is a sample of a map for our Foreign Exchange division.
                            Not a logo, but the concept is the same.
                            Attached Files

                            Comment


                              #15
                              Originally posted by Zaniwoop View Post
                              You can do that from Configure Maps.
                              Below is a sample of a map for our Foreign Exchange division.
                              Not a logo, but the concept is the same.
                              that one looks quite interesting. would it be possible to add a full-sized one to http://www.zabbix.com/wiki/doc/screenshots ?
                              Zabbix 3.0 Network Monitoring book
                              Zabbix tips and inspiration (blog)

                              Comment

                              Working...
                              X