Skip to content

Commit

Permalink
QA: Fix host count for #5279 and correct one query in lib/utility.php
Browse files Browse the repository at this point in the history
  • Loading branch information
TheWitness committed Apr 3, 2023
1 parent 23f091e commit 9ea1246
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cli/rebuild_poller_cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
);

/* add special host 0 */
if ($poller_id == 1) {
if ($poller_id == 1 && $host_template_id == 0 && $host_id == 0) {
$hosts[0] = 0;
}

Expand Down
11 changes: 9 additions & 2 deletions lib/utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ function repopulate_poller_cache() {
$poller_items = array();
$local_data_ids = array();
$poller_prev = 1;

$i = 0;
$j = 0;

Expand All @@ -62,14 +63,17 @@ function repopulate_poller_cache() {

if ($i > 500 || $poller_prev != $poller_id) {
poller_update_poller_cache_from_buffer($local_data_ids, $poller_items, $poller_prev);

$i = 0;

$local_data_ids = array();
$poller_items = array();
}

$poller_prev = $poller_id;
$poller_items = array_merge($poller_items, update_poller_cache($data));
$local_data_ids[] = $data['id'];

$i++;
$j++;
}
Expand All @@ -95,11 +99,14 @@ function repopulate_poller_cache() {
db_execute('TRUNCATE TABLE poller_data_template_field_mappings');
db_execute('INSERT IGNORE INTO poller_data_template_field_mappings
SELECT dtr.data_template_id, dif.data_name,
GROUP_CONCAT(dtr.data_source_name ORDER BY dtr.data_source_name) AS data_source_names, NOW()
FROM data_template_rrd AS dtr
GROUP_CONCAT(DISTINCT dtr.data_source_name ORDER BY dtr.data_source_name) AS data_source_names, NOW()
FROM graph_templates_item AS gti
INNER JOIN data_template_rrd AS dtr
ON gti.task_item_id = dtr.id
INNER JOIN data_input_fields AS dif
ON dtr.data_input_field_id = dif.id
WHERE dtr.local_data_id = 0
AND gti.local_graph_id = 0
GROUP BY dtr.data_template_id, dif.data_name');

if (isset($_SESSION['sess_user_id'])) {
Expand Down

0 comments on commit 9ea1246

Please sign in to comment.