Skip to content

Feature/collection health - #99

Merged
TheWitness merged 8 commits into
Cacti:developfrom
bmfmancini:feature/collection-health
Dec 1, 2026
Merged

TheWitness merged 8 commits into
Cacti:developfrom
bmfmancini:feature/collection-health

Conversation

@bmfmancini

Copy link
Copy Markdown
Member

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

  • Added a "Collection" column to the Devices tab, showing the status of the latest Host MIB data collection for each device, with tooltips and links to the Device Dashboard. [1] [2] [3] [4]
  • Introduced a "Poll Now" feature on the Device Dashboard, allowing users with the Host MIB Admin realm to manually collect all Host MIB tables for a device immediately, with real-time card refresh and per-device locking to prevent concurrent collections. [1] [2]
  • Collection outcomes (OK, No Data, Failed, last success) are now recorded for every collector and device, displayed in the new Collection Health card, and explained on relevant lists (Processes, Storage, Hardware, Inventory) when empty. [1] [2] [3] [4]

Documentation and Example Updates

  • Expanded the README with detailed sections on collection health, manual polling, and especially on configuring the SNMP agent to ensure the Host Resources MIB is fully exposed; added an examples/snmpd.conf.example file with best-practice configurations for SNMPv2c and SNMPv3. [1] [2] [3] [4] [5] [6] [7]
  • Added a redirecting examples/index.php for convenience and copyright.

Styling and UI Enhancements

  • Added new CSS for collection health banners, Collection Health card explanations, and the Poll Now button/status, using theme-aware severity colors for better visibility and accessibility.

Changelog and Internal Improvements

  • Updated CHANGELOG.md to reflect all new features, bug fixes, and developer documentation improvements.
  • Improved empty state handling in lists to include collection health explanations, using a new helper function. [1] [2] [3] [4]

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.

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'].
Copilot AI balanced review requested due to automatic review settings December 1, 2026 03:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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
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

Comment thread hmib.php Resolved
Comment thread examples/snmpd.conf.example Resolved
Comment thread hmib.php Resolved
Comment thread hmib.php Resolved
Comment thread hmib.php Resolved
Comment thread js/hmib_dashboard.js Resolved
Comment thread poller_hmib.php Resolved

@somethingwithproof somethingwithproof left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Blockers.

  • checkHost() adds the full hmib_hrSWRunPerf_freq to process total_time on 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 preserve last_seen on manual refreshes and cover two consecutive polls without double-counting elapsed time.
  • hmib_dashboard_poll_status() treats an unlocked host and a recent hrSystem.last_attempt as completion. A worker that exits after hrSystem but 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 corrected view systemonly included .1.3.6.1.2.1.25 directive from #98. This branch still ships ok as 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 somethingwithproof left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

  1. 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 writes ok and advances last_success. I exercised the actual collector with those two responses and it recorded hrSystem, 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.

  2. Blocker. hmib.php calls hmib_get_collection_summaries() for the Devices tab after fetching the requested page. The helper reads every row in plugin_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.

bmfmancini and others added 3 commits December 1, 2026 08:17
…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>
@sonarqubecloud

sonarqubecloud Bot commented Dec 1, 2026

Copy link
Copy Markdown

@TheWitness
TheWitness merged commit 3a63c59 into Cacti:develop Dec 1, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants