Skip to content

Wireless registrations: show client signal and resolve client names via DNS - #145

Merged
TheWitness merged 9 commits into
developfrom
fix/wifi-reg-signal-dns
Nov 24, 2026
Merged

TheWitness merged 9 commits into
developfrom
fix/wifi-reg-signal-dns

Conversation

@TheWitness

@TheWitness TheWitness commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Problem

On RouterOS 7 the Wireless Registrations page showed most rows with an empty Signal to Noise column and several blank Client Names, even though /interface/wifi/registration-table/print on the device shows good data.

  1. Signal: For v7 devices the poller collects registrations through the RouterOS API (Support RouterOS 7.x (WifiWave2 wireless + mtxrGaugeTable health) alongside 6.x, and add a Health tab #135). WifiWave2 only reports signal (dBm), which was stored in Strength, but the page only rendered SignalToNoise, which the API path never sets. The few rows with an SNR value were stale SNMP-era rows (lowercase MAC index) that kept their old value.
  2. Client Name: The name came only from DHCP host-name via plugin_mikrotik_mac2hostname. Clients that send no host-name, and access-point clients whose router has no lease name, showed blank. The router's registration table exposes dhcp-hostname/dhcp-address, but access points do not, and neither was used. There was no DNS fallback.

Changes

  • UI: Replace the Signal to Noise column with Signal (dBm) (from Strength), which both RouterOS 7 (API) and pre-7 (SNMP) devices populate, so one column works for every device. SNR is still collected on pre-7 devices for graphs. Join mac2hostname through a per-MAC "newest name" subquery. That table's primary key is (mac_address, hostname), so a MAC with more than one cached name could otherwise duplicate registration rows.
  • API collector: Store dhcp-hostname (routers) in mac2hostname, and set SignalToNoise = NULL on upsert to clear stale SNMP values.
  • Name resolution: New mikrotik_resolve_wireless_client_names(), run after both the API and SNMP collectors. For present registrations with no cached name, it gets the IP from dhcp-address or any device's DHCP lease. It then takes the name from the collected DNS cache (plugin_mikrotik_dns A record), falling back to reverse DNS: Cacti's configured DNS servers via get_dns_from_ip() (with settings_dns_timeout), otherwise gethostbyaddr(). Results are cached with source = 1 via INSERT IGNORE.
  • mikrotik_clean_dns_name() normalizes lookup results and rejects the failure sentinels (ERROR, timed_out, echoed IP) and malformed names.
  • Schema 3.5: plugin_mikrotik_mac2hostname gains a source column (0 = DHCP, 1 = DNS), added on upgrade. The UI prefers DHCP names regardless of write order, and the DNS fallback is skipped until the column exists.
  • The fallback only uses a bound, enabled lease seen in the latest collection, and looks up DNS only on the device that supplied the address.
  • CHANGELOG and cacti.pot are updated.

Testing

  • New Pest unit tests for mikrotik_clean_dns_name().
  • Full plugin suite: 150 passed. The 8 ApiTlsTest failures are environmental: the same 8 fail on unmodified develop in the test environment (openssl cert generation).
  • Validated the UI subquery and resolver SQL against MySQL with seeded rows, including the lowercase SNMP index matching an uppercase DHCP MAC.
  • tests/bin/check-i18n-pot.php passes.

Reviewer notes

  • RouterOS 7 does not expose per-client SNR (or a noise floor outside a disruptive /interface/wifi/scan), so the page no longer shows SNR. The SignalToNoise column and data query field are unchanged for pre-7 graphs.
  • Unresolvable clients are retried each registration poll; each lookup is bounded by the Cacti DNS timeout when DNS servers are configured.

Settings changes (follow-up)

  • New Wireless Registration Retention setting after Address List Retention, with the same choices and 4-week default. Registrations not seen for longer than that are pruned alongside the DHCP/DNS/Address List history (prune_wireless_registrations()). It also removes the Graphs and Data Sources created for them, matched by device, MAC snmp_index and the wireless registration graph templates.
  • Renamed the "DHCP/DNS/List Settings" section to Data Retention. Dropped the redundant "MikroTik" prefix from General Settings, Poller Enabled, API Polling Enabled and the Device, Queue/Tree and Wireless Collection Frequencies sections. Dropped "Wireless" from the four frequency options under the Wireless section.
  • The repetitive settings entries are now built with mikrotik_drop_setting(), mikrotik_checkbox_setting() and mikrotik_spacer_setting(), which cleared the SonarCloud duplication gate. The generated $settings array was verified identical to before.

RouterOS 7 (WifiWave2) reports only the client signal, not
signal-to-noise, so the Wireless Registrations Signal to Noise column
was empty. Show the collected signal (dBm) and clear stale SNMP-era SNR
values on API-polled rows.

Client names came only from DHCP host-names. Use the router's
registration-table dhcp-hostname when present and otherwise resolve the
client's IP (dhcp-address or any device's DHCP lease) through the
collected DNS cache, then reverse DNS, caching the result so access
point clients and clients without a host-name are named. Show only the
newest name per MAC so multiple cached names do not duplicate rows.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 23, 2026 19:55
RouterOS 7 never reports SNR and pre-7 SNMP devices also populate Strength, so a single signal column works for every device. SNR is still collected on pre-7 devices for graphs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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

