Issue with exporting reports to PDF

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
antdis
Posts: 6
Joined: Wed Jul 07, 2021 11:12 pm

Issue with exporting reports to PDF

Post by antdis »

When trying to export a report to PDF, I get the following error page:

Failed to create PDF
Verify that your Nagios XI server can connect to the URL:
https://localhost/nagiosxi/reports/avai ... r_compat=1

If I run a curl on that url from the server, I get:
curl: (51) Unable to communicate securely with peer: requested domain name does not match the server's certificate.

If I replace the 'localhost' with the correct domain name, I get a time out error. I also found this in the logs:
/var/log/httpd/error_log

sh: line 1: 39622 Segmentation fault /usr/bin/wkhtmltopdf --lowquality --no-outline --footer-spacing 3 --margin-bottom 15mm --footer-font-size 9 --footer-right "Page [page] of [toPage]" --footer-left "2021$
sh: line 1: 37699 Segmentation fault /usr/bin/wkhtmltopdf --lowquality --no-outline --footer-spacing 3 --margin-bottom 15mm --footer-font-size 9 --footer-right "Page [page] of [toPage]" --footer-left "2021$
sh: line 1: 71024 Segmentation fault /usr/bin/wkhtmltopdf --lowquality --no-outline --footer-spacing 3 --margin-bottom 15mm --footer-font-size 9 --footer-right "Page [page] of [toPage]" --footer-left "2021$
sh: line 1: 108445 Segmentation fault /usr/bin/wkhtmltopdf --lowquality --no-outline --footer-spacing 3 --margin-bottom 15mm --footer-font-size 9 --footer-right "Page [page] of [toPage]" --footer-left "202$
sh: line 1: 120561 Segmentation fault /usr/bin/wkhtmltopdf --lowquality --no-outline --footer-spacing 3 --margin-bottom 15mm --footer-font-size 9 --footer-right "Page [page] of [toPage]" --footer-left "202$
sh: line 1: 15197 Segmentation fault /usr/bin/wkhtmltopdf --lowquality --no-outline --footer-spacing 3 --margin-bottom 15mm --footer-font-size 9 --footer-right "Page [page] of [toPage]" --footer-left "2021$
sh: line 1: 122731 Segmentation fault /usr/bin/wkhtmltopdf --lowquality --no-outline --footer-spacing 3 --margin-bottom 15mm --footer-font-size 9 --footer-right "Page [page] of [toPage]" --footer-left "202$
sh: line 1: 676 Segmentation fault /usr/bin/wkhtmltopdf --lowquality --no-outline --footer-spacing 3 --margin-bottom 15mm --footer-font-size 9 --footer-right "Page [page] of [toPage]" --footer-left "2021$
sh: line 1: 3689 Segmentation fault /usr/bin/wkhtmltopdf --lowquality --no-outline --footer-spacing 3 --margin-bottom 15mm --footer-font-size 9 --footer-right "Page [page] of [toPage]" --footer-left "2021$

sh: line 1: 3689 Segmentation fault /usr/bin/wkhtmltopdf --lowquality --no-outline --footer-spacing 3 --margin-bottom 15mm --footer-font-size 9 --footer-right "Page [page] of [toPage]" --footer-left "2021-08-27 09:53:44" --no-stop-slow-scripts 'https://localhost/nagiosxi/reports/avai ... r_compat=1' '/usr/local/nagiosxi/tmp/exportreport-username-6128ee689e61b' &>>/usr/local/nagiosxi/var/wkhtmltox.log


/usr/local/nagiosxi/var/wkhtmltox.log
/usr/bin/wkhtmltopdf --lowquality --no-outline --footer-spacing 3 --margin-bottom 15mm --footer-font-size 9 --footer-right "Page [page] of [toPage]" --footer-left "2021-08-27 10:29:39" --no-stop-slow-scripts 'https://localhost/nagiosxi/reports/avai ... r_compat=1' '/usr/local/nagiosxi/tmp/exportreport-username-6128f6d3b30d3'


The file /usr/local/nagiosxi/tmp/exportreport-username-6128f6d3b30d3 doesn't exist.
User avatar
pbroste
Posts: 1288
Joined: Tue Jun 01, 2021 1:27 pm

Re: Issue with exporting reports to PDF

Post by pbroste »

Hello @antdis

Thanks for reaching out, you state that you are running into SSL issues; are you able to pull-up the report if you address without SSL and hit on http:// (instead of https://)?

Are you utilizing FQDN or are you hitting it up with the IP Address? If you are using an FQDN you may need to update '/etc/hosts'.

'/etc/hosts' Should look or add a line:
127.0.0.1 FQDN
Thanks,
Perry
antdis
Posts: 6
Joined: Wed Jul 07, 2021 11:12 pm

Re: Issue with exporting reports to PDF

Post by antdis »

Hello and thanks for your response.

I'm not 100% sure this is a SSL issue, I did get an error about using localhost from the local server, but we kind of expect that to happen. That's why I switched the localhost to the fqdn and tried to curl that as well.

I do have the fqdn in the hosts file. Also, we have two environments (one for production and one for development), I see this issue in our production environment, but I don't in dev. Between the two the dns and hosts file setup are the same with the only difference being the difference in the name.

I'm not ruling out that the issue is related to SSL, but I am thinking it's more related to the segmentation issue. I can use the pdf export from ssh to make a pdf file of google.com, that worked correctly. I also get the same error if I try to use the download as jpg.
User avatar
pbroste
Posts: 1288
Joined: Tue Jun 01, 2021 1:27 pm

Re: Issue with exporting reports to PDF

Post by pbroste »

Hello @antdis

Thanks for following up and would like to take a look at your Nagios XI System Profile so we can see what is going on with the certificate verification.

To send us your system profile.
  • Login to the Nagios XI GUI using a web browser.
  • Click the "Admin" > "System Profile" Menu
  • Click the "Download Profile" button
  • Save the profile.zip file and send via Private Message
Thanks,
Perry
User avatar
pbroste
Posts: 1288
Joined: Tue Jun 01, 2021 1:27 pm

Re: Issue with exporting reports to PDF

Post by pbroste »

Hello @antdis

Thanks for following up, want to have you run the command to get the System Profile. Please let me know the results.

Code: Select all

rm -rf /usr/local/nagiosxi/var/components/profile.zip
/usr/local/nagiosxi/scripts/components/getprofile.sh SUPPORT
Then send the resulting /usr/local/nagiosxi/var/components/profile.zip​ file via Private Message.

Thanks,
Perry
User avatar
pbroste
Posts: 1288
Joined: Tue Jun 01, 2021 1:27 pm

Re: Issue with exporting reports to PDF

Post by pbroste »

Hello @antdis

Thanks for sending over the System Profile.

In review, we see the following message "sudo: sorry, you must have a tty to run sudo" in the error log and want to know if there has been any changes or updates to the sudoers?

Let me know what these look like:

Code: Select all

grep NAGIOS /etc/sudoers
grep requiretty /etc/sudoers
By default we should see the following in the '/etc/sudoers':

Code: Select all

User_Alias      NAGIOSXI=nagios
User_Alias      NAGIOSXIWEB=apache
NAGIOSXI ALL = NOPASSWD:/etc/init.d/nagios start
NAGIOSXI ALL = NOPASSWD:/etc/init.d/nagios stop
NAGIOSXI ALL = NOPASSWD:/etc/init.d/nagios restart
NAGIOSXI ALL = NOPASSWD:/etc/init.d/nagios reload
NAGIOSXI ALL = NOPASSWD:/etc/init.d/nagios status
NAGIOSXI ALL = NOPASSWD:/etc/init.d/nagios checkconfig
NAGIOSXI ALL = NOPASSWD:/etc/init.d/npcd start
NAGIOSXI ALL = NOPASSWD:/etc/init.d/npcd stop
NAGIOSXI ALL = NOPASSWD:/etc/init.d/npcd restart
NAGIOSXI ALL = NOPASSWD:/etc/init.d/npcd reload
NAGIOSXI ALL = NOPASSWD:/etc/init.d/npcd status
NAGIOSXI ALL = NOPASSWD:/usr/bin/php /usr/local/nagiosxi/scripts/components/autodiscover_new.php *
NAGIOSXI ALL = NOPASSWD:/usr/bin/php /usr/local/nagiosxi/scripts/send_to_nls.php *
NAGIOSXI ALL = NOPASSWD:/usr/bin/php /usr/local/nagiosxi/scripts/migrate/migrate.php *
NAGIOSXI ALL = NOPASSWD:/usr/local/nagiosxi/scripts/components/getprofile.sh
NAGIOSXI ALL = NOPASSWD:/usr/local/nagiosxi/scripts/upgrade_to_latest.sh
NAGIOSXI ALL = NOPASSWD:/usr/local/nagiosxi/scripts/change_timezone.sh
NAGIOSXI ALL = NOPASSWD:/usr/local/nagiosxi/scripts/manage_services.sh *
NAGIOSXI ALL = NOPASSWD:/usr/local/nagiosxi/scripts/reset_config_perms.sh
NAGIOSXI ALL = NOPASSWD:/usr/local/nagiosxi/scripts/manage_ssl_config.sh *
NAGIOSXI ALL = NOPASSWD:/usr/local/nagiosxi/scripts/backup_xi.sh *
NAGIOSXIWEB ALL = NOPASSWD:/etc/init.d/snmptt restart
NAGIOSXIWEB ALL = NOPASSWD:/usr/bin/tail -100 /var/log/messages
NAGIOSXIWEB ALL = NOPASSWD:/usr/bin/tail -100 /var/log/httpd/error_log
NAGIOSXIWEB ALL = NOPASSWD:/usr/bin/tail -100 /var/log/mysqld.log
NAGIOSXIWEB ALL = NOPASSWD:/usr/bin/php /usr/local/nagiosxi/scripts/components/autodiscover_new.php *
NAGIOSXIWEB ALL = NOPASSWD:/usr/local/nagiosxi/scripts/components/getprofile.sh
NAGIOSXIWEB ALL = NOPASSWD:/usr/local/nagiosxi/scripts/repair_databases.sh
NAGIOSXIWEB ALL = NOPASSWD:/usr/local/nagiosxi/scripts/manage_services.sh *
Want to have you grab some Firefox development tool results in the Networking tab by doing the following:
  • Open Firefox with Development tools menu open to Networking tab
  • Nagios XI web console > Reports > Download > Select PDF
  • Look for the entry that ran "Availability.php" and select
  • Right-click on the "Availability.php" selection in Dev Tools and select copy > Copy as Curl (POSIX)
  • Paste the Curl command line that you just copied into an ssh terminal session
