Ad Widget

Collapse

Zabbix Dynamic PDF Report Generation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • belpir
    Junior Member
    • Jan 2014
    • 2

    #151
    2.2.1. No graphs available

    Hello,
    I run zabbix_server 2.2.1 fresh install on Debian 7.0.3 (GNU/linux-3.2.51-1 x86_64), php 5.4.4-14+deb7u7.
    PDF report was successfully generated but no graphs were included.
    Error log says:
    [error] [client 11.22.33.44] PHP Warning: fopen(/tmp_images/All_671.png): failed to open stream: No such file or directory in /usr/share/zabbix/generatereport.php on line 45, referer: http://zabbix.example.com/pdfform.php
    [error] [client 11.22.33.44] PHP Warning: fwrite() expects parameter 1 to be resource, boolean given in /usr/share/zabbix/generatereport.php on line 46, referer: http://zabbix.example.com/pdfform.php
    [error] [client 11.22.33.44] PHP Warning: fclose() expects parameter 1 to be resource, boolean given in /usr/share/zabbix/generatereport.php on line 47, referer: http://zabbix.example.com/pdfform.php

    Looks like some of PHP functions does not work correctly.


    other info:
    -Does not work with zabbix_report_generation 0.3 beta
    -Does not work with adjusted zabbix_report_generation from answer ID #100 (the same symptoms like 0.3 beta)

    tmp_cookies, tmp_images and data.txt are running with following permissions:
    -rwxrwxrwx 1 root www-data

    config.inc.php
    <?php
    //CONFIGURABLE
    # zabbix server info(user must have API access)
    $z_server = 'http://zabbix.example.com';
    $z_user = 'admin';
    $z_pass = '***********';
    # tmp_images directory path
    $z_img_path = '/tmp_images/';
    # should be the tail of the URL
    $pdf_location = $z_server ."/pdf.php";
    # paper settings
    $paper_format = 'LETTER'; // formats supported: 4A0, 2A0, A0 -> A10, B0 -> B10, C0 -> C10, RA0 -> RA4, SRA0 -> SRA4, LETTER, LEGAL, EXECUTIVE, FOLIO
    $paper_oreintation = 'portrait'; // formats supported: portrait / landscape
    # time zone
    $timezone = 'CET';

    //DO NOT CHANGE BELOW THIS LINE
    $z_tmp_cookies = "";
    $z_url_index = $z_server ."index.php";
    $z_url_graph = $z_server ."chart2.php";
    $z_url_api = $z_server ."api_jsonrpc.php";
    $z_login_data = "name=" .$z_user ."&password=" .$z_pass ."&autologin=1&enter=Sign+in";
    $data = './data.txt';
    ?>

    Could anyone tell me what is wrong?

    Thank you

    Comment

    • belpir
      Junior Member
      • Jan 2014
      • 2

      #152
      No graphs available

      Hello,
      New progress.
      I have created new directory /tmp_images within the filesystem. This directory is now full of *.pnp images, but no graphs are included to the pdf report with following log errors:

      [error] [client 11.22.33.44] PHP Warning: Creating default object from empty value in /usr/share/zabbix/ZabbixAPI.class.php on line 106, referer: http://zabbix.example.com/pdfform.php
      [error] [client 11.22.33.44] PHP Warning: unlink(zabbix_cookie_663.txt): No such file or directory in /usr/share/zabbix/generatereport.php on line 44, referer: http://zabbix.example.com/pdfform.php
      [error] [client 11.22.33.44] PHP Notice: getimagesize(): Read error! in /usr/share/zabbix/class.ezpdf.php on line 1319, referer: http://zabbix.example.com/pdfform.php

      where:
      /usr/share/zabbix/ZabbixAPI.class.php:
      102 public static function debugEnabled($value) {
      103 // Initialize instance if it isn't already
      104 self::__init();
      105 if ($value === TRUE)
      106 self::$instance->debug = true;
      107 else
      108 self::$instance->debug = false;
      109 }

      /usr/share/zabbix/generatereport.php:
      38 // get graph
      39 curl_setopt($ch, CURLOPT_URL, $z_url_graph ."?graphid=" .$graphid ."&width=" .$width ."&height=" .$height ."&period=" .$period);
      40 $output = curl_exec($ch);
      41 curl_close($ch);
      42 // delete cookie
      43 header("Content-type: image/png");
      44 unlink($filename_cookie);
      45 $fp = fopen($image_name, 'w');
      46 fwrite($fp, $output);
      47 fclose($fp);
      48 header("Content-type: text/html");
      49 }
      /usr/share/zabbix/class.ezpdf.php:
      1318 if (!(file_exists($image))) return false; //return immediately if image file does not exist
      1319 $imageInfo = getimagesize($image);
      1320 switch ($imageInfo[2]){
      1321 case 2:
      1322 $type = "jpeg";
      1323 break;
      1324 case 3:
      1325 $type = "png";
      1326 break;
      1327 default:
      1328 return false; //return if file is not jpg or png
      1329 }

      What else do I wrong?
      Thank you.

      Comment

      • amit
        Junior Member
        • Jul 2013
        • 2

        #153
        Exclude Graphs with no data.

        Hello,

        Is there anyway wherein i do not get the graphs in which there is no data & get the graphs which has data in the pdf?

        i use zabbix 2.0.10

        Comment

        • Ferrol
          Junior Member
          • Feb 2014
          • 11

          #154
          Could anyone tell me what is wrong?

          Thank you[/QUOTE]

          Hi Belpir,

          I think your $z_server = 'http://zabbix.example.com'; in 'config.inc.php' should be like this:

          $z_server = 'http://zabbix.example.com/zabbix/';

          Regards,
          ferrol

          Comment

          • Axilla
            Senior Member
            • Aug 2010
            • 130

            #155
            hey all, i have put a copy of this project up on my github. It is latest as of the updates someone posted not to far back. I'm seeking a new job and needed to get some of my work up.

            GitHub is where people build software. More than 150 million people use GitHub to discover, fork, and contribute to over 420 million projects.


            you can fork and work from here if you like! Glad people have kept this project going in my absence! Hopefully I can work on more zabbix stuff again in the near future, but my current job just doesn't allow for it at the moment

            Comment

            • steveboyson
              Senior Member
              • Jul 2013
              • 582

              #156
              I get some warnings in apache's error log:
              Code:
              [Thu Mar 27 01:30:16 2014] [error] [client 192.168.4.104] PHP Notice:  Undefined index:  in /usr/share/zabbix/custom/reports/class.pdf.php on line 1631, referer: https://XXXXXXXXXXXXXXXX/custom/reports/
              (XXXX is a placeholder)

              Also, the report entry page layout and its header look quite garbled, also page 2 and 3. As soon as the graphs start all is ok.
              So the part before the graphs is somewhat messed up. I set "A4" as paper format, maybe this is the problem.

              P.S. In the config.php.inc, the param for paper orientation should be
              "$paper_orientation" and not "$paper_oreintation"

              Comment

              • Ferrol
                Junior Member
                • Feb 2014
                • 11

                #157
                Display graph by group

                Hi all,

                Anyone have successfully changed their zabbix report generation to have option to choose by Host Group? I might need a help here.

                Comment

                • boomer
                  Junior Member
                  • Jun 2011
                  • 13

                  #158
                  Hi all,
                  add a report for "Host Group"
                  --
                  Last edited by boomer; 28-05-2014, 20:56.

                  Comment

                  • Ferrol
                    Junior Member
                    • Feb 2014
                    • 11

                    #159
                    Originally posted by boomer
                    Hi all,
                    add a report for "Host Group"
                    --
                    Hi Boomer,

                    Thank you very much.. It really helps me alot!

                    Btw, do you have configuration to choose the report by certain dates?
                    eg. from 2/5/2015 to 25/5/2014 report? Im not sure whether this can be done of not as Zabbix itself do not have that function.

                    Comment

                    • boomer
                      Junior Member
                      • Jun 2011
                      • 13

                      #160
                      add time period for host and groups
                      selected from filter panel
                      Attached Files

                      Comment

                      • vlam
                        Senior Member
                        Zabbix Certified Specialist
                        • Jun 2009
                        • 166

                        #161
                        I keep on getting this error

                        [Thu May 29 06:04:31 2014] [error] [client *.*.*.*] PHP Parse error: syntax error, unexpected ':' in /var/www/html/zabbix/custom_pages/config.inc.php on line 10, referer: http://0.0.0.0/zabbix/screens.php?si...01000000000030
                        [Thu May 29 06:04:51 2014] [error] [client *.*.*.*] PHP Fatal error: Call to undefined function json_encode() in /var/www/html/zabbix/custom_pages/ZabbixAPI.class.php on line 220, referer: http://0.0.0.0/zabbix/screens.php?si...01000000000030

                        What can cause this
                        4 Zabbix Frontend Servers (Load balanced)
                        2 Zabbix App Servers (HA)
                        2 Zabbix Database Servers (HA)
                        18 Zabbix Proxy Servers (HA)
                        3897 Deployed Zabbix Agents
                        6161 Values per second
                        X-Layer Integration
                        Jaspersoft report Servers (HA)

                        Comment

                        • Ferrol
                          Junior Member
                          • Feb 2014
                          • 11

                          #162
                          Originally posted by vlam
                          I keep on getting this error

                          [Thu May 29 06:04:31 2014] [error] [client *.*.*.*] PHP Parse error: syntax error, unexpected ':' in /var/www/html/zabbix/custom_pages/config.inc.php on line 10, referer: http://0.0.0.0/zabbix/screens.php?si...01000000000030
                          [Thu May 29 06:04:51 2014] [error] [client *.*.*.*] PHP Fatal error: Call to undefined function json_encode() in /var/www/html/zabbix/custom_pages/ZabbixAPI.class.php on line 220, referer: http://0.0.0.0/zabbix/screens.php?si...01000000000030

                          What can cause this
                          under your config.inv.php, mayb you can show the code in that file for us to help.

                          Comment

                          • vlam
                            Senior Member
                            Zabbix Certified Specialist
                            • Jun 2009
                            • 166

                            #163
                            <?php
                            //CONFIGURABLE
                            # zabbix server info(user must have API access)
                            $z_server = 'http://0.0.0.0/zabbix';
                            $z_user = 'User';
                            $z_pass = 'Pass';
                            # tmp_images directory path
                            $z_img_path = '/custom_pages/tmp_images/';
                            # should be the tail of the URL
                            $pdf_location = $z_server ."/custom_pages/pdf.php";
                            # paper settings
                            $paper_format = 'LETTER'; // formats supported: 4A0, 2A0, A0 -> A10, B0 -> B10, C0 -> C10, RA0 -> RA4, SRA0 -> SRA4, LETTER, LEGAL, EXECUTIVE, FOLIO
                            $paper_oreintation = 'portrait'; // formats supported: portrait / landscape
                            # time zone
                            $timezone = 'EST';

                            //DO NOT CHANGE BELOW THIS LINE
                            $z_tmp_cookies = "";
                            $z_url_index = $z_server ."index.php";
                            $z_url_graph = $z_server ."chart2.php";
                            $z_url_api = $z_server ."api_jsonrpc.php";
                            $z_login_data = "name=" .$z_user ."&password=" .$z_pass ."&enter=Enter";
                            $data = './data.txt';
                            ?>
                            4 Zabbix Frontend Servers (Load balanced)
                            2 Zabbix App Servers (HA)
                            2 Zabbix Database Servers (HA)
                            18 Zabbix Proxy Servers (HA)
                            3897 Deployed Zabbix Agents
                            6161 Values per second
                            X-Layer Integration
                            Jaspersoft report Servers (HA)

                            Comment

                            • Ferrol
                              Junior Member
                              • Feb 2014
                              • 11

                              #164
                              Originally posted by vlam
                              <?php
                              //CONFIGURABLE
                              # zabbix server info(user must have API access)
                              $z_server = 'http://0.0.0.0/zabbix';
                              $z_user = 'User';
                              $z_pass = 'Pass';
                              # tmp_images directory path
                              $z_img_path = '/custom_pages/tmp_images/';
                              # should be the tail of the URL
                              $pdf_location = $z_server ."/custom_pages/pdf.php";
                              # paper settings
                              $paper_format = 'LETTER'; // formats supported: 4A0, 2A0, A0 -> A10, B0 -> B10, C0 -> C10, RA0 -> RA4, SRA0 -> SRA4, LETTER, LEGAL, EXECUTIVE, FOLIO
                              $paper_oreintation = 'portrait'; // formats supported: portrait / landscape
                              # time zone
                              $timezone = 'EST';

                              //DO NOT CHANGE BELOW THIS LINE
                              $z_tmp_cookies = "";
                              $z_url_index = $z_server ."index.php";
                              $z_url_graph = $z_server ."chart2.php";
                              $z_url_api = $z_server ."api_jsonrpc.php";
                              $z_login_data = "name=" .$z_user ."&password=" .$z_pass ."&enter=Enter";
                              $data = './data.txt';
                              ?>
                              vlam,

                              try this:

                              $z_server = 'http://0.0.0.0/zabbix/custom_pages/';
                              $z_user = 'User';
                              $z_pass = 'Pass';
                              # tmp_images directory path
                              $z_img_path = '/<complete path>/zabbix/custom_pages/tmp_images/';
                              # should be the tail of the URL
                              $pdf_location = $z_server ."pdf.php";

                              Hope it works...

                              Comment

                              • Ferrol
                                Junior Member
                                • Feb 2014
                                • 11

                                #165
                                Originally posted by boomer
                                add time period for host and groups
                                selected from filter panel
                                Hi Boomer,

                                Thanks for the answer. I have a problem using that method as my zabbix was set to refresh its page in every 5 seconds. As my Report generation really take time to generate a report, it will not have enough time to generate the report if i am generating it from inside Zabbix. I had to generate it directly from the browser.

                                Thanks anyway

                                Comment

                                Working...