Page 1 of 2

Scheduled Availability Report generates corrupt PDF files

Posted: Tue Jan 08, 2019 6:03 am
by DennisPR
Hi,

I'm having trouble with all Availability Reports on my Nagios XI 5.5.8.
The generated PDF files are all 349 bytes and unreadable.
When I run the same report manually it generates the PDF ok.

This is the output from the command tail -f /var/log/httpd/error_log

Code: Select all

PHP Warning:  Invalid argument supplied for foreach() in /usr/local/nagiosxi/html/includes/components/nagiosim/nagiosim.inc.php on line 491
--2019-01-08 11:35:31--  http://ap-dco67-mon.bel.centric.lan/nagiosxi//reports/availability.php?reportperiod=lastmonth&startdate=&enddate=&host=&service=&hostgroup=frbe-all&servicegroup=&advanced=0&assumeinitialstates=yes&assumestateretention=yes&assumestatesduringdowntime=yes&includesoftstates=no&assumedhoststate=3&assumedservicestate=6&timeperiod=&locale=en&mode=pdf&token=d2bab6cc1f61c577f07da6101f7852f2523edabc
Resolving ap-dco67-mon.bel.centric.lan... 10.75.1.21
Connecting to ap-dco67-mon.bel.centric.lan|10.75.1.21|:80... connected.
HTTP request sent, awaiting response... Loading pages (1/6)
PHP Warning:  Module 'PDO' already loaded in Unknown on line 0 37%
PHP Warning:  Module 'pdo_mysql' already loaded in Unknown on line 0
No entry for terminal type "unknown";
using dumb terminal settings.
PHP Warning:  Invalid argument supplied for foreach() in /usr/local/nagiosxi/html/includes/components/nagiosim/nagiosim.inc.php on line 491
[Tue Jan 08 11:49:02 2019] [error] [client 10.70.1.50] PHP Warning:  Division by zero in /usr/local/nagiosxi/html/includes/components/opscreen/merlin.php on line 156, referer: http://ap-dco67-mon/nagiosxi/includes/components/opscreen/opscreen.php
[Tue Jan 08 11:49:02 2019] [error] [client 10.70.1.50] PHP Warning:  Division by zero in /usr/local/nagiosxi/html/includes/components/opscreen/merlin.php on line 158, referer: http://ap-dco67-mon/nagiosxi/includes/components/opscreen/opscreen.php
[Tue Jan 08 11:49:02 2019] [error] [client 10.70.1.50] PHP Warning:  Division by zero in /usr/local/nagiosxi/html/includes/components/opscreen/merlin.php on line 204, referer: http://ap-dco67-mon/nagiosxi/includes/components/opscreen/opscreen.php
[Tue Jan 08 11:49:02 2019] [error] [client 10.70.1.50] PHP Warning:  Division by zero in /usr/local/nagiosxi/html/includes/components/opscreen/merlin.php on line 206, referer: http://ap-dco67-mon/nagiosxi/includes/components/opscreen/opscreen.php
[Tue Jan 08 11:49:03 2019] [error] [client 10.70.1.44] PHP Warning:  Division by zero in /usr/local/nagiosxi/html/includes/components/opscreen/merlin.php on line 156, referer: http://ap-dco67-mon.bel.centric.lan/nagiosxi/includes/components/opscreen/opscreen.php
[Tue Jan 08 11:49:03 2019] [error] [client 10.70.1.44] PHP Warning:  Division by zero in /usr/local/nagiosxi/html/includes/components/opscreen/merlin.php on line 158, referer: http://ap-dco67-mon.bel.centric.lan/nagiosxi/includes/components/opscreen/opscreen.php
[Tue Jan 08 11:49:03 2019] [error] [client 10.70.1.44] PHP Warning:  Division by zero in /usr/local/nagiosxi/html/includes/components/opscreen/merlin.php on line 204, referer: http://ap-dco67-mon.bel.centric.lan/nagiosxi/includes/components/opscreen/opscreen.php
[Tue Jan 08 11:49:03 2019] [error] [client 10.70.1.44] PHP Warning:  Division by zero in /usr/local/nagiosxi/html/includes/components/opscreen/merlin.php on line 206, referer: http://ap-dco67-mon.bel.centric.lan/nagiosxi/includes/components/opscreen/opscreen.php
[Tue Jan 08 11:49:09 2019] [error] [client 10.70.1.27] PHP Warning:  Division by zero in /usr/local/nagiosxi/html/includes/components/opscreen/merlin.php on line 204, referer: http://ap-dco67-mon.bel.centric.lan/nagiosxi/includes/components/opscreen/opscreen.php
[Tue Jan 08 11:49:09 2019] [error] [client 10.70.1.27] PHP Warning:  Division by zero in /usr/local/nagiosxi/html/includes/components/opscreen/merlin.php on line 206, referer: http://ap-dco67-mon.bel.centric.lan/nagiosxi/includes/components/opscreen/opscreen.php
Read error (Connection timed out) in headers.
Retrying.

