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

Tree search does not take hosts belonging to a site into account #4293

Closed
browniebraun opened this issue Jun 8, 2021 · 8 comments
Closed
Assignees
Labels
bug Undesired behaviour resolved A fixed issue
Milestone

Comments

@browniebraun
Copy link
Member

browniebraun commented Jun 8, 2021

Describe the bug

For my company we are automatically generating a geographic tree with more than 500 sites. Hosts will in general only be assigned to a site. Using that method the tree search will never return a hit for a host that belongs to specific site, because there is no record existing in graph_tree_items referring its individual host_id.

To Reproduce

Create some leaf sites, assign those to the Cacti tree or a tree branch and finally assign some hosts to those new test site records.
Go to the tree view and enter the first characters of one of those hosts.

Expected behavior

Hosts will be found, tree will be opened down to host level, including leaf site branches.

Reality

No hits. Cacti returns nothing.

Solution

Better solutions may exist, but the easiest way is to take the host table in function "get_matching_nodes()" two times (with a RIGHT JOIN) into account as follows:

	$matching = db_fetch_assoc_prepared("SELECT gti.parent, gti.graph_tree_id
		FROM graph_tree_items AS gti
		LEFT JOIN host AS h
		ON h.id=gti.host_id
		RIGHT JOIN host AS h2
		ON h2.site_id=gti.site_id
		LEFT JOIN graph_templates_graph AS gtg
		ON gtg.local_graph_id=gti.local_graph_id AND gtg.local_graph_id>0
		WHERE gtg.title_cache LIKE ?
		OR h.description LIKE ?
		OR h.hostname LIKE ?
		OR h2.description LIKE ?
		OR h2.hostname LIKE ?
		OR gti.title LIKE ?",
		array($filter, $filter, $filter, $filter, $filter, $filter));

Screenshot

Patch in place

image

Version

  • Cacti 1.2.16
@browniebraun browniebraun added bug Undesired behaviour unverified Some days we don't have a clue and removed unverified Some days we don't have a clue labels Jun 8, 2021
@netniV
Copy link
Member

netniV commented Jun 8, 2021

Are you looking into this one @browniebraun ?

@TheWitness
Copy link
Member

Having seen the code in detail, I would expect this scenario to have never been tested.

@browniebraun
Copy link
Member Author

yep, similar to the missing sort mechanism for sites within a branch. see my previous patch. :) I believe we have just missed it.

@netniV
Copy link
Member

netniV commented Jun 9, 2021

Cool. I'll assign you then.

@browniebraun
Copy link
Member Author

roger that. ;)

@browniebraun
Copy link
Member Author

I was out for the last two weeks supporting a move, means I have not forgotten my task.

@TheWitness
Copy link
Member

What task was that? 🙄

@TheWitness
Copy link
Member

Commit it dude 👍

TheWitness added a commit that referenced this issue Jul 1, 2021
Tree search does not take hosts belonging to a site into account
@TheWitness TheWitness added the resolved A fixed issue label Jul 1, 2021
@TheWitness TheWitness added this to the 1.2.18 milestone Jul 1, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Sep 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Undesired behaviour resolved A fixed issue
Projects
None yet
Development

No branches or pull requests

3 participants