Here is an example of the curl command:

Code: Select all

curl 'https://xxx.xxx.xxx.xxx/nagiosxi/reports/availability.php?reportperiod=last24hours&startdate=&enddate=&host=&service=&hostgroup=&servicegroup=&advanced=0&assumeinitialstates=yes&assumestateretention=yes&assumestatesduringdowntime=yes&includesoftstates=no&assumedhoststate=3&assumedservicestate=6&timeperiod=&mode=getreport&mode=pdf' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'DNT: 1' -H 'Connection: keep-alive' -H 'Referer: https://xxx.xxx.xxx.xxx/nagiosxi/reports/availability.php?&=' -H 'Cookie: nagiosxi=g79bcnfhud60ul5pf69f109gh3' -H 'Upgrade-Insecure-Requests: 1' -H 'Sec-Fetch-Dest: iframe' -H 'Sec-Fetch-Mode: navigate' -H 'Sec-Fetch-Site: same-origin' -H 'Sec-Fetch-User: ?1'
Append the following: -k --output /tmp/report.txt --verbose to the command line so it looks like this example:

Code: Select all

curl 'https://xxx.xxx.xxx.xxx/nagiosxi/reports/availability.php?reportperiod=last24hours&startdate=&enddate=&host=&service=&hostgroup=&servicegroup=&advanced=0&assumeinitialstates=yes&assumestateretention=yes&assumestatesduringdowntime=yes&includesoftstates=no&assumedhoststate=3&assumedservicestate=6&timeperiod=&mode=getreport&mode=pdf' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'DNT: 1' -H 'Connection: keep-alive' -H 'Referer: https://xxx.xxx.xxx.xxx/nagiosxi/reports/availability.php?&=' -H 'Cookie: nagiosxi=g79bcnfhud60ul5pf69f109gh3' -H 'Upgrade-Insecure-Requests: 1' -H 'Sec-Fetch-Dest: iframe' -H 'Sec-Fetch-Mode: navigate' -H 'Sec-Fetch-Site: same-origin' -H 'Sec-Fetch-User: ?1' -k --verbose --output /tmp/report.pdf
Note: use --cacert <file> instead of -k to verify certificate.

Please run and let me know the results,
Perry
antdis
Posts: 6
Joined: Wed Jul 07, 2021 11:12 pm

Re: Issue with exporting reports to PDF

Post by antdis »

Thanks for your response.

This issue was resolved in version 5.8.1 and was related to usernames being capitalized. Thank you for your assistance.
User avatar
pbroste
Posts: 1288
Joined: Tue Jun 01, 2021 1:27 pm

Re: Issue with exporting reports to PDF

Post by pbroste »

Hello @antdis,

Super, thanks for following up and letting us know what resolved the issue. Will go ahead and lock.

Thanks,
Perry
Locked