Zabbix Dynamic PDF Report Generation

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

    Hi,

    Has anyone tried pdf reporting yet with Zabbix 4 which is currently in beta?

    Comment


      I finally made a new release and managed to get it packaged up. I think I have addressed most of the issues people have mentioned in this edition.

      The link to the version I have put out:
      https://drive.google.com/drive/folde...zg?usp=sharing

      The current version as of this post is 0.9.6 - please use this if as all possible.
      I have only tested it in my own environment so there may be some tweaks needed for certain installations, but I would expect anyone already running a previous version would have no issues.

      Remember that tmp and reports must be writable by the webserver. They should already be chmod 777, but apparently that doesn't take in some cases. SELinux may also require extra tweaks.

      This version has:
      * Updated logout function so you no longer should get errors when logging in.
      * More humanized names when showing items with macros in their name
      * Improved spacing
      * Support for subgroups in the Chooser and Old reports section
      * Added a textfield prefilled with the $graphs value from config.inc.php that you can override on a per report basis to suit your needs.

      I hope you will find this useful.

      NB: If you unpack to the current location of your zabbix-pdf-report installation, remember to copy config.inc.php first. I didn't get around to move it to config.inc.php.dist
      To use Google Drive, you need to use a supported web browser. Learn what a browser is, which browser you use, and how to update to the latest version. Option 1: Find the update for your browser To

      Comment


      • afjunior
        afjunior commented
        Editing a comment
        Thank you very much for your work. Working partially on Zabbix, but I believe it will soon be perfect again.
        Last edited by afjunior; 19-10-2018, 13:02.

      After the upgrade, I'm using zabbix 4 perfectly

      Comment


        Hello, martinm_76
        We launch latesest version 0.9.6 on Zabbix 4.0.0rc3, but we have some problem with pdf generation: Graphs for ICMP isn't work could you help us.
        At the same time we have 1 question - is it possible to make one bid pdf report for all Host groups?
        Thanks!

        Comment


        • martinm_76
          martinm_76 commented
          Editing a comment
          Hi Mark.

          I guess the naming has changed for ICMP. In our environment it's still called ICMP Ping. You can either change 'Ping' to 'ICMP' or 'ICMP Graph' and it should work, depending on how much ICMP you want included.
          Also, you could try specifying #.*# in the filter in stead of the prefilled one - that should give you every graph there is.

          One big PDF for alle host groups is somewhat more tricky and would likely take a very long time to generate, unless you stick to a very smal period of time. It could probably be done, though.
          Look at my next post, as I have now uploaded the project to GitHub for better management and community. Feel free to file an issue for one big graph of everything the user can see.

          /Martin.

        Hello again, all.

        I was a bit annoyed that I couldn't include the kind of graphs you can see in Latest Items in the report, so I set to work on how to do that, and it seems I managed it. I don't have it so you can included several entries in one graph at the moment, but I expect in that case you could do a regular graph in stead.
        I have updated the version to 1.0.0 with this addition and in order to be more responsive and agile with the development, I have now set it up on GitHub.

        You can get it here: https://github.com/martinm76/zabbix-pdf-report

        If you have any issues, examples, etc. you want to mention, it would be nice if you could use GitHub to track it. Of course you are most welcome to discuss things in this thread as well, but I hope to be able to be a bit more responsive with GitHub.

        Comment


          hi

          I need help setting this up. I followed steps on page 1 of this topic updated config.inc.php with zabbix-server and username pass. but when I launch in browser I get login page. after login page I get 500 error.
          on apache error log I get below logs.

          [Thu Oct 18 10:41:44.987838 2018] [:error] [pid 1115] [client 216.228.112.21:51125] PHP Warning: Creating default object from empty value in /usr/share/zabbix/custompages/zabbix-pdf-report/inc/ZabbixAPI.class.php on line 123, referer: https://zabbix-server/zabbix/customp...ix-pdf-report/

          [Thu Oct 18 10:41:44.987923 2018] [:error] [pid 1115] [client 216.228.112.21:51125] PHP Fatal error: Uncaught Error: Call to undefined function curl_init() in /usr/share/zabbix/custompages/zabbix-pdf-report/inc/ZabbixAPI.class.php:324\nStack trace:\n#0 /usr/share/zabbix/custompages/zabbix-pdf-report/inc/ZabbixAPI.class.php(257): ZabbixAPI::__jsonRequest('https://zabbix-...', '{"auth":null,"m...')\n#1 /usr/share/zabbix/custompages/zabbix-pdf-report/inc/ZabbixAPI.class.php(285): ZabbixAPI->__callAPI('user.login', Array)\n#2 /usr/share/zabbix/custompages/zabbix-pdf-report/inc/ZabbixAPI.class.php(100): ZabbixAPI->__login()\n#3 /usr/share/zabbix/custompages/zabbix-pdf-report/index.php(30): ZabbixAPI::login('https://zabbix-...', 'username', 'password')\n#4 {main}\n thrown in /usr/share/zabbix/custompages/zabbix-pdf-report/inc/ZabbixAPI.class.php on line 324, referer: https://zabbix-server/zabbix/customp...ix-pdf-report/

          changed username password in log.

          how to solve this issue?
          Last edited by kfadia; 18-10-2018, 12:49.

          Comment


          • martinm_76
            martinm_76 commented
            Editing a comment
            Hi there.

            From the error message it seems like you have not installed the php-curl package of your distribution. You will need to do that. You also need JSON support, if you haven't got that already.


          Good morning. First of all, congratulations for the excellent project. I have been observing that in the last updates, the figures are not being generated considering the data and time that are set, but fixed in 1h. Regardless of the choice made (day, month, year ... custom) ... only in the graphics part always consider the last hour. Would you kindly help me?

          Comment


          • martinm_76
            martinm_76 commented
            Editing a comment
            First, thank you for the kind words. It means a lot to me!

            Second:
            Can you please elaborate? Is it items, triggers, trends that you don't see reflect the chosen period? As far as I understand your question, the graphs were okay?
            Are you able to generate an example I can see with values that are not problematic to share? You can e-mail it to me at [email protected]

            Until a few releases ago there was a bug in the graph setup that it would always go with endtime of now (possibly introduced in Zabbix 3.x - which required setting isNow=0 in the request). I would not have thought something similar would be required for the other queries, though.

          • afjunior
            afjunior commented
            Editing a comment
            Email sent to you with requested attachments

          • martinm_76
            martinm_76 commented
            Editing a comment
            Hello again.
            A new version will be released soon, but for now I have a manual patch you can try and report back if it is working at your end. Please see this ticket for details:
            https://github.com/martinm76/zabbix-pdf-report/issues/1

          Thanks martinm_76,

          installing php_curl and php-json solved 500 error but now getting blank page with unable to login,

          [Thu Oct 18 12:25:36.088823 2018] [:error] [pid 18595] [client 216.228.112.22:5018] PHP Warning: Creating default object from empty value in /usr/share/zabbix/custompages/zabbix-pdf-report/inc/ZabbixAPI.class.php on line 123, referer: https://zabbix-server/zabbix/customp...ix-pdf-report/

          do I need to edit ZabbixAPI.class.php too to point to zabbix-server URL?

          Comment


          • kfadia
            kfadia commented
            Editing a comment
            yeah I was thinking along the same line. I can help with documentation, atleast for initial step by step setup and that can be published on Github page as readme. than we can document on how to get items and graphs in report.

            I tried debug mode and that made me understand how it works and what items your script considers for reports. next I'm going to try each option.

            next thing I'm trying to figure out how I can get items without graph in reports? it seems there're many items we have and need report for are text/log items so can't make graph out of it. but wanted to have PDF/html report on daily basis. e.g. 1000 hosts in datacenter their SBIOS version, BMC version, Software/OS version. or networking devices with they Interface Error report on daily/12hr basis.

            Improvements:
            1) tap in to zabbix DB so we can use same zabbix username pass for each user. I'm going to try if your tool can work with read-only replica and if yes then we can think about this option. (Ignore this, I tried with different account than in config file and it worked. I just realized username/pass in config is just for zabbix-api connection)
            2) eliminate items definition in config.inc.php and make it rely on browser so we don't have to make changes in config for every new item. (I'm still learning how the tool works, so ignore if this is already true.)
            Last edited by kfadia; 19-10-2018, 05:19. Reason: I tried with different account than in config file and it worked. I just realized username/pass in config is just for zabbix-api connection

          • martinm_76
            martinm_76 commented
            Editing a comment
            Hello again. Glad you got the login issue sorted. The username/password in config.inc.php is only used if you choose to disable the user login page. It should work for login, though.

            Regarding 2: The item definition is one of the harder ones to expose in the interface, at least in its current form. Possibly another parser could be made so the array is made later, but it works pretty well like it is now, but of course makes it difficult for people without access to the config-file to adapt the report to their needs.
            Can you think of a way it can be done without requiring database access and still retaining configuration? I guess we could write to either sqlite or a flat text-file ...
            If is theoretically possible to read all items, graphs, etc. and let the user check off which they want included, but it would require a lot of rewriting to do it, or at least delayed generation of the report data. I think the current compromise where you can override the defaults work pretty well for almost all situations.

          • kfadia
            kfadia commented
            Editing a comment
            yes you can read all item practically assigned to host/hostgroups using zabbix-api. for example zabbix-grafana plugin queries everything using API. probably it rights temp data in sqlite3.
            in my environment I'm afraid to expose Dynamic-PDF-Generation tool to users as everybody has different requirements and I'll get busy editing config file everyday...

          GitHub repository updated with code fixing the issue with graphs in Zabbix 4.0 (hopefully 4.x and beyond) and a few other minor tweaks. master is now version 1.1.1

          Comment


            Originally posted by martinm_76 View Post
            GitHub repository updated with code fixing the issue with graphs in Zabbix 4.0 (hopefully 4.x and beyond) and a few other minor tweaks. master is now version 1.1.1
            Where can i download latest version ? Installed v0.9.6 on 4.0 zabbix appliance but created pdf only in the graphics part always consider the last hour.

            Comment


            • martinm_76
              martinm_76 commented
              Editing a comment
              If you look a little further back you'll see the github link, but here is is again: https://github.com/martinm76/zabbix-pdf-report
              You can download it as a zip-file or check it out with git.
              There have been a fair bit of development there since 0.9.6 and it works correctly with both 3.x and 4.x versions of Zabbix. Hopefully also 2.x versions, but I have no real way to test that.

            Originally posted by onurintel View Post

            Where can i download latest version ? Installed v0.9.6 on 4.0 zabbix appliance but created pdf only in the graphics part always consider the last hour.
            I have implemented the following workaround until the script is made compatible with Zabbix 4.

            I only produce 12-hour reports with the cronjob, so I don't have any problems. (It is not a solution for different report fields continuously through web gui)

            Code:
            file : createpdf.functions.php
            find : curl_setopt($ch, CURLOPT_URL, $z_url_graph ."?graphid=" .$graphid ."&width=" .$width ."&height=" .$height ."&period=" .$period ."&stime=" .$stime ."&isNow=0");
            replace : curl_setopt($ch, CURLOPT_URL, $z_url_graph ."?graphid=" .$graphid ."&width=" .$width ."&height=" .$height ."&from=now-12h" ."&to=now" ."&isNow=0&profileIdx=web.screens.filter");

            Comment

            Announcement

            Collapse
            No announcement yet.
            Working...
            X