zabbix-pdf-report icon indicating copy to clipboard operation
zabbix-pdf-report copied to clipboard

Empty report

Open WW-build opened this issue 4 years ago • 15 comments

Hi, I was using your tool for few month and everything was working fine, but few week's ago I've spotted that PDF reports doesn't include graph data, pages are just empty. Zabbix-server: 5.0.5 Apache: 2.4.29 OS: Ubuntu

WW-build avatar Nov 30 '20 15:11 WW-build

I'm also having this issue of empty graph data.

Tooling around in the files, I see that all the images in the tmp folder are of size 0.

Zabbix version: 5.0.5 Centos 8

asalz-zh avatar Dec 09 '20 22:12 asalz-zh

Have you run the fix-rights.sh script? Have you tried 'setenforce 0' so SELinux won't put roadblocks up, if there are issues? Are the files put below the webroot folder or somewhere else? Are the SELinux contexts matching the Apache webserver (or whatever webserver you are using)?

Also note that is some cases, certain intervals produce graphs with no data in Zabbix as well, so please make sure that is not the case here.

martinm76 avatar Dec 14 '20 21:12 martinm76

I have run the fix-rights script and I can't set setenforce 0 because its not found. The graphs don't show up no matter how large the interval i make it.

[root@appliance ~]# setenforce 0
-bash: setenforce: command not found
[root@appliance ~]# sestatus
-bash: sestatus: command not found
[root@appliance ~]# uname -a
Linux appliance 4.18.0-193.19.1.el8_2.x86_64 #1 SMP Mon Sep 14 14:37:00 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
[root@appliance ~]# cat /etc/*-release
CentOS Linux release 8.2.2004 (Core)
NAME="CentOS Linux"
VERSION="8 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="8"
PLATFORM_ID="platform:el8"
PRETTY_NAME="CentOS Linux 8 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:8"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-8"
CENTOS_MANTISBT_PROJECT_VERSION="8"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="8"

CentOS Linux release 8.2.2004 (Core)
CentOS Linux release 8.2.2004 (Core)

asalz-zh avatar Dec 18 '20 15:12 asalz-zh

Hi, I have a similar issu : I can generate report, but no graph are shown, only titles. I have no image in the "tmp" folder. setenforce 0 : Command 'setenforce' not found

The debug looks like OK :

HostID: 10164
Report Type: host
Time Period: 2678400
Temp image path: /usr/share/zabbix/zabbix-pdf-report-master/tmp/zabbix_report_wuOfu3

Time scope - starttime: 1606039633, endtime: 1608718033 - stime: 20201122110713
Proxy Bompard(id:10164)
Graph selector : #.*#

CPU jumps (id:950) matched the expression - including it.
Array
(
    [graphid] => 950
    [name] => CPU jumps
)
[...]
./images/general/zabbix.png written to PDF-file ...
Report ready - available as: ./reports/proxy-bompard.pdf

