Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

fix(topcounter): use session cache to store top counter hosts/services results #8189

Merged
merged 13 commits into from
Mar 5, 2020

Conversation

garnier-quentin
Copy link
Contributor

Pull Request Template

Description

On huge platform with many users (around 200), top counters services/hosts slows overall database real-time performances.
The best solution should have a configuration for read-only mariadb/mysql replicas. Like that we could have many users and we don't slow real time database for centreon-broker. First, It's important for top counters, services monitoring and some widgets. For configuration and graphs, we could do it after.
That solution will take some time. So i have done a patch. It fixes following issue:

  • my refresh time 'AjaxTimeReloadStatistic' is 60 but react calls topcounters services and hosts every 30 seconds
  • if we have multiple tabs on your browser with the same session, it calls top counters too many times.

I use the session cache to solve the issue.

Fixes # (issue)

Type of change

  • Patch fixing an issue (non-breaking change)
  • New functionality (non-breaking change)
  • Breaking change (patch or feature) that might cause side effects breaking part of the Software
  • Updating documentation (missing information, typo...)

Target serie

  • 2.8.x
  • 18.10.x
  • 19.04.x
  • 19.10.x
  • 20.04.x (master)

How this pull request can be tested ?

If you call the top counter 2 times in a row, it should provide the same result (there is the 'time' attribute).

Checklist

Community contributors & Centreon team

  • I followed the coding style guidelines provided by Centreon
  • I have commented my code, especially new classes, functions or any legacy code modified. (docblock)
  • I have commented my code, especially hard-to-understand areas of the PR.
  • I have made corresponding changes to the documentation.
  • I have rebased my development branch on the base branch (master, maintenance).

Centreon team only

  • I have made sure that the unit tests related to the story are successful.
  • I have made sure that unit tests cover 80% of the code written for the story.
  • I have made sure that acceptance tests related to the story are successful (local and CI)

loiclau
loiclau previously approved these changes Dec 17, 2019
@cgagnaire cgagnaire changed the title use session cache to store top counter hosts/services results fix(topcounter): use session cache to store top counter hosts/services results Dec 17, 2019
www/api/internal.php Outdated Show resolved Hide resolved
@cgagnaire cgagnaire requested review from kduret and callapa January 16, 2020 12:47
www/api/class/centreon_topcounter.class.php Outdated Show resolved Hide resolved
www/api/class/centreon_topcounter.class.php Show resolved Hide resolved
www/api/class/centreon_topcounter.class.php Show resolved Hide resolved
www/class/centreonSession.class.php Outdated Show resolved Hide resolved
@cgagnaire cgagnaire added pr/internal-ps PR made by the Centreon ProServices Team status/needs-attention The PR is on-hold. The reasons are specified in the PR labels Feb 6, 2020
sc979
sc979 previously approved these changes Feb 14, 2020
@sc979 sc979 requested review from kduret, callapa and loiclau February 14, 2020 09:38
@@ -612,6 +619,11 @@ public function getServicesStatus()
throw new \RestUnauthorizedException("You're not authorized to access resource datas");
}

if (isset($_SESSION['topCounterServiceStatus']) &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a function will avoid to duplicate lines 556->559 & 622->625

sc979
sc979 previously approved these changes Feb 24, 2020
@cgagnaire cgagnaire merged commit 3b8df36 into master Mar 5, 2020
@cgagnaire cgagnaire deleted the topcounter-performance branch March 5, 2020 14:39
cgagnaire added a commit that referenced this pull request Mar 5, 2020
…s results (#8189)

* use session cache to store top counter hosts/services results

* resolve comments review

* enh(performance): session size fix

* fix(topcounter): manage reviews

* fix topcounters session errors

* fix timezone

* replace deprecated method

* remove useless request to get configuration poller main.cfg

* Update moveFiles.php

* Update moveFiles.php

Co-authored-by: qgarnier <garnier.quentin@gmail.com>
Co-authored-by: sc979 <34628915+sc979@users.noreply.github.com>
Co-authored-by: Kevin Duret <duret.kevin@gmail.com>
cgagnaire added a commit that referenced this pull request Mar 5, 2020
…s results (#8189)

* use session cache to store top counter hosts/services results

* resolve comments review

* enh(performance): session size fix

* fix(topcounter): manage reviews

* fix topcounters session errors

* fix timezone

* replace deprecated method

* remove useless request to get configuration poller main.cfg

* Update moveFiles.php

* Update moveFiles.php

Co-authored-by: qgarnier <garnier.quentin@gmail.com>
Co-authored-by: sc979 <34628915+sc979@users.noreply.github.com>
Co-authored-by: Kevin Duret <duret.kevin@gmail.com>

Conflicts:
	www/class/centreon.class.php
victorvassilev added a commit that referenced this pull request Mar 9, 2020
* enh(apiv2): add extra fields to host read endpoint
Resolves: MON-4943

* fix(code): Clean switch case service monitoring (#8285)

* fix(code): dedicated meta event console does not exist anymore

* fix(code): scheduling queue console does not exist anymore

* fix(code): merge some cases

Co-authored-by: Colin Gagnaire <cgagnaire@centreon.com>

* fix(remote-server): fix import with strict mode (#7944)

Refs: MON-7944

* Update src/Centreon/Domain/Monitoring/Host.php

Co-Authored-By: Kevin Duret <kduret@centreon.com>

* Update src/Centreon/Domain/Monitoring/Host.php

Co-Authored-By: Kevin Duret <kduret@centreon.com>

* doc(api): document how to generate html api documentation (#8394)

* fix(topcounter): use session cache to store top counter hosts/services results (#8189)

* use session cache to store top counter hosts/services results

* resolve comments review

* enh(performance): session size fix

* fix(topcounter): manage reviews

* fix topcounters session errors

* fix timezone

* replace deprecated method

* remove useless request to get configuration poller main.cfg

* Update moveFiles.php

* Update moveFiles.php

Co-authored-by: qgarnier <garnier.quentin@gmail.com>
Co-authored-by: sc979 <34628915+sc979@users.noreply.github.com>
Co-authored-by: Kevin Duret <duret.kevin@gmail.com>

* enh(config): prepare anomalydetection module (#8321)

* enh(config): prepare anomalydetection module

* Update service.class.php

* fix(config): remove dead code

Co-authored-by: qgarnier <garnier.quentin@gmail.com>

* enh(apiv2): add extra fields to host read endpoint
Resolves: MON-4943

* Update src/Centreon/Domain/Monitoring/Host.php

Co-Authored-By: Kevin Duret <kduret@centreon.com>

* Update src/Centreon/Domain/Monitoring/Host.php

Co-Authored-By: Kevin Duret <kduret@centreon.com>

* remove api html doc

Co-authored-by: Colin Gagnaire <cgagnaire@centreon.com>
Co-authored-by: Kevin Duret <kduret@centreon.com>
Co-authored-by: qgarnier <garnier.quentin@gmail.com>
Co-authored-by: sc979 <34628915+sc979@users.noreply.github.com>
Co-authored-by: Kevin Duret <duret.kevin@gmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/performance kind/enhancement pr/internal-ps PR made by the Centreon ProServices Team status/needs-attention The PR is on-hold. The reasons are specified in the PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants