Ad Widget

Collapse

Zabbix Dynamic PDF Report Generation

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

    Even I'm using zabbix 4.0 and the changes i made is in the "ZabbixAPI.class.php" changed "user.authenticate" to "user.login" and it started working. Now i'm able to fetch the graphs as well.

    Comment


      Hi Dear Lets expose you my problem:
      I've installed a fresh zabbix server now. I installed Zabbix 4.4 on ubuntu 18.04.Now I would like you to tell me step by step what to do next...
      For now i did this:
      - clone :
      clone https://github.com/catonrug/zabbix-pdf-report.git to /usr/share/

      -copy and edit:
      cp config.inc.php.dist config.inc.php
      vi config.inc.php
      In the configuration i changed
      #the server Ip
      #The Login
      # the passwd

      -create tmp and reports folders
      ./fixrights.sh

      -give the rights
      chmod 777 tmp reports

      -copy
      cp /usr/share/zabbix-pdf-report/zabbix-pdf-report.conf /etc/apache2/conf-available/

      -linked
      ln -s /etc/apache2/conf-available/zabbix-pdf-report.conf /etc/apache2/conf-enabled

      -restart apache2

      service apache2 restart

      -Disable SELinux
      setenforce 0

      after all this I was not able to get the UI so,

      I -i've copy the zabbix-pdf-report folder to /var/www/html/

      and linked with:

      -ln /var/html/zabbix-pdf-report/zabbix-pdf-report.conf /etc/apache2/conf-enabled

      Then the http://my ip/zabbix-pdf-report/ shows only the UI.

      When I put the credentials, the next page doesn't appear

      And I got this log in error.log


      [Sat Oct 19 19:57:57.437477 2019] [php7:warn] [pid 29897] [client 192.168.2.254:52777] PHP Warning: get_class() expects parameter 1 to be object,null given in /var/www/html/zabbix-pdf-report/inc/ZabbixAPI.class.php on line 208, referer: http://my_Ip/zabbix-pdf-report/ [Sat Oct 19 19:57:57.437787 2019] [php7:error] [pid 29897] [client 192.168.2.254:52777] PHP Fatal error: Uncaught Error: Call to undefined function curl_init() in /var/www/html/zabbix-pdf-report/inc/ZabbixAPI.class.php:324\nStack trace:\n#0 /var/www/html/zabbix-pdf-report/inc/ZabbixAPI.class.php(257): ZabbixAPI::__jsonRequest('http://154.127....','{"auth":null,"m...')\n#1 /var/www/html/zabbix-pdf-report/inc/ZabbixAPI.class.php(285): ZabbixAPI->__callAPI('user.login', Array)\n#2 /var/www/html/zabbix-pdf-report/inc/ZabbixAPI.class.php(100):ZabbixAPI->__login()\n#3 /var/www/html/zabbix-pdf-report/index.php(30): ZabbixAPI::login('http://154.127....','Admin', '*******')\n#4 {main}\n thrown in /var/www/html/zabbix-pdf-report/inc/ZabbixAPI.class.php on line 324, referer: http://my_ip/zabbix-pdf-report/



      So that is ,Could you please help me?
      Last edited by KINGAB_93; 21-10-2019, 10:17.

      Comment


        I've downloaded the package from
        github.com/martinm76/zabbix-pdf-report
        , and changed the IP and company name in
        config.inc.php, and thus it started working. Below is my Config.inc.php page for your referance.


        <?php header('Access-Control-Allow-Origin: *');?>
        <?php
        /*
        ** Zabbix
        ** Copyright (C) 2001-2018 Zabbix SIA
        **
        ** This program is free software; you can redistribute it and/or modify
        ** it under the terms of the GNU General Public License as published by
        ** the Free Software Foundation; either version 2 of the License, or
        ** (at your option) any later version.
        **
        ** This program is distributed in the hope that it will be useful,
        ** but WITHOUT ANY WARRANTY; without even the implied warranty of
        ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
        ** GNU General Public License for more details.
        **
        ** You should have received a copy of the GNU General Public License
        ** along with this program; if not, write to the Free Software
        ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
        **/


        // reset the LC_CTYPE locale so that case transformation functions would work correctly
        // it is also required for PHP to work with the Turkish locale (https://bugs.php.net/bug.php?id=18556)
        // WARNING: this must be done before executing any other code, otherwise code execution could fail!
        // this will be unnecessary in PHP 5.5
        //require_once dirname(__FILE__).'index.php';
        setlocale(LC_CTYPE, [
        'C', 'POSIX', 'en', 'en_US', 'en_US.UTF-8', 'English_United States.1252', 'en_GB', 'en_GB.UTF-8'
        ]);

        require_once dirname(__FILE__).'/classes/core/Z.php';

        try {
        Z::getInstance()->run(ZBase::EXEC_MODE_DEFAULT);
        }
        catch (DBException $e) {
        (new CView('general.warning', [
        'header' => 'Database error',
        'messages' => [$e->getMessage()],
        'theme' => ZBX_DEFAULT_THEME
        ]))->render();

        exit;
        }
        catch (ConfigFileException $e) {
        switch ($e->getCode()) {
        case CConfigFile::CONFIG_NOT_FOUND:
        redirect('setup.php');
        exit;

        case CConfigFile::CONFIG_ERROR:
        (new CView('general.warning', [
        'header' => 'Configuration file error',
        'messages' => [$e->getMessage()],
        'theme' => ZBX_DEFAULT_THEME
        ]))->render();

        exit;
        }
        }
        catch (Exception $e) {
        (new CView('general.warning', [
        'header' => $e->getMessage(),
        'messages' => [],
        'theme' => ZBX_DEFAULT_THEME
        ]))->render();

        exit;
        }

        CProfiler::getInstance()->start();

        global $ZBX_SERVER, $ZBX_SERVER_PORT, $ZBX_USER_NAME, $ZBX_PWD, $page;

        $page = [
        'title' => null,
        'file' => null,
        'scripts' => null,
        'type' => null,
        'menu' => null
        ];

        //dynamic pdf generation
        //CONFIGURABLE
        # zabbix server info(user must have API access)
        $z_server = 'http://127.0.0.1:8080/zabbix-4.0.0/';
        $z_server ='http://127.0.0.1:8080/zabbix-4.0.0/frontends/php/';
        $z_user ='Admin';
        $z_pass = '123456';
        # Temporary directory for storing pdf data and graphs - must exist
        $z_tmp_path = 'http://127.0.0.1:8080/zabbix-4.0.0/frontends/php/tmp';
        //$z_tmp_path = './tmp';
        # Directory for storing PDF reports
        //$pdf_report_dir = './reports';
        $pdf_report_dir = 'http://127.0.0.1:8080/zabbix-4.0.0/frontends/php/report/reports';
        # Root URL to reports
        //$pdf_report_url = $z_server ."report/reports";
        $pdf_report_url = 'http://127.0.0.1:8080/zabbix-4.0.0/frontends/php/report/reports';
        # paper settings
        $paper_format = 'A4'; // formats supported: 4A0, 2A0, A0 -> A10, B0 -> B10, C0 -> C10, RA0 -> RA4, SRA0 -> SRA4, LETTER, LEGAL, EXECUTIVE, FOLIO
        $paper_orientation = 'portrait'; // formats supported: portrait / landscape
        $timezone = 'India/Kolkata';
        # Logo used in PDF - may be empty
        # TODO: Specify image size!
        $pdf_logo = 'http://127.0.0.1:8080/zabbix-4.0.0/frontends/php/images/general/zabbix.png';
        $company_name = 'Zabbix';

        //DO NOT CHANGE BELOW THIS LINE
        $z_tmp_cookies = "/tmp/";
        $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";


        Hope This will be useful for you.

        Comment


        • KINGAB_93
          KINGAB_93 commented
          Editing a comment
          before make a configuration in config.inc.php and after you download what have you done?
          I would like to know all your steps?
          Also tell me which OS are you using ?
          I'm for instance using ubuntu 18.04 and zabbix 4.4....
          Last edited by KINGAB_93; 21-10-2019, 15:35.

        I downloaded the code from the I shared before, I'm using ubuntu 18.04 with zabbix version 4.2 and centos7 with 4.2 zabbix version.
        First I changed "Zabbix.API.class.php" page. In this page I changed 'user.authenticate' to 'user.login'.
        Second, I created a file with the name 'config.inc.php' and added the above code.
        This was the coding changes I did and I was able to generate PDF based on hosts.

        Comment


          Hi, just to comment what works for me in version 4.4 for zabbix on Centos 7.6

          cd /usr/share/zabbix
          git clone https://github.com/martinm76/zabbix-pdf-report.git
          cd zabbix-pdf-report/
          cp config.inc.php.dist config.inc.php ( and edit the file with your conf)
          ./fixrights.sh
          chmod 777 reports/ tmp/

          In your zabbix --> Screens --> Create New
          Resource: URL
          URL: http://zabbix.yourcompany/zabbix-pdf.../createpdf.php
          800x600 center (1x1)

          Comment


            The following solution is not recommended thing to do since there has been made some modifications in original Zabbix API.

            Comment

            Announcement

            Collapse
            No announcement yet.
            Working...
            X