Repository navigation
Respect Graph Template Test Data Source in graph automation - #86
Merged
Merged
Conversation
Gate add_graphs.php invocations on test_data_sources() so a Graph Template with Test Data Source enabled is not graphed on devices (e.g. MikroTik) whose Host Resources MIB data source (Login Users, Processes) returns no valid data. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
The tests lack E2E coverage for all three data-source probe gates, leaving regressions undetected where failing probes create graphs or passing probes and disabled checks block creation.
1 open issue
What changed in this PR
This PR makes Host MIB graph automation honor Cacti’s per-template Test Data Source setting before creating graphs.
Changes:
- Adds data-source checks for Users/Processes templates, directly assigned templates, and indexed data-query graphs.
- Skips graph creation and emits a debug message when validation fails.
- Preserves existing behavior when data-source testing is disabled.
| File | Description |
|---|---|
poller_graphs.php |
Gates all three graph-creation paths on core test_data_sources(), including query and index arguments for data-query graphs. |
Review effort: Balanced
Load the real hmib_gt_graph()/hmib_dq_graphs() and exercise the skip branch of each gate (device, data query, and summary paths) so the per-test coverage run attributes them to poller_graphs.php. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
bmfmancini
approved these changes
Nov 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Summary
The Host MIB graph automation (
poller_graphs.php) created graphs by shelling out to Cacti'scli/add_graphs.php, which callscreate_complete_graph_from_template()directly and never tests the data source. As a result, the automation ignored the per–Graph Template "Test Data Source" setting (graph_templates.test_source) that Cacti's GUI graph creation honors viacreate_save_graph()→test_data_sources().In practice this created Login Users and Processes graphs on devices (for example MikroTik/RouterOS) that expose the Host Resources MIB but return no valid data for
hrSystemNumUsers/hrSystemProcesses.Fix
Gate every
add_graphs.phpinvocation on core'stest_data_sources(), mirroringcreate_save_graph():hmib_gt_graph()— the Users/Processes template pathadd_summary_graphs()hmib_dq_graphs()— data-query graphscggraphs usetest_data_sources($graph_template_id, $host_id);dsgraphs usetest_data_sources($graph_template_id, $host_id, $query_id, $snmp_index).When a template's "Test Data Source" is off (the default),
test_data_sources()returns true and behavior is unchanged. When it is on and the data source returns no valid data, the graph is skipped and a debug line is emitted.Testing
php -lclean.