When i run the fixrihts.sh, i have an error (maybe it's because i use nginx) :

sudo bash /usr/share/zabbix/zabbix-pdf-report-master/fixrights.sh
chown: invalid user: ‘apache’
drwxrwxrwx 2 root root 4096 Dec 23 12:55 reports
drwxrwxrwx 2 root root 4096 Dec 23 12:55 tmp

You should now have tmp and reports folders that your webserver can write to.

Zabbix-server: 5.0.6 Nginx 1.14.0 OS: Ubuntu 18.04

Sillmael avatar Dec 23 '20 10:12 Sillmael

@Sillmael @WW-build Did either of you ever find a solution to this?

asalz-zh avatar Feb 24 '21 15:02 asalz-zh

This seems very odd. Could it be that there has been some update to your PHP libraries and possible some of the functions involved in making the images are no longer part of the base package and needs exstra modules?

Try to check phpinfo() output for if 'gd' is actually used?

On my Ubuntu test server, I could get this ouput with php7.2 -i -- I expect you have something similar. Also, I would expect some error messages from PHP either in error log of webserver, messages or similar syslog location - unless somehow all errors have been suppressed in your PHP installation.

martinm76 avatar Feb 24 '21 17:02 martinm76

Screen Shot 2021-02-24 at 11 18 05 AM

There is a screenshot of the phpinfo() for gd.

Here is the only php error.log file entry

2021/02/24 11:17:11 [error] 1289421#0: *1262 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 10.212.134.17, server: shared-zabbix.<REDACTEDDOMAIN>.com, request: "GET /zabbix-pdf-report/phpinfo.php HTTP/2.0", upstream: "fastcgi://unix:/run/php-fpm/zabbix.sock:", host: "10.1.5.20"
2021/02/24 11:18:48 [error] 1289421#0: *1262 FastCGI sent in stderr: "PHP message: PHP Notice:  getimagesize(): Read error! in /usr/share/zabbix/zabbix-pdf-report/inc/class.ezpdf.php on line 1320
PHP message: PHP Notice:  getimagesize(): Read error! in /usr/share/zabbix/zabbix-pdf-report/inc/class.ezpdf.php on line 1320
PHP message: PHP Notice:  getimagesize(): Read error! in /usr/share/zabbix/zabbix-pdf-report/inc/class.ezpdf.php on line 1320
PHP message: PHP Notice:  getimagesize(): Read error! in /usr/share/zabbix/zabbix-pdf-report/inc/class.ezpdf.php on line 1320
PHP message: PHP Notice:  getimagesize(): Read error! in /usr/share/zabbix/zabbix-pdf-report/inc/class.ezpdf.php on line 1320" while reading response header from upstream, client: 10.212.134.17, server: shared-zabbix.<REDACTEDDOMAIN>.com, request: "GET /zabbix-pdf-report/createpdf.php?ReportType=host&HostID=10335&GraphsOn=yes&mygraphs2=%23%28Ping%7CCPU+load%7CCPU+usage%7CCPU+util%7Cprocessor%7CDisk+space%7CSwap%7CEthernet%7CMemory+usage%7C%5ETraffic+on+%7Ctraffic+on+eth%29%23&myitems2=%23%28Utilization+of%7Cfarm+connection%7CAverage+Latency%7CNumber+of+processes%7CCache+%25+Hit%29%23&ReportRange=last&timePeriod=Hour HTTP/2.0", upstream: "fastcgi://unix:/run/php-fpm/zabbix.sock:", host: "10.1.5.20", referrer: "https://10.1.5.20/zabbix-pdf-report/chooser.php"

/var/log/nginx/error.log (END)

asalz-zh avatar Feb 24 '21 17:02 asalz-zh

Hmm... A couple of searches mention that it could be fopen being disabled in your settings, probably just for URL's, though. It seems like the EzImage function opens the image/image data with an URL and tries to save it locally and then check it's type. Since your files are always 0 bytes, it seems the stream isn't making it, so it might be that fopen on URL's is not allowed in the setup you have.

There are a few spots in createpdf.php where you could try to make sure temporary files are kept after the report is created

There's this for the text-file that ends up becoming the PDF: unlink($tmp_pdf_data);

At the bottom there's this: // Clean up temp images array_map('unlink', glob("$z_tmpimg_path/*")); rmdir("$z_tmpimg_path");

Experiment a bit with that and check your PHP settings.

martinm76 avatar Feb 24 '21 19:02 martinm76

Just checked my test server, and I have this:

apache2/php.ini:allow_url_fopen = On

martinm76 avatar Feb 24 '21 19:02 martinm76

I've got url_fopen on in the php settings image

I've commented out the "clean up" section and it leaves the temp folder with empty picture files.

Is there a way to make a curl call manually of how it is supposed to be getting the graphs?

asalz-zh avatar Mar 02 '21 15:03 asalz-zh

Odd.. You could try to do some print statements or similar in the section with the fopen og GetImageSize call. As for Curl, you might want to try something like this: https://gist.github.com/BugBuster1701/7571132

martinm76 avatar Mar 03 '21 21:03 martinm76

This can happen if you have an HTTPS connection to Zabbix, but the URL to Zabbix (variable $z_server) in config.inc.php of zabbix-pdf-report doesn't point to the domain which is written as Common Name (CN) in the server certificate. A self-signed certificate is not a problem, but a wrong domain is a problem.

neter-bg avatar Jul 15 '21 14:07 neter-bg

Anyone got an update on this issue? I have only run on either http or Let's Encrypt certificates, so @neter-bg may well have a point here. I almost always leave the host as localhost in my config. I have very limited experience with nginx.

A copy of config.inc.php with any needed redactions (but explanations of the redaction if so) would probably help, as well as a 'ls -la' from the directory the report is installed in.

martinm76 avatar May 22 '22 22:05 martinm76

Hi everyone, I've run into the same issue.

It looks like the problem sits in function GetGraphImageById(), during the first curl call, which should login to zabbix frontend and save authentication cookies.

It seems to be somehow related to HTTPS: if I configure a plain HTTP url in the z_server config variable, the function works and graphs are retrieved.

My environment: RockyLinux 8.6, PHP 7.2, Apache, Zabbix 6.0.

bitmind avatar Oct 27 '22 13:10 bitmind

Hey guys. Has anyone managed to solve this problem and could you share the steps they took here? In my case, even though I set the variable to http, as the URL all requests are in HTTPS, I believe it is not having any effect.

andrebatista2031 avatar Mar 19 '24 15:03 andrebatista2031