Hostname resolution can cache another device’s name from cross-router DNS records or stale, inactive leases, while concurrent cache writes can incorrectly prioritize DNS names over DHCP names.

3 open issues
What changed in this PR

Improves wireless registration visibility in the Cacti MikroTik plugin, adding RouterOS 7 signal display and client-name resolution while retaining RouterOS 6 signal-to-noise support.

Changes:

  • Displays signal strength and selects one cached client name per MAC.
  • Collects registration-provided names, adds DNS fallback, and clears stale API-row signal-to-noise values.
  • Adds hostname-normalization tests and updates translations and release notes.
File Description
tests/​Unit/​PollerParsingTest.php Tests DNS-name normalization and rejection of unusable results.
poller_mikrotik.php Adds client-name collection and DNS resolution; clears stale signal-to-noise data.
mikrotik.php Displays signal strength and selects the newest cached name per MAC.
locales/​po/​cacti.pot Adds the translatable signal-strength column label.
CHANGELOG.md Documents signal display and client-name resolution changes.

Review effort: Balanced

Comment thread poller_mikrotik.php Resolved
Comment thread poller_mikrotik.php Resolved
Comment thread poller_mikrotik.php Resolved
TheWitness and others added 7 commits November 23, 2026 15:08
Address review feedback on the client-name fallback:

- Only resolve addresses from a bound, enabled DHCP lease seen in the
  latest collection, so a stale or reassigned lease cannot attach another
  client's name to the MAC.
- Look up the DNS cache on the device that supplied the address (the
  polled device for dhcp-address, the lease's device otherwise), so
  overlapping networks cannot cross-assign names.
- Record DNS-derived names with a new mac2hostname source column and
  prefer DHCP names in the UI regardless of write order (schema 3.5).
- Mark the eval-loaded mikrotik_clean_dns_name() helper as coverage
  ignored, matching the other isolated poller helpers, to satisfy the
  changed-lines coverage gate.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Prune wireless registrations not seen for longer than the new
'Wireless Registration Retention' setting (same choices and default as
the other retention settings) alongside the DHCP/DNS/Address List
pruning, and remove the Graphs and Data Sources created for them.

Rename the 'DHCP/DNS/List Settings' section to 'Data Retention' and drop
the redundant 'MikroTik' prefix from the settings tab section and option
labels.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
checkHost() is not exercised by the unit suite; mark the new call like the neighbouring RouterOS 7 wireless block.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ings

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The fifteen drop-down entries differed only in label, description,
option list and default; generate them with mikrotik_drop_setting() to
remove the duplication flagged by SonarCloud. The resulting settings
array is unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The settings hook can run before config_arrays has populated the option lists; pass them through unchanged as before.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Generate the repeated section headings and checkbox entries with
mikrotik_spacer_setting() and mikrotik_checkbox_setting(), clearing the
remaining SonarCloud duplication on the MikroTik settings tab. The
resulting settings array is unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sonarqubecloud

Copy link
Copy Markdown

@TheWitness
TheWitness merged commit 3331493 into develop Nov 24, 2026
7 checks passed
@TheWitness
TheWitness deleted the fix/wifi-reg-signal-dns branch November 24, 2026 14:41
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.

3 participants