--2019-01-08 11:50:32--  (try: 2)  http://ap-dco67-mon.bel.centric.lan/nagiosxi//reports/availability.php?reportperiod=lastmonth&startdate=&enddate=&host=&service=&hostgroup=frbe-all&servicegroup=&advanced=0&assumeinitialstates=yes&assumestateretention=yes&assumestatesduringdowntime=yes&includesoftstates=no&assumedhoststate=3&assumedservicestate=6&timeperiod=&locale=en&mode=pdf&token=d2bab6cc1f61c577f07da6101f7852f2523edabc
Connecting to ap-dco67-mon.bel.centric.lan|10.75.1.21|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 27 [text/html]
Saving to: "/usr/local/nagiosxi/tmp/scheduledreport-dpeere-bs60kb-Availability_Report.pdf"

     0K                                                       100% 4.59M=0s

2019-01-08 11:50:32 (4.59 MB/s) - "/usr/local/nagiosxi/tmp/scheduledreport-dpeere-bs60kb-Availability_Report.pdf" saved [27/27]

Counting pages (2/6)
Resolving links (4/6)
Loading headers and footers (5/6)
Printing pages (6/6)
Done


Re: Scheduled Availability Report generates corrupt PDF file

Posted: Tue Jan 08, 2019 2:23 pm
by cdienger
What version of XI is this?

I assume you've seen https://support.nagios.com/kb/article.php?id=611 and increased the php.ini settings per https://support.nagios.com/kb/article.php?id=611. Is this correct?

Do you see anything being logged to /usr/local/nagiosxi/var/wkhtmltox.log when it fails?

Re: Scheduled Availability Report generates corrupt PDF file

Posted: Mon Jan 14, 2019 3:38 am
by DennisPR
Hi

I'm running Nagios XI 5.5.8.
Here are some important settings of my php.ini

Code: Select all

max_execution_time = 180
max_input_time = 240
memory_limit = 1024M
max_input_vars = 5000
There is no /usr/local/nagiosxi/var/wkhtmltox.log

Re: Scheduled Availability Report generates corrupt PDF file

Posted: Mon Jan 14, 2019 4:21 pm
by npolovenko
@DennisPR, Please run the following script as root and let me know if it resolves the issue:
cd /usr/local/nagiosxi/scripts/
./repair_databases.sh
Can you also upload the following file in the ticket?
/usr/local/nagiosxi/html/config.inc.php

Re: Scheduled Availability Report generates corrupt PDF file

Posted: Mon Jan 21, 2019 8:37 am
by DennisPR
Running the repair databases script didn't solve the problem

Re: Scheduled Availability Report generates corrupt PDF file

Posted: Mon Jan 21, 2019 3:39 pm
by npolovenko
@DennisPR, Please open the config.inc.php file and replace the following block at the end:
///////// keep these in order /////////

// include generic db defs
if (!defined('CFG_ONLY')) { if (!defined('CFG_ONLY')) { require_once(dirname(__FILE__).'/includes/db.inc.php'); } }

// include generic definitions
if (!defined('CFG_ONLY')) { if (!defined('CFG_ONLY')) { require_once(dirname(__FILE__).'/db/common.inc.php'); } }
// include db-specific definitions
//if (!defined('CFG_ONLY')) { if (!defined('CFG_ONLY')) { require_once(dirname(__FILE__).'/db/'.$cfg['dbtype'].'.inc.php'); } }

?>
With:
///////// keep these in order /////////

if (!defined('CFG_ONLY')) {

// include generic db defs
require_once(dirname(__FILE__) . '/includes/db.inc.php');

// include generic definitions
require_once(dirname(__FILE__) . '/db/common.inc.php');

}
Do not add anything else, including "?>".

Save the file and let me know if this fixes the issue.

Run:
service httpd restart
If the pdf file comes corrupted again please upload it in the thread.

Re: Scheduled Availability Report generates corrupt PDF file

Posted: Mon Jan 28, 2019 5:20 am
by DennisPR
Hi that didn't solve the problem see attachment.

Re: Scheduled Availability Report generates corrupt PDF file

Posted: Mon Jan 28, 2019 1:25 pm
by npolovenko
@DennisPR, Please update to XI 5.5.9. Then go to the Admin menu and click on System Settings in the left column. Make sure the timezone is accurate. Have you changed the timezone on this server recently?

Re: Scheduled Availability Report generates corrupt PDF file

Posted: Tue Jan 29, 2019 4:37 am
by DennisPR
Upgrading to 5.5.9 didn't solve the problem as well.
The Timezone is set to (UTC+ 01:00) Brussels like it should be in the system settings of Nagios.
I don't know if someone ever changed the timezone manually on this server that has been running for a couple of years.
Do you want me to check anything else ?

Re: Scheduled Availability Report generates corrupt PDF file

Posted: Tue Jan 29, 2019 3:32 pm
by ssax
If you open up the PDF you attached with a text editor you will see this message:

Code: Select all

Your session has timed out.
It could be related to these messages:

Code: Select all

PHP Warning:  Module 'PDO' already loaded in Unknown on line 0 37%
PHP Warning:  Module 'pdo_mysql' already loaded in Unknown on line 0
Please attach your /etc/php.ini and the output of these commands:

Code: Select all

ls -l /etc/php.d
grep "PDO\|pdo_mysql" /etc/php.d/*
Additionally, please PM me a fresh copy of your profile, you can download it from Admin > System Profile > Download Profile so that I can review some settings.