Page 1 of 2

Mailed report is blank but fine on screen

Posted: Thu May 03, 2018 7:10 am
by eloyd
Despite increasing max_execution_time to 60 and memory_limit to 256M in /etc/php.ini, scheduled reports in our Nagios XI 5.4.13 are coming up blank. At least, the executive summary is. 1KB file is generated with no valid PDF content. The report shows fine on the screen. Switching to JPG report gives the same result. A 1KB empty JPG.

Thoughts?

Re: Mailed report is blank but fine on screen

Posted: Thu May 03, 2018 1:18 pm
by tgriep
Reports are generated using the External URL in the Admin > System Settings menu, make sure it is valid.
If not, update it and try again.
Also, if you open the PDF file in a text editor, it sometimes will display the error, can you try that and post the error?

Also, can you run this as root on the Nagios server.

Code: Select all

tail -f /var/log/httpd/*_log
Then try and download the PDF or JPG file and post the output of the tail command. I should have some sort of an error we can work with.

Re: Mailed report is blank but fine on screen

Posted: Thu May 03, 2018 1:59 pm
by eloyd
The external URL is valid. But now that I know that's what I need to look for, I can tell you what the problem is. Our external URL contains a port specifier. That port is being dropped from the URL when Nagios tries to make the connection. Port 80 (the default port) will return a blank page no matter what URL you ask for. We use this for security reasons. So we need to have the port specified in the external URL respected in this request, please. Our external URL looks something like: http://REDACTED:8080. What shows up in the error log is a specific hit against port 80:

Code: Select all

--2018-05-03 14:54:32--  http://REDACTED/nagiosxi//reports/execsummary.php?reportperiod=last24hours&startdate=&enddate=&host=&service=&hostgroup=&servicegroup=&advanced=0&assumeinitialstates=yes&assumestateretention=yes&assumestatesduringdowntime=yes&includesoftstates=no&assumedhoststate=3&assumedservicestate=6&timeperiod=&username=nagiosadmin&ticket=jdr6imlt&locale=en_US&mode=pdf
Resolving REDACTED... <valid ip>
Connecting to REDACTED|<valid IP>|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 350 [text/html]
Saving to: "/usr/local/nagiosxi/tmp/scheduledreport-nagiosadmin-eB7okT-execsummary.pdf"
     0K                                                       100% 22.1M=0s
2018-05-03 14:54:32 (22.1 MB/s) - "/usr/local/nagiosxi/tmp/scheduledreport-nagiosadmin-eB7okT-execsummary.pdf" saved [350/350]

Re: Mailed report is blank but fine on screen

Posted: Thu May 03, 2018 3:06 pm
by tgriep
There is a setting in the /usr/local/nagiosxi/html/config.inc.php that allows the system to use a different port for the subsystem calls.
Edit this line and put in the port number.

Code: Select all

$cfg['port_number'] = false;
like

Code: Select all

$cfg['port_number'] = 8080;
Save it and restart Apache by running

Code: Select all

service httpd restart
Then see if the report can be downloaded.

Re: Mailed report is blank but fine on screen

Posted: Thu May 03, 2018 3:25 pm
by eloyd
The developer in me wonders why the external URL, port and all, isn't use as it instead of having to hard code a value in a config file? Besides, if it's the machine calling itself, why not use the internal URL in the first place? There's no other option? Like, maybe respecting the port number assigned in the external URL? :-)

Re: Mailed report is blank but fine on screen

Posted: Fri May 04, 2018 8:54 am
by mcapra

Re: Mailed report is blank but fine on screen

Posted: Fri May 04, 2018 10:05 am
by eloyd
Indeed. I just kinda feel like, if we're going to be https://tools.ietf.org/html/rfc3986#section-3.2.3 compliant, and we specify a port, it should be used.

Re: Mailed report is blank but fine on screen

Posted: Fri May 04, 2018 12:06 pm
by tgriep
I think it has to do with where the client PC is when accessing the XI GUI.

If it is external and the External URL is set differently than the Internal URL or that the external URL is a NATed IP, that is why it works that way.

Did setting the port in the config.inc.php file fix the report?

Re: Mailed report is blank but fine on screen

Posted: Fri May 04, 2018 12:18 pm
by eloyd
We are not making the change to the config file. I may not have been clear on what's failing. The attached file in the automatically generated and scheduled report (PDF or JPG) contains blank HTML code. No one is trying to click on the link in the email (that part works fine). It's the attachment that's broken. It's broken because whatever is generating it internally is trying to connect to the external URL configuration parameter but ignoring the port specified. Since the default port 80 on the external URL will work (but directs to a blank page for security purposes), Nagios will not be able to use the external URL without using the specified port to create this report.

Re: Mailed report is blank but fine on screen

Posted: Fri May 04, 2018 1:58 pm
by tgriep
If the PDF file is larger than zero bytes, can you open it in a text editor and post what you find in it?
A quick look at the code shows it to be using the External URL.