Ad Widget

Collapse

Zabbix Dynamic PDF Report Generation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Pavlik
    Junior Member
    • Aug 2020
    • 2

    #421
    Installation instruction

    Hi!

    First of all, I want to thank martinm_76 and other people who had a hand in this project. I've been looking for a reporting tool for quite a long time, and this one is great.

    However, it was difficult for me to get started. How-to section, honestly, isn't really helpful, and I had to read lots of messages on this forum to find out all installation steps. And I can see that I'm not the only one.

    So, I want to clarify author's How-to to help other people.

    I also want to mention that I've just registred in this forum, so my text formatting skills can be horrible... and my English isn't the best as well.

    Installation

    1) Clone repo to /usr/share/zabbix/ (you may also create inner directory, e.g. custom_pages, and place repo there):
    Code:
    sudo git clone https://github.com/martinm76/zabbix-pdf-report /usr/share/zabbix/zabbix-pdf-report
    cd /usr/share/zabbix/zabbix-pdf-report
    2) Create tmp and reports folders with proper rights by running script:
    Code:
    sudo ./fixrights.sh
    3) Copy config.inc.php.dist to config.inc.php and configure the latter:
    Code:
    sudo cp config.inc.php.dist config.inc.php
    sudo nano config.inc.php
    4) Make sure you have php-curl and php-json packages installed.

    5) Restart apache:
    Code:
    sudo service apache2 restart
    6) Now you should be able to access PDF report generation page using a URL like this:

    http://x.x.x.x/zabbix/zabbix-pdf-report, where x.x.x.x is your Zabbix server IP.

    7) You may also create a Zabbix screen to make using zabbix-pdf-report more convenient. In zabbix web-interface go to Screens -> Create New. Create a new 1 row 1 column screen with width and height of 800x600 / Centre / Top. Set Resource as URL:


    If you have SELinux being active on the system and fail to get the PDF's generated, try disabling SELinux for a while:
    Code:
    setenforce 0
    A little bit about usage

    Most of the elements of zabbix-pdf-report web-interface are quite clear. But I think that "Graphs to show" and "Items to graph" text fields can be tricky. So I want to explain this part:

    Default content here is actually regular expressions with hash signs (#) as delimiters. So you may enter partial matches instead of complete names. Use vertical line (|) to separate names.

    NB: Regexps are case sensitive by default. Use ignore case flag (i) to change case sensitivity.

    Comment


    • KatarinaS
      KatarinaS commented
      Editing a comment
      I followed all the steps, however when I click the Generate button, it just throws me a blank page and nothing happens? Does anyone know how to solve this? Does this have anything to do with the version of php and zabbix, for me the version is php 8.2.9 for zabbix 6.4.4 I adjusted my version in config.inc.php?
      PLEASE HELP!
  • Pavlik
    Junior Member
    • Aug 2020
    • 2

    #422
    Screen doesn't work

    By the way, I ran into a problem. The reporter works well on its own web-page. But Zabbix screen with reporter as URL resource seems not.

    It shows all elements of the form, and when I select something and click "Generate" button, nothing happens.
    Click image for larger version  Name:	reporter.png Views:	19 Size:	52.5 KB ID:	407183

    Can anyone help, please?

    My soft:
    Zabbix server version: 4.4.10 and 5.0.2 (doesn't work on both servers)
    PHP version: 7.0.33-0+deb9u8 (Zabbix 4.4.10) and 7.4.3 (Zabbix 5.0.2)
    zabbix-pdf-report version: 1.2.3

    EDIT:

    When screen is opened, Chrome's dev-tool shows error:
    Blocked script execution in '<URL>' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
    And when I click "Generate" button, it shows the following message:
    Blocked form submission to 'createpdf.php' because the form's frame is sandboxed and the 'allow-forms' permission is not set.

    Still don't know how to fix it.
    Last edited by Pavlik; 18-08-2020, 16:06.

    Comment


    • provels
      provels commented
      Editing a comment
      Could it be security settings in your browser?

    • Pavlik
      Pavlik commented
      Editing a comment
      Hi, provels

      I checked it in 3 browsers (Chrome, Edge, Yandex) with security settings turned off - no effect, the same problem :/

    • sajid4uu2c
      sajid4uu2c commented
      Editing a comment
      Pavlik, I am also facing the same issue. Any luck?
  • parmesh
    Junior Member
    • Aug 2020
    • 1

    #423
    Hello there, ...

    I'm new here and, I'm attempting to find out about this module. I put it working yet something is missing yet, I accept on the grounds that the chart isn't appearing. I saw another post on a similar subject who has a similar issue, however, nobody answer plainly how fixed this.

    Would someone be able to help or simply show the "North" hehe?

    Apologies, my English is a lot of poor.

    Much appreciated!
    Last edited by parmesh; 23-08-2020, 10:42.

    Comment

    • vatixxx
      Junior Member
      • Sep 2020
      • 2

      #424
      It's possible to automate generation of this report, and send every day by e-mail?

      Comment

      • provels
        Member
        • Apr 2020
        • 93

        #425
        In one of my past posts, I said I thought the PDF Report Generator was crashing when the URL was added as a screen. This is not the case; it is the 30 second screen auto-refresh that is clearing the report.
        Is there a way to disable auto-refresh for a single page/screen or would that disable it globally? Thank you.

        EDIT - I found in another post that the refresh interval is defined in the user profile (upper right corner of screen). I can change it to whatever I wish.
        So another problem solved!

        Last edited by provels; 12-09-2020, 00:19.

        Comment

        • AaronMVP
          Junior Member
          • Sep 2020
          • 1

          #426
          Hello,

          Somehow my reports aren't showing any data when I enable 'Include graphs'. The only way to get a report is unchecking every checkbox, then I get a empty report without any data.
          I also get alot of these kind of CURL commands:

          {"groupid":"6","name":"Virtual machines"},{"groupid":"4","name":"Zabbix servers"}],"id":1}) Response decoded: (Array ( [jsonrpc] => 2.0 [result] => Array ( [0] => Array ( [groupid] => 20 [name] => DATTS_AMSD ) [1] => Array ( [groupid] => 5 [name] => Discovered hosts ) [2] => Array ( [groupid] => 2 [name] => Linux servers ) [3] => Array ( [groupid] => 19 [name] => Synology ) [4] => Array ( [groupid] => 18 [name] => UPS ) [5] => Array ( [groupid] => 6 [name] => Virtual machines ) [6] => Array ( [groupid] => 4 [name] => Zabbix servers ) ) [id] => 1 ) CURL URL: http://10.0.20.206/zabbix/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":"c406e1cbe85f7e88f2b8fd694a019b83","met hod ":"user.logout","id":1,"params":[],"jsonrpc":"2.0"} [10102] => gzip ) Got response from API: ({"jsonrpc":"2.0","result":true,"id":1}) Response decoded: (Array ( [jsonrpc] => 2.0 [result] => 1 [id] => 1 ) __logout() Got response from API: (1)

          In /var/log/apache2/error.log I get the following error:
          [Wed Sep 16 11:32:22.950385 2020] [php7:warn] [pid 1429] [client 10.60.2.239:62368] PHP Warning: get_class() expects parameter 1 to be object, null given in /usr/share/zabbix/zabbix-pdf-report/inc/ZabbixAPI.class.php on line 208, referer: http://10.0.20.206/zabbix/zabbix-pdf-report/chooser.php

          Could anyone help me out with this issue? So I can make a report with data.

          CURL and PHP is installed. Using zabbix version 4.4.

          Comment


          • Pradish
            Pradish commented
            Editing a comment
            I am also getting same issue. I did clone update repo. Zabbix server is upgraded to 5.0.4. Early debug console reported CSS and JS file not found, so i cloned files from repo again and reconfigured, however the same issue persists
        • hidesomething_
          Junior Member
          • Oct 2020
          • 1

          #427
          Hi everyone. First of all thanks martnm76 for making this wonderful tool! Everything in this tool works great.
          Now I just wonder is there a way to automatically generate the report (for example per week) and send to email? My idea is that make a cron job to automatically generate report per week, and then use python to send pdf report files in /reports folder. But I don't know how to make a cron job to automatically generate the pdf report file? Can anyone help me with this? I'm really appreciate all of your help!

          Comment

          • RPW
            Junior Member
            • Oct 2008
            • 11

            #428
            I'm using a cron script similar to the one below

            Code:
            #!/bin/bash
            # HOSTGROUP1 - GroupID=26
            # HOSTGROUP2 - GroupID=31
            
            REPORT_FILE=Zabbix-PDF-Report_`date "+%d_%m_%Y"`.pdf"
            # **** HOSTGROUP1 ****
            GroupID=26
            wget -O /report/$REPORT_FILE http://127.0.0.1/zabbix/zabbix-pdf-report/createpdf.php?ReportType=hostgroup&GroupID =26&ReportRange=last&timePeriod=Week"
            mail -s "Periodical PDF Report Monitoring" -a /report/$REPORT_FILE.pdf [email protected]
            # **** HOSTGROUP2 ****
            GroupID=31
            wget -O /report/$REPORT_FILE http://127.0.0.1/zabbix/zabbix-pdf-report/createpdf.php?ReportType=hostgroup&GroupID =31&ReportRange=last&timePeriod=Week"
            mail -s "Periodical PDF Report Monitoring" -a /report/$REPORT_FILE.pdf [email protected]
            Create a cron job for weekly and call the script.
            For run this script automatically, the variables “$ z_user” and “$ z_pass” must be set in the file “config.inc.php” and $allow_localhost=1. The user should should only have read permissions on the Zabbix server.

            Comment

            • joinup
              Junior Member
              • Jun 2018
              • 1

              #429
              Hello, I Have Ubuntu18.04 , php 8 , everytime o choose a hostgroup i get the error "PHP Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/inc/ZabbixAPI.class.php:358) in /var/www/html/createpdf.php on line 414, referer: http://192.168.40.111/chooser.php" and get the output in the screen "CURL URL: https://zabbixServer/api_jsonrpc.php
              CURL Options: Array ( [19913] => 1 [41] => [13] => 30 [78] => 5 [81] => [64] => [52] => 1 [74] => 1 [10023] => Array" can you help?

              Comment

              • heba
                Member
                • Jan 2020
                • 40

                #430
                Dear All

                I am also facing the same issue as Pavlik - the screen of the report generator appears to me - but when I select any thing and click generate... nothing happens...how can I troubleshoot this ... any log files to check ? I am on Zabbix 4.4.10 front end...

                Another question... if there is issue in the version Zabbix 4.4.10 ... can I roll back to any previous version ? example 4.4.8 and how ?

                Thanks
                Heba

                Comment

                • mbuyukkarakas
                  Member
                  • Aug 2014
                  • 49

                  #431
                  I'm using zabbix 5.0 with centos 7 and php 7.0 / apache.
                  PDF report is working almost okay but it is not listing all the host groups. I dont know why but it's listing only some the host groups.
                  Could you help me please to solve that ?

                  Thank you.
                  Mehmet

                  Comment

                  • heba
                    Member
                    • Jan 2020
                    • 40

                    #432
                    Dears

                    I have a strange issue. suddenly report stopped working and it is not producing reports at all... nothing happens when I click "generate"

                    Don't know where to check for errors... can you please advise... I am on zabbix 4.4.10 on redhat 7.4

                    Many thanks for our help
                    Heba

                    Comment


                    • martinm_76
                      martinm_76 commented
                      Editing a comment
                      Depends on a lot of tings, but assuming you're using Apache, look in /var/log/httpd, mostly the error logs. If php-fpm is installed, check also /var/log/php-fpm, probably www-error.log. If any other webserver is used, I'm not exactly sure where you should look, but start in /var/log and I would expect something that points in the direction of that webserver is listed.
                      Also perhaps check if SELinux is running (sestatus). It should still work, but requires a few more steps, although ./fixrights.sh ought to have handled them (you should run it regardless of whether you have SELinux or not).
                  • Springatem
                    Junior Member
                    • Sep 2020
                    • 3

                    #433
                    Hi all,

                    Having a weird problem with this plugin at the moment, the cron entries we have are only showing the last hour of the day, as though even if I have the period set as month it is grabbing a default value of 1hour as though that is the default setting?

                    cron entry:
                    55 12 * * * php-cgi /usr/share/zabbix/zabbix-pdf-report/createpdf.php ReportType=hostitem HostID=11135 ItemID[0]=11111 ReportRange=last timePeriod=Month

                    We recently upgraded to zabbix 5, and since then the chooser.php page also does not show the usual report type options:

                    Click image for larger version  Name:	Zabbix report.png Views:	0 Size:	13.3 KB ID:	415672

                    I noticed the min version on the plugin was version 4, is it currently broken for zabbix 5?

                    UPDATE: have sort of fixed the chooser.php page, it now gives me the option to generate the report, but.... the top of the page has a load of script output such as:
                    CURL URL: http://<IP address>/zabbix/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,"para ms" :

                    and then a load of lines containing our host data before it shows the generate form

                    the auto generated script is still only showing the last hour of the day
                    Last edited by Springatem; 24-12-2020, 14:01.

                    Comment

                    • Springatem
                      Junior Member
                      • Sep 2020
                      • 3

                      #434
                      Hiya, OK I have got a little further with this, turns out the php cgi plugin had not been upgraded to the same version, installed that and the chooser page started to work again

                      However if I run the cron entry:
                      php-cgi /usr/share/zabbix/zabbix-pdf-report/createpdf.php ReportType=hostitem HostID=11135 ItemID[0]=11111 ReportRange=last timePeriod=Month

                      the report generates the PDF but it is actually blank with no graphs

                      If I generate a report using the chooser.php file there isn't a method of selecting only specific graphs?

                      The reason we need this and had it working this way before is because on our switches we have multiple customers in the same switch stack, but send them individual usage reports for their switch port only

                      Has this funcionality changed in the recent update? When i look at the old createpdf.php file, the ItemID variable is in there, but the new createpdf file doesn't apear to have ItemID as a variable any more so seems to me that it cannot be used to select individual graphs any more?
                      Last edited by Springatem; 24-12-2020, 12:32.

                      Comment

                    • rizkysyahrian
                      Junior Member
                      • Jan 2021
                      • 6

                      #435
                      Heya guys,

                      i'm new here..

                      i've tried using pdf report and got this

                      Click image for larger version

Name:	zabbixreport.JPG
Views:	8133
Size:	287.2 KB
ID:	416238

                      i'm using docker with ubuntu 20.04 with zabbix 5.0 alphine image.

                      can any one help me?

                      Comment


                      • rizkysyahrian
                        rizkysyahrian commented
                        Editing a comment
                        i didn't see parameter $zabbix_version in default config.inc.php or should i add one?

                      • martinm_76
                        martinm_76 commented
                        Editing a comment
                        Start by getting the latest version here: https://github.com/martinm76/zabbix-pdf-report - I updated it as late as yesterday with a few extra tweaks. Look at config.inc.php.dist and copy the line from there.
                        You may want to do a diff config.inc.php.dist config.inc.php to see what else may have changed.

                      • sajid4uu2c
                        sajid4uu2c commented
                        Editing a comment
                        Hi, I have used this script and it works perfectly. 

                        I would like to know where I can increase the timeout value in the script. I have infra of about 200 servers in one hostgroup.
                        When I try to generate the report it is throwing me gateway timeout error. So I am splitting my hosts into smaller groups then generating as a work around. Could you please let me know how to increase timeout I tried to increase max_execution and memory size in php.ini but it did not help
                    Working...