Ad Widget

Collapse

Zabbix Dynamic PDF Report Generation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Lsuman
    Junior Member
    • Mar 2023
    • 2

    #466
    Hi Can someone help me on this.

    New to zabbix and linux.
    my platform: ubuntu 22.04
    mysql
    zabbix 6.4

    Migrated databse from zabbix 5.2 to 6.4. Server side working fine.
    Followed the steps for the pdf reports, it was working fine on the old server, got the following error at login.

    Click image for larger version

Name:	image.png
Views:	2124
Size:	13.7 KB
ID:	461139
    out of options to proceed.

    Thanks,
    Suman

    Comment


    • Ricardo Beltran
      Ricardo Beltran commented
      Editing a comment
      I have the same problem, did you find a solution? I have an ubuntu 22.04 and zabbix 6.4

    • Jobin Joseph
      Jobin Joseph commented
      Editing a comment
      change user to username in file zabbix-pdf-report-master\inc\ZabbixAPI.class.php
      Like
      $data = $this->__callAPI('user.login', array( 'password' => $this->password, 'username' => $this->username ));
  • hsyah
    Junior Member
    • Sep 2020
    • 2

    #467
    How to generate a pdf report for a certain device at 08:00 every day in the pdf directory?

    Comment

    • Rudresh SN
      Junior Member
      • Mar 2023
      • 1

      #468
      Hi

      I did changes in the config.inc.php file so now I can able to generate the pdf report but I can't see any of the graphs, trigger information's i,e show triggers, graphed items, configured item's status etc,. for both our specific hosts and also for the Zabbix server host/host group.

      So do we need to make any code changes/config changes in any of the specific files? If so please provide those information so that it will be a great help !!!

      Comment

      • Lsuman
        Junior Member
        • Mar 2023
        • 2

        #469

        Can some one help me on this:
        report server login is okay, when I run report gives an HTTP 500 error.
        Apache log says this

        [Thu Jun 22 13:40:31.634349 2023] [php:warn] [pid 4437] [client :60508] PHP Warning: Undefined array key "pageWidth" in /usr/share/zabbix/zabbix-pdf-report/inc/class.ezpdf.php on line 1239, referer: http://localhost/zabbix/zabbix-pdf-report/chooser.php
        [Thu Jun 22 13:40:31.634385 2023] [php:warn] [pid 4437] [client :60508] PHP Warning: Undefined array key "pageHeight" in /usr/share/zabbix/zabbix-pdf-report/inc/class.ezpdf.php on line 228, referer: http://localhost/zabbix/zabbix-pdf-report/chooser.php
        [Thu Jun 22 13:40:31.634412 2023] [php:warn] [pid 4437] [client :60508] PHP Warning: Undefined array key "pageWidth" in /usr/share/zabbix/zabbix-pdf-report/inc/class.ezpdf.php on line 1285, referer: http://localhost/zabbix/zabbix-pdf-report/chooser.php
        [Thu Jun 22 13:40:31.634433 2023] [php:warn] [pid 4437] [client :60508] PHP Warning: Undefined array key "pageWidth" in /usr/share/zabbix/zabbix-pdf-report/inc/class.ezpdf.php on line 1239, referer: http://localhost/zabbix/zabbix-pdf-report/chooser.php
        [Thu Jun 22 13:40:31.634463 2023] [php:warn] [pid 4437] [client :60508] PHP Warning: Undefined array key "pageHeight" in /usr/share/zabbix/zabbix-pdf-report/inc/class.ezpdf.php on line 228, referer: http://localhost/zabbix/zabbix-pdf-report/chooser.php
        [Thu Jun 22 13:40:31.634488 2023] [php:warn] [pid 4437] [client :60508] PHP Warning: Undefined array key "pageWidth" in /usr/share/zabbix/zabbix-pdf-report/inc/class.ezpdf.php on line 1285, referer: http://localhost/zabbix/zabbix-pdf-report/chooser.php
        [Thu Jun 22 13:40:31.634563 2023] [php:error] [pid 4437] [client :60508] PHP Fatal error: Uncaught Error: Call to undefined function get_magic_quotes_runtime() in /usr/share/zabbix/zabbix-pdf-report/inc/class.pdf.php:2640\nStack trace:\n#0 /usr/share/zabbix/zabbix-pdf-report/createpdf.php(282): Cpdf->addPngFromFile()\n#1 {main}\n thrown in /usr/share/zabbix/zabbix-pdf-report/inc/class.pdf.php on line 2640, referer: http://localhost/zabbix/zabbix-pdf-report/chooser.php zz0.1x252ak93tjzz



        Zabbix server 6.4
        Ubuntu 22.04

        Comment


        • Lsuman
          Lsuman commented
          Editing a comment
          and the tmp folder is full with images(graphs for the report)
          I mean running a report is generating files for pdf in tmp folder but not able to compile a pdf (i guess)

        • AlexOliveira
          AlexOliveira commented
          Editing a comment
          Hello.

          I tried to install on version 6.2.
          The installation did not give any errors, but it is not working.
          Does anyone know if it works in this version, what will need to be changed?

          #

          CURL URL: /api_jsonrpc.php
          CURL Options: Array ( [19913] => 1 [41] => [13] => 30 [78] => 5 [81] => [64] => [52] => 1 [74] => 1 [10023] => Array ( [0] => Content-Type: application/json-rpc [1] => User-Agent: ZabbixAPI v1.0 - http://andrewfarley.com/zabbix_php_api ) [10036] => POST [10015] => {"method":"apiinfo.version","id":1,"params":[],"jsonrpc":"2.0"} [10102] => gzip ) Got response from API: () Response decoded: ( API Version returned : , converted to integer as : 0
          CURL URL: /api_jsonrpc.php
          CURL Options: Array ( [19913] => 1 [41] => [13] => 30 [78] => 5 [81] => [64] => [52] => 1 [74] => 1 [10023] => Array ( [0] => Content-Type: application/json-rpc [1] => User-Agent: ZabbixAPI v1.0 - http://andrewfarley.com/zabbix_php_api ) [10036] => POST [10015] => {"auth":null,"method":"user.login","id":1,"params" :{"password":null,"user":null},"jsonrpc":"2.0"} [10102] => gzip ) Got response from API: () Response decoded: ( __login() Got response from API: () Unable to login:

          #


          Thanks
      • KatarinaS
        Junior Member
        • Aug 2023
        • 2

        #470

        Hello, I have zabbix version 6.4.4. When generating the PDF it opens me a blank page.



        Warning: Undefined variable $method in /usr/share/zabbix/zabbix-pdf-report/inc/ZabbixAPI.class.php on line 256

        Warning: Undefined variable $params in /usr/share/zabbix/zabbix-pdf-report/inc/ZabbixAPI.class.php on line 256

        Warning: Undefined array key "pageWidth" in /usr/share/zabbix/zabbix-pdf-report/inc/class.ezpdf.php on line 1239

        Warning: Undefined array key "pageWidth" in /usr/share/zabbix/zabbix-pdf-report/inc/class.ezpdf.php on line 1285

        Warning: Undefined array key "pageWidth" in /usr/share/zabbix/zabbix-pdf-report/inc/class.ezpdf.php on line 1239

        Warning: Undefined array key "pageWidth" in /usr/share/zabbix/zabbix-pdf-report/inc/class.ezpdf.php on line 1285

        Warning: Undefined array key "pageWidth" in /usr/share/zabbix/zabbix-pdf-report/inc/class.ezpdf.php on line 1239

        Warning: Undefined array key "pageWidth" in /usr/share/zabbix/zabbix-pdf-report/inc/class.ezpdf.php on line 1285

        Warning: Undefined array key "pageWidth" in /usr/share/zabbix/zabbix-pdf-report/inc/class.ezpdf.php on line 1239

        Warning: Undefined array key "pageWidth" in /usr/share/zabbix/zabbix-pdf-report/inc/class.ezpdf.php on line 1285

        Warning: Undefined array key "pageWidth" in /usr/share/zabbix/zabbix-pdf-report/inc/class.ezpdf.php on line 1239

        Warning: Undefined array key "pageWidth" in /usr/share/zabbix/zabbix-pdf-report/inc/class.ezpdf.php on line 1285

        Warning: Undefined array key "pageWidth" in /usr/share/zabbix/zabbix-pdf-report/inc/class.ezpdf.php on line 1239

        Warning: Undefined array key "pageWidth" in /usr/share/zabbix/zabbix-pdf-report/inc/class.ezpdf.php on line 1285

        Warning: Undefined array key "pageWidth" in /usr/share/zabbix/zabbix-pdf-report/inc/class.ezpdf.php on line 1239

        Warning: Undefined array key "pageWidth" in /usr/share/zabbix/zabbix-pdf-report/inc/class.ezpdf.php on line 1285

        Warning: Undefined array key "pageWidth" in /usr/share/zabbix/zabbix-pdf-report/inc/class.ezpdf.php on line 1239

        Warning: Undefined array key "pageWidth" in /usr/share/zabbix/zabbix-pdf-report/inc/class.ezpdf.php on line 1285

        Warning: Undefined array key "pageWidth" in /usr/share/zabbix/zabbix-pdf-report/inc/class.ezpdf.php on line 1239

        Warning: Undefined array key "pageWidth" in /usr/share/zabbix/zabbix-pdf-report/inc/class.ezpdf.php on line 1285

        Warning: Undefined array key "pageWidth" in /usr/share/zabbix/zabbix-pdf-report/inc/class.ezpdf.php on line 1239

        Warning: Undefined array key "pageWidth" in /usr/share/zabbix/zabbix-pdf-report/inc/class.ezpdf.php on line 1285

        Warning: Undefined array key "pageWidth" in /usr/share/zabbix/zabbix-pdf-report/inc/class.ezpdf.php on line 1239

        Warning: Undefined array key "pageWidth" in /usr/share/zabbix/zabbix-pdf-report/inc/class.ezpdf.php on line 1285

        Fatal error: Uncaught Error: Call to undefined function get_magic_quotes_runtime() in /usr/share/zabbix/zabbix-pdf-report/inc/class.pdf.php:2640 Stack trace: #0 /usr/share/zabbix/zabbix-pdf-report/createpdf.php(283): Cpdf->addPngFromFile() Home {main} thrown in /usr/share/zabbix/zabbix-pdf-report/inc/class.pdf.php on line 2640

        My PHP version is 8.2.7, I downloaded the pdf generation package via the zabbix documentation https://github.com/martinm76/zabbix-pdf-report

        Do you know what the problem is and how to solve it. I hope you can help me. Thank you in advance.

        Comment

        • KatarinaS
          Junior Member
          • Aug 2023
          • 2

          #471
          Hi,
          Can someone help me how to export the report file from actionlog and availability report in PDF format?

          Thank you.


          Comment

          • ashton
            Junior Member
            • Sep 2023
            • 1

            #472
            As I was working through an upgrade, the problem cropped in one of my environments, I thought I'd share everything I did to get it working. I'm more of a javascript developer and my PHP knowledge is very limited, so full disclaimer any changes you make to PHP and your own environments you do at your own risk. It's a lengthy process, but hopefully it gets you further. My only issue now is even though the PDF generates, the Contents page is empty, but everything else is there, so that will be the next thing I tackle.

            So first off, I upgraded from a working 6.0 LTS environment with PHP 7.4 to get a new template that's only supported from 6.4 working. I followed published guidance on a everything, obviously the Zabbix upgrade guidance along with the recommendation of migrating to PHP 8.2. All of that completed successfully, but then I started experiencing the different pains that all of you were going through with the PDF Report Generation... basically your logs and mine are pretty much identical in terms of the different errors.

            I picked up a few issues, so let me list them:

            - Under PHP 8.2, several functions used in the PDF producer (class.pdf.php and class.ezpdf.php) are fully deprecated
            - The current implementation of class.pdf.php has a spelling mistake in it (this is important later)
            - The ZabbixAPI.class.php has an issue with the Zabbix 6.4 API implementation in that the call for the user id to has changed from 'user' to 'username'

            To get it to run, the following was done (bear in mind my environment is customized to support organization branding, so I've had a few more things to fix that I won't list here)

            - I found the PDF producer has a revised implementation which is supported under PHP 8. This is available at https://github.com/rospdf/pdf-php. I copied everything from the src folder into /usr/share/zabbix/zabbix-pdf-report/inc (including the sub-folders - else you'll have other errors). Then renamed the class.pdf.php and class.ezpdf.php files to <filename>.<ext>.0. Then I renamed Cpdf.php to class.pdf.php and Cezpdf.php to class.ezpdf.php. You'll also need to update the include statement in class.ezpdf.php (Line 2 or 3) to reference 'inc/class.pdf.php' else the references won't work.

            -The createpdf.php and inc/pdf.functions.php make reference to a function getFontDecender, but in the replaces classes, the function is correctly spelled, so you'll need to update these files search for getFontDecender and replace with getFontDescender

            -In martinm76's repo on Github, you'll notice he has posted an updated ZabbixAPI.class.php from April 2023. Replace your existing one in /usr/share/zabbix/zabbix-pdf-report/inc folder. You'll need to edit it though, and make 2 changes ... Like I said, I'm no PHP developer, so this worked after I tried this, but the code correction I made could possibly be done differently.

            Find the line that starts with 'private static function __buildAPIVersionJSONRequest', and make sure it looks like 'private static function __buildAPIVersionJSONRequest($method, $params = array())' before the opening brace '{'.

            Find the line that starts with ' private function __APIVersion', and make sure it looks like 'private function __APIVersion($method, $params = array())' before the opening brace '{'

            Comment


            • trong.nguyen
              trong.nguyen commented
              Editing a comment
              Thank you for your comment, I follow these steps and it works well. I'm running zabbix 7.0.10 with PHP 8.0
              - Under PHP 8.2, several functions used in the PDF producer (class.pdf.php and class.ezpdf.php) are fully deprecated
              - The current implementation of class.pdf.php has a spelling mistake in it (this is important later)
              - The ZabbixAPI.class.php has an issue with the Zabbix 6.4 API implementation in that the call for the user id to has changed from 'user' to 'username'

              To get it to run, the following was done (bear in mind my environment is customized to support organization branding, so I've had a few more things to fix that I won't list here)

              - I found the PDF producer has a revised implementation which is supported under PHP 8. This is available at https://github.com/rospdf/pdf-php. I copied everything from the src folder into /usr/share/zabbix/zabbix-pdf-report/inc (including the sub-folders - else you'll have other errors). Then renamed the class.pdf.php and class.ezpdf.php files to <filename>.<ext>.0. Then I renamed Cpdf.php to class.pdf.php and Cezpdf.php to class.ezpdf.php. You'll also need to update the include statement in class.ezpdf.php (Line 2 or 3) to reference 'inc/class.pdf.php' else the references won't work.

              -The createpdf.php and inc/pdf.functions.php make reference to a function getFontDecender, but in the replaces classes, the function is correctly spelled, so you'll need to update these files search for getFontDecender and replace with getFontDescender

              -In martinm76's repo on Github, you'll notice he has posted an updated ZabbixAPI.class.php from April 2023. Replace your existing one in /usr/share/zabbix/zabbix-pdf-report/inc folder. You'll need to edit it though, and make 2 changes ... Like I said, I'm no PHP developer, so this worked after I tried this, but the code correction I made could possibly be done differently.

              Find the line that starts with 'private static function __buildAPIVersionJSONRequest', and make sure it looks like 'private static function __buildAPIVersionJSONRequest($method, $params = array())' before the opening brace '{'.

            • trong.nguyen
              trong.nguyen commented
              Editing a comment
              @ashton,
              I have problems when generating tables of content. It generate nothing, do you have the same issue.
              Thanks.

            • soumya
              soumya commented
              Editing a comment
              not only table of contents are not printing but also getting error if we check any of these check boxes 'Show configured items status' & 'Show configured trends (SLA-ish)'. Even Host Group drop down not populating.
              one more thing. if we update ZabbixAPI.class.php like below

              from => private function __APIVersion() {
              to => private function __APIVersion($method, $params = array()) {

              host/host group & other selection boxes are not loading.

              Zabbix : 7.0
              Php : 8.0
              Last edited by soumya; 10-07-2025, 16:22.
          • trong.nguyen
            Junior Member
            • Mar 2023
            • 3

            #473
            Hi, I also want to auto generate report with curl, but I try so many ways with to login and get report file:

            Code:
            <curl -d "name=Admin&password=zabbix" "http://10.2.3.120/zabbix/zabbix-pdf-report/createpdf.php?ReportType=host&HostID=10437&ItemGra phsOn=yes&mygraphs2=%23%28Nginx%29%23&myitems2=%23 %28Nginx%29%23&ReportRange=last&timePeriod=Hour"
            curl -u Admin:zabbix -L -o '/tmp/report.pdf' "http://10.2.3.120/zabbix/zabbix-pdf-report/createpdf.php?ReportType=host&HostID=10437&ItemGra phsOn=yes&mygraphs2=%23%28Nginx%29%23&myitems2=%23 %28Nginx%29%23&ReportRange=last&timePeriod=Hour"
            curl -s --header "Authorization: Basic $AUTH_TOKEN" -o /tmp/report.pdf 'http://10.2.3.120/zabbix/zabbix-pdf-report/createpdf.php?ReportType=host&HostID=10437&ItemGra phsOn=yes&mygraphs2=%23%28Nginx%29%23&myitems2=%23 %28Nginx%29%23&ReportRange=last&timePeriod=Hour'>

            But I still get the log from httpd:
            [Sat Oct 07 13:46:04.903096 2023] [proxy_fcgi:error] [pid 23174] [client 10.2.3.100:34088] AH01071: Got error 'PHP message: PHP Notice: Undefined index: username in /usr/share/zabbix/zabbix-pdf-report/createpdf.php on line 19\nPHP message: PHP Notice: Undefined index: password in /usr/share/zabbix/zabbix-pdf-report/createpdf.php on line 20\n'

            Do you know how to curl with ID and password to generate reports automatically.
            Many thanks in advance.​

            Comment

            • trong.nguyen
              Junior Member
              • Mar 2023
              • 3

              #474
              Hi, I also want to auto generate report with curl, but I try so many ways with to login and get report file:

              Code:
              <curl -d "name=Admin&password=zabbix" "http://10.2.3.120/zabbix/zabbix-pdf-report/createpdf.php?ReportType=host&HostID=10437&ItemGra phsOn=yes&mygraphs2=%23%28Nginx%29%23&myitems2=%23 %28Nginx%29%23&ReportRange=last&timePeriod=Hour"
              curl -u Admin:zabbix -L -o '/tmp/report.pdf' "http://10.2.3.120/zabbix/zabbix-pdf-report/createpdf.php?ReportType=host&HostID=10437&ItemGra phsOn=yes&mygraphs2=%23%28Nginx%29%23&myitems2=%23 %28Nginx%29%23&ReportRange=last&timePeriod=Hour"
              curl -s --header "Authorization: Basic $AUTH_TOKEN" -o /tmp/report.pdf 'http://10.2.3.120/zabbix/zabbix-pdf-report/createpdf.php?ReportType=host&HostID=10437&ItemGra phsOn=yes&mygraphs2=%23%28Nginx%29%23&myitems2=%23 %28Nginx%29%23&ReportRange=last&timePeriod=Hour'>

              But I still get the log from httpd:
              [Sat Oct 07 13:46:04.903096 2023] [proxy_fcgi:error] [pid 23174] [client 10.2.3.100:34088] AH01071: Got error 'PHP message: PHP Notice: Undefined index: username in /usr/share/zabbix/zabbix-pdf-report/createpdf.php on line 19\nPHP message: PHP Notice: Undefined index: password in /usr/share/zabbix/zabbix-pdf-report/createpdf.php on line 20\n'

              Do you know how to curl with ID and password to generate reports automatically.
              Many thanks in advance.​

              Comment

              • bab
                Senior Member
                • Aug 2020
                • 176

                #475
                Is there any clear doc about run this pdf reporter on zabbix version 6 and above ? Is that possible get pdf report ? I think this post it some confusing as there are more than 30 pages and does not any tag as answer

                Comment

                • jdomingo
                  Junior Member
                  • Feb 2024
                  • 2

                  #476
                  Hi,
                  Does it happen to anyone else? The PDF is created but... empty.

                  Click image for larger version

Name:	image.png
Views:	1401
Size:	35.3 KB
ID:	479946

                  Comment

                  • jdomingo
                    Junior Member
                    • Feb 2024
                    • 2

                    #477
                    Logs:
                    2024/02/29 13:00:43 [error] 345725#345725: *9 FastCGI sent in stderr: "
                    PHP message: PHP Notice: Undefined variable: method in /usr/share/zabbix/zabbix-pdf-report/inc/ZabbixAPI.class.php on line 252
                    PHP message: PHP Notice: Undefined variable: params in /usr/share/zabbix/zabbix-pdf-report/inc/ZabbixAPI.class.php on line 252

                    2024/02/29 13:00:51 [error] 345725#345725: *9 FastCGI sent in stderr: "

                    PHP message: PHP Notice: Trying to access array offset on value of type bool in /usr/share/zabbix/zabbix-pdf-report/inc/index.functions.php on line 5

                    2024/02/29 13:01:17 [error] 345725#345725: *9 FastCGI sent in stderr: "

                    PHP message: PHP Deprecated: Function get_magic_quotes_runtime() is deprecated in /usr/share/zabbix/zabbix-pdf-report/inc/class.pdf.php on line 2640

                    PHP message: PHP Notice: Trying to access array offset on value of type bool in /usr/share/zabbix/zabbix-pdf-report/inc/class.ezpdf.php on line 1321

                    Comment

                    • afjuniormga
                      Junior Member
                      • May 2024
                      • 1

                      #478
                      Congratulations on the project. He is truly incredible.
                      As some functions are deprecated, I would like to know if it is working in versions of PHP 8.1 or above?

                      And if not, is there a plan for this to happen?

                      Thank you very much

                      Comment

                      • snraju
                        Junior Member
                        • Aug 2024
                        • 1

                        #479
                        We have configured the pdf report and everything works fine but the pdf generated have all the graphs generated but they are empty saying no data for those items.

                        Got error 'PHP message: PHP Notice: Undefined variable: method in /usr/share/zabbix/zabbix-report/inc/ZabbixAPI.class.php on line 252\nPHP message: PHP Notice: Undefined variable: params in /usr/share/zabbix/zabbix-report/inc/ZabbixAPI.class.php on line 252\n'

                        PHP version : 7.2
                        Zabbix: 6.0.31

                        Comment

                        • brunosouza
                          Junior Member
                          • Jun 2025
                          • 1

                          #480
                          Hi,

                          I am using zabbix 7.2.6 and configured LDAP login. After this i cannot login into pdf genaration, i receive this error:

                          Unable to login: Array ( [code] => -32600 [message] => Invalid request. [data] => Invalid parameter "/": unexpected parameter "auth". )

                          So, i just alter ZabbixAPI_class.php this:

                          private static function __buildJSONRequest($method, $params = array()) {
                          // This is our default JSON array
                          $request = array(
                          'auth' => self::$instance->auth_hash,
                          'method' => $method,
                          'id' => 1, // NOTE: this needs to be fixed I think?
                          'params' => ( is_array($params) ? $params : array() ),
                          'jsonrpc' => "2.0"
                          );
                          // Return our request, in JSON format
                          return json_encode($request);
                          }

                          to

                          private static function __buildJSONRequest($method, $params = array()) {
                          // This is our default JSON array
                          $request = array(
                          'method' => $method,
                          'id' => 1, // NOTE: this needs to be fixed I think?
                          'params' => ( is_array($params) ? $params : array() ),
                          'jsonrpc' => "2.0"
                          );
                          // Return our request, in JSON format
                          return json_encode($request);
                          }​

                          so, i received another error:

                          Unable to logout: Array ( [code] => -32602 [message] => Invalid params. [data] => Not authorized. )

                          Can you help me?

                          Comment

                          Working...