Repository navigation
Feature/collection health - #99
Conversation
Collection health: the poller records the outcome of every collector for every Device in plugin_hmib_collector_status (OK with a row count, No Data, or Failed with the SNMP error, plus the last success). It shows as a Collection column on the Devices tab, a notice and a Collection Health card on the Device Dashboard, and the reason on the Processes, Storage, Hardware and Inventory lists when they are filtered to one Device and empty. An agent whose SNMP view hides part of the Host Resources MIB no longer looks like a Device with nothing to report. Poll Now: users with the Host MIB Admin realm can collect every table of the Dashboard's Device at once. It runs poller_hmib.php --host-id=N --force --manual in the background; --manual also updates the Device's CPU, memory and OS type figures, now in hmib_update_summaries(). A per-Device lock keeps a manual and a scheduled collection of the same Device from running together, and the collection schedule is unchanged. Also: - Saved Dashboard layouts record the cards the user has seen, so new cards are added once and removed ones stay removed. - The Device picker on the Dashboard shows the Device's name, not its id. - The hrSWRunPerf collector is no longer named 'hrSWRunPref'. - The unit-test stub of get_nfilter_request_var() reads $GLOBALS['__test_request'].
There was a problem hiding this comment.
🟡 Changes recommended
The missing translation-template update blocks CI, while unresolved Poll Now bugs can falsely report completion and inflate process use time.
7 open issues
Update cacti.pot for new translatable strings · New Replace invalid SNMP option with a view directive · New Reuse batched collector statuses for tooltips · New Avoid scheduled-interval accounting for manual polls · New Track Poll Now completion with a unique run token · New Refresh the collection-health banner after polling · New Record success only after both system walks succeed · New
What changed in this PR
This PR adds collection-health visibility and on-demand polling to the Host MIB plugin, helping users distinguish empty device data from failed or restricted SNMP collection.
Changes:
- Records collector outcomes and displays status, troubleshooting explanations, and a Collection Health dashboard card.
- Adds permission-controlled Poll Now with per-device locking, summary updates, and card refresh.
- Expands SNMP configuration guidance, adds regression tests, and fixes device-picker labels and empty Graphs filters.
| File | Description |
|---|---|
tests/Unit/PollNowTest.php |
Tests manual-poll endpoints and device-scoped summary updates. |
tests/Unit/PollerHmibIndexedOidTest.php |
Tests failed, empty, and successful collector outcomes. |
tests/Unit/HmibSetupTableTest.php |
Checks creation of the collector-status table. |
tests/Unit/HmibLifecycleTest.php |
Checks removal of the new table during uninstall. |
tests/Unit/CollectionHealthTest.php |
Tests health summaries, explanations, and status persistence. |
tests/bootstrap-unit.php |
Supports configurable request values in tests. |
setup.php |
Integrates health helpers and table lifecycle handling. |
README.md |
Documents collection health, manual polling, and SNMP configuration. |
poller_hmib.php |
Records outcomes, locks device collection, and updates manual-poll summaries. |
manifest.json |
Registers the new examples directory. |
js/hmib_dashboard.js |
Starts manual polls, tracks progress, and refreshes cards. |
includes/health.php |
Adds status storage, summaries, and explanatory helpers. |
includes/database.php |
Creates the collector-status table during installation. |
hmib.php |
Adds health displays and polling endpoints; fixes picker labels and empty graph filters. |
examples/snmpd.conf.example |
Provides Host Resources MIB configuration examples. |
examples/index.php |
Adds a directory redirect. |
css/hmib.css |
Styles collection-health notices and polling controls. |
CHANGELOG.md |
Records features, fixes, and documentation additions. |
Review effort: Balanced
somethingwithproof
left a comment
There was a problem hiding this comment.
Blockers.
checkHost()adds the fullhmib_hrSWRunPerf_freqto processtotal_timeon each forced manual poll. In a focused worker fixture, two manual polls one second apart each passed 300 seconds to the Use History update. Please preservelast_seenon manual refreshes and cover two consecutive polls without double-counting elapsed time.hmib_dashboard_poll_status()treats an unlocked host and a recenthrSystem.last_attemptas completion. A worker that exits afterhrSystembut before the remaining collectors or summary updates still satisfies both checks. Please track the outcome of the requested run and report success only after it finishes.- The translation check fails locally on the new dashboard strings. Please regenerate
locales/po/cacti.pot. Also bring over the correctedview systemonly included .1.3.6.1.2.1.25directive from #98. This branch still shipsokas the active line in Option 1.
- Track each Poll Now as its own run: the Dashboard passes a token to the worker, which marks the run running once it holds the Device lock, busy when another collection holds it, and done only after collecting and updating the summaries. The status check reports done only for that run, and a worker that stopped part way or never started as an error. The main run prunes runs a closed Dashboard left behind. - A Poll Now refreshes the Use History last_seen of running processes without adding the scheduled performance interval, so repeated clicks no longer add use time. - Record the hrSystem outcome after both the Host Resources and the MIB-II system walks; either one failing records a failure and keeps the last success time. A system walk that returned rows but failed part way reads as Incomplete, not Failing, as the other collectors still ran. - Keep the collector rows read for the Devices tab summaries, so the Collection tooltips need no query per Device. - Reload the Dashboard when a Poll Now finishes, so the collection notice above the cards is current too. - Use the view directive in Option 1 of examples/snmpd.conf.example. - Regenerate locales/po/cacti.pot.
E2E: the Dashboard notice and card state for a partial collection, the reason on an empty process list, the Devices tab and Dashboard before the poller has created the status table, a card released since a layout was saved, the Poll Now endpoints, and the poller's help text. Unit: the summary labels, the explanation for a collector that has not run, the SNMP error text of a failed request, and the batched CPU figure writes of hmib_update_summaries(). Add plugin_hmib_collector_status to the tables the tests snapshot.
…tests The patch coverage gate failed because examples/index.php was never executed. Request it through the E2E server and check the redirect. Add a Graphs tab regression test: start a session with no Host MIB device, check the page renders without an SQL error, then add the first device and check the same session offers its graph template.
somethingwithproof
left a comment
There was a problem hiding this comment.
The manual-poll accounting, per-run completion tracking, translations, and SNMP view example now address the previous review. The full local unit suite passed all 112 tests. Two additional cases need changes before merge.
-
Blocker.
poller_hmib.php,collect_hrSystem(). When the Host Resources system walk returns a row and the MIB-II system walk returns an empty array with no SNMP error, the collector writesokand advanceslast_success. I exercised the actual collector with those two responses and it recordedhrSystem, ok, 1. An operator sees a fresh success even though the MIB-II fields still contain the previous values. Please record this as an incomplete collection, preserve the previous success timestamp, and keep the other collectors running. A regression covering a successful run followed by this partial response would pin down both the status and timestamp. -
Blocker.
hmib.phpcallshmib_get_collection_summaries()for the Devices tab after fetching the requested page. The helper reads every row inplugin_hmib_collector_status, even when the page is empty. In a local PHP 8.5/SQLite fixture with 10,000 devices and seven collectors each, the helper fetched 70,000 rows and added 44 MiB to peak PHP allocation. Please batch the distinct host IDs from the displayed page in one bound query, skip the query for an empty page, and keep reusing the fetched rows for tooltips. A test with an off-page device would guard against reintroducing the full-table read.
…ted Devices' statuses collect_hrSystem() recorded ok and moved last_success forward when the Host Resources system walk answered but the MIB-II system walk came back empty without an SNMP error, so the stale MIB-II fields looked freshly collected. That case is now recorded as failed with the rows it got, keeping the previous success time; the other collectors still run. hmib_get_collection_summaries() read every row of the collector status table for the Devices tab. It now takes the host ids of the displayed page, reads their rows in one bound query, skips the query for an empty page, and still keeps the rows for the tooltips. Tests: a MariaDB regression running the real collector for a successful collection followed by the partial one, and unit tests for the batched read, an off-page Device and an empty page. The unit bootstrap gains a db_qstr() stub and can define a cut-out function under another name, since another test file replaces collect_hrSystem() with a recorder.
Cacti#98 landed the same snmpd example, Graphs tab fix and tests this branch already carries. CHANGELOG.md and README.md keep this branch's wording, which describes Poll Now and --manual.
Resolve the CHANGELOG.md conflict by keeping both the collection-health entries and the js/cards.js sync entry from Cacti#100. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|





This pull request introduces several major features and improvements to the Host MIB plugin, focusing on enhanced device collection visibility, manual polling, and improved documentation for SNMP agent configuration. The most significant changes are grouped below by theme.
New Features and User Experience Improvements
Documentation and Example Updates
examples/snmpd.conf.examplefile with best-practice configurations for SNMPv2c and SNMPv3. [1] [2] [3] [4] [5] [6] [7]examples/index.phpfor convenience and copyright.Styling and UI Enhancements
Changelog and Internal Improvements
CHANGELOG.mdto reflect all new features, bug fixes, and developer documentation improvements.These changes collectively provide more actionable information to users, make troubleshooting easier, and ensure the plugin is easier to set up and maintain in a variety of SNMP environments.