Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to get JSON history output #955

Closed
willfurnell opened this issue Jan 11, 2024 · 2 comments · Fixed by #985
Closed

Unable to get JSON history output #955

willfurnell opened this issue Jan 11, 2024 · 2 comments · Fixed by #985
Assignees
Labels
area/export Affects exports to other formats bug Something isn't working
Milestone

Comments

@willfurnell
Copy link

Describe the bug

The following HTML is output at the end of the JSON when requesting the history of a service for a host

<b>Fatal error</b>:  Uncaught ErrorException: Uncaught ErrorException: session_name(): Cannot change session name when headers already sent in /usr/share/php/Icinga/Web/Session/Php72Session.php:20
Stack trace:
#0 [internal function]: Icinga\Application\ApplicationBootstrap-&gt;Icinga\Application\{closure}(2, 'session_name():...', '/usr/share/php/...', 20, Array)
#1 /usr/share/php/Icinga/Web/Session/Php72Session.php(20): session_name('Icingaweb2')
#2 /usr/share/php/Icinga/Web/Session/PhpSession.php(167): Icinga\Web\Session\Php72Session-&gt;open()
#3 /usr/share/php/Icinga/Web/Controller/ActionController.php(579): Icinga\Web\Session\PhpSession-&gt;write()
#4 /usr/share/php/Icinga/Web/Controller/ActionController.php(525): Icinga\Web\Controller\ActionController-&gt;shutdownSession()
#5 /usr/share/icingaweb2/modules/icingadb/application/controllers/ErrorController.php(58): Icinga\Web\Controller\ActionController-&gt;postDispatch()
#6 /usr/share/icinga-php/vendor/vendor/shardj/zf1-future/library/Zend/Controller/Action.php(521): Icinga\Module\Icingadb\C in <b>/usr/share/icinga-php/vendor/vendor/shardj/zf1-future/library/Zend/Controller/Plugin/Broker.php</b> on line <b>262</b><br />

Additionally, the full check history for the service is not returned either in the JSON that is output, just one check result as far as I can see.

To Reproduce

  1. In your web browser, go to https://icinga/icingaweb2/icingadb/service/history?name=sshd-external-check&host.name=hostname&format=json and look at the output returned

OR

Run a cURL command like the following requesting JSON

curl -s -HContent-Type:application/json -HAccept:application/json -u api:api "https://icinga/icingaweb2/icingadb/service/history?name=service&host.name=hostname&format=json"

Expected behavior

Well formatted JSON, with the full check history is returned

Your Environment

Include as many relevant details about the environment you experienced the problem in.

  • Icinga DB Web version (System - About): 1.1.1
  • Icinga Web 2 version (System - About): 2.12.1
  • Web browser: Firefox, cURL
  • Icinga 2 version (icinga2 --version): r2.14.1-1
  • Icinga DB version (icingadb --version): v1.1.1
  • PHP version used (php --version): 7.3.33
  • Server operating system and version: CentOS 7
@nilmerg nilmerg added bug Something isn't working area/export Affects exports to other formats labels Jan 12, 2024
@nilmerg nilmerg added this to the 1.1.2 milestone Jan 12, 2024
@nilmerg
Copy link
Member

nilmerg commented Jan 17, 2024

This is very likely caused by #847.

The problem is that since then, the query results are fully loaded into memory and held there in full for a brief time. This causes an out of memory error on history views as there the number of resulting rows is usually very large.

To solve this, we may do one of the following things:

  1. Query redis in exports again for each individual result. Pro: quickly done, Con: Bad performance
  2. Fetch results in parts and query redis every nth number of them. Pro: Better performance, Con: Not easily done

I'd prefer 2) 😅

@nilmerg nilmerg added the difficulty/hard You can do this! Just ask someone for input first, please. And demand (some of) it as comment here! label Jan 17, 2024
@nilmerg
Copy link
Member

nilmerg commented Jan 17, 2024

Or 3), don't query redis at all because it's unnecessary as no current state is required due to the results being of historical nature. 🤦‍♂️

@nilmerg nilmerg added difficulty/easy Anyone can do this and removed difficulty/hard You can do this! Just ask someone for input first, please. And demand (some of) it as comment here! labels Jan 17, 2024
@nilmerg nilmerg removed the difficulty/easy Anyone can do this label Mar 19, 2024
@nilmerg nilmerg self-assigned this Mar 19, 2024
nilmerg added a commit that referenced this issue Mar 22, 2024
@nilmerg nilmerg changed the title HTML exception session_name(): Cannot change session name when headers already sent when trying to get JSON history output Unable to get JSON history output Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/export Affects exports to other formats bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants