137 Commits
Author SHA1 Message Date
TheWitness 9da2bc9967 bug: pass bool (not int) to api_plugin_register_hook() $enable (#852)
* bug: pass bool (not int) to api_plugin_register_hook() enable argument

Cacti 1.3 types api_plugin_register_hook() 5th arg as bool enable. These calls passed int 1, which only coerces while the file lacks declare(strict_types=1); pass true so they stay type-correct. php -l clean.

* Exclude live-DB reinstall body of plugin_thold_install() from coverage

* bug: pass bool true (not string '1') at remaining register-hook upgrade sites

Convert the 17 other api_plugin_register_hook() 5th arguments in includes/database.php from the string '1' to boolean true so the upgrade/re-registration paths are strict_types-safe against Cacti develop's bool \ signature.
2026-10-08 15:21:20 -04:00
TheWitnessandCopilot 9b217e0e3a INFO: set compat to 1.2.29 (#838)
* INFO: set compat to 1.2.32

* docs: update Copilot instructions Cacti baseline to 1.2.32 (matches INFO compat)

* INFO: back off compat to 1.2.29

* Add manifest.json + upgrade-time file pruning

* Prune phpunit.xml on upgrade and ignore markdown-lint configs

phpunit.xml ships in the repo for CI but is a dev-only test artifact, so it
is removed from manifest.json 'expected', pruned from installs on upgrade
(like tests/), and excluded from the manifest drift check.

The retired markdown-lint configs (.mdlrc, .md_style.rb) are deleted, and
.md* is now ignored like .git*: protected from pruning and excluded from
drift if it reappears.

* Move thold_functions.php and thold_webapi.php into includes/; flatten css

The main threshold library becomes includes/functions.php and the web API
helper becomes includes/webapi.php; every caller (setup.php, includes/*, the
CLI/poller/notify entry points and the test suite) loads them from includes/.
Each per-theme stylesheet css/<theme>/main.css becomes css/<theme>.css so users
can drop their own css/<theme>.css into the css base, and the page_head hook
looks there. Old paths are tombstoned so existing installs drop the stale
copies on upgrade.

* Regenerate cacti.pot for the includes/ file relocations

Moving the plugin's library files into includes/ changed the source-reference
lines in the translation template; regenerate it so the 'Verify translation
template' CI check passes.

* Harden the hook-include test and make RPN integer ops explicit

The HookFunctionsIncludeTest invokes real hooks with placeholder input purely
to execute their relocated include_once lines; it now swallows engine
notices/warnings/deprecations during those calls (and restores the error
handler and config afterward) so it cannot trip the suite's failOnDeprecation
or leak state into other tests. The RPN % and ^ operators now cast their
operands to int explicitly, matching their long-standing integer-truncation
behaviour while silencing the implicit float-to-int conversion deprecation.

* Harden prune against tampered-manifest path traversal

The upgrade-time prune now rejects any tombstone containing '.'/'..' segments
(which could escape the plugin directory or resolve to its root) and treats
ancestors of whitelist entries as protected, so a tombstone on a parent
directory can no longer delete a whitelisted file beneath it.

* docs: update and align the Project Structure block

Point the structure tree at the relocated files (libraries now under
includes/, data files under docs/, stylesheets under css/) and align the
trailing '# ...' comments to a single column so they no longer drift right.

* docs/tests: standardize test header and correct manifest-contract notes

- Use the full license header (from the plugin's own setup.php) in
  tests/Unit/PruneFilesTest.php instead of the abbreviated copyright banner.
- Document that the manifest drift check and the upgrade-time prune also
  handle phpunit.xml and .md* files, matching the implemented behavior.

* refactor: rename prune helpers to the plugin-slug function prefix

The repository naming contract reserves the plugin_<name>_ prefix for plugin
lifecycle / hook-registration functions; all other functions use the plain
<name>_ prefix. Rename the internal upgrade helpers accordingly:

  plugin_<name>_prune_files() -> <name>_prune_files()
  plugin_<name>_rmtree()      -> <name>_rmtree()

The call site, unit tests, and the copilot-instructions.md references are
updated to match. No behavioral change.

* chore: set the Cacti compatibility floor to 1.2.29

Align the compat metadata (and the contributor-guide references) with the
team decision to standardize the minimum supported Cacti version at 1.2.29;
the previously proposed 1.2.32 floor was not adopted.

---------

Co-authored-by: Copilot <copilot@users.noreply.github.com>
2026-10-01 01:40:00 -05:00
TheWitness 41dc700357 Add PHPDoc blocks to undocumented functions (partial - thold_functions.php follow-up owed) (#828)
* Add PHPDoc blocks: small files batch (cli_import, poller_thold, includes/tab, includes/database, cli_thresholds, thold_notify, notify_queue)

* Add PHPDoc blocks: includes/polling.php, includes/settings.php (WIP checkpoint)

* Add PHPDoc blocks: thold_process.php, thold_daemon.php (WIP checkpoint)

* Add PHPDoc blocks: thold_webapi.php (WIP checkpoint)

* Add PHPDoc blocks: thold.php (WIP checkpoint)

* Add PHPDoc blocks: thold_graph.php (WIP checkpoint)

* Add PHPDoc blocks: notify_lists.php (WIP checkpoint)

* Add PHPDoc blocks: thold_templates.php (WIP checkpoint)

* Add PHPDoc blocks: setup.php batch 1-2 (WIP checkpoint)

* Add PHPDoc blocks: setup.php batch 3-4 (WIP checkpoint)

* Add PHPDoc blocks: setup.php batch 5 (WIP checkpoint)

* Add PHPDoc blocks: setup.php batch 6-7 (WIP checkpoint)

* Add PHPDoc blocks: setup.php complete

* Address review feedback and refresh translation template

- Fix thold_update_host_status() return type (int|null, since it
  falls through with no explicit return in the normal case)
- Fix @global $device_change_fields description in
  thold_config_arrays() (appends this plugin's fields, not unused)
- Fix @global $config description in thold_graph_button() (used to
  build the Create Threshold link's URL)
- Fix thold_data_source_action_prepare()/thold_graphs_action_prepare()
  return types (array|void; only the non-plugin_thold_create branch
  returns $save)
- Fix @global $timearray description in list_tholds() (used to render
  each baseline threshold's reference time range)
- Fix @global $thold_types description in thold_show_log() (used to
  render each log row's type column)
- Regenerate locales/po/cacti.pot (source line references only)
- Fix .gitignore pattern for compiled .mo files (locales/LC_MESSAGES/, not locales/po/)

* test(coverage): allowlist untestable entry points touched by PHPDoc pass

This PR only adds PHPDoc blocks (no functional changes), but touching every file in the plugin newly triggers the 'Enforce coverage of changed lines' CI gate for files that were never require()'d by any test before now:

- cli_import.php, cli_thresholds.php: CLI entry points (include cli_check.php / chdir + execute at the top level).

- poller_thold.php: poller entry point, same category.

- thold.php, thold_graph.php, thold_templates.php, notify_lists.php: authenticated web entry points (chdir + include(auth.php) at the top level), like notify_queue.php/thold_notify.php already allowlisted above.

- thold_daemon.php: daemon entry point, same category as thold_process.php already allowlisted above.

- includes/settings.php, includes/tab.php: Settings-page/header-tab-bar hook callbacks, only meaningful inside a live Cacti page render.

- thold_webapi.php: web-page action handlers that read \ and the database directly.

None of these can be require()'d into the isolated unit test process, matching the existing allowlist entries' precedent exactly. Verified locally: running patch-coverage.php against the PR's actual base ref confirms all 11 files are no longer reported as unexpected-unmeasured.

* docs: add PHPDoc blocks to remaining thold_functions.php functions

* chore: refresh translation template after PHPDoc line-number shifts
2026-09-25 12:30:04 -04:00
Thomas Vincent 860be297c1 fix(notify): recover unfinished queue claims (#813)
* fix: recover unfinished notification claims

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* test: cover notification claim recovery branches

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* fix: harden notification worker recovery

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* fix: heartbeat notification queue loops

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* fix: fail closed on notification worker recovery

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* fix: bound notification worker recovery

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* style: format notification CLI validation

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* fix: prove notification claim ownership at completion

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* fix: bound notification completion failures

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* fix: recover unverifiable stale workers

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* test: keep disabled exec path measurable

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* fix: verify stale worker age without wall clocks

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* fix: fail closed on unverifiable live workers

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* test: cover portable process age fallback

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* test: reject invalid process age output

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* Retry failed queued email notifications (#811)

* Retry failed queued email notifications

* test: cover queued delivery retry paths

* style: document notification fixture parameters

* fix: batch grouped notification delivery updates

* fix: align notification retry status output

* refactor: centralize notification retry updates

* fix: retain retry queue ownership

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

---------

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
2026-09-19 21:07:29 -04:00
TheWitness 0f526404f7 Updating copyrights to 2026 (#740) 2026-02-14 14:16:33 -05:00
TheWitnessandCopilot 2d3b623d7a Updating workflow to include code validation PHP8.4 and MariaDB 10.6 (#739)
* Adding Worflows for code validation

* Apply php-cs-fixer rules

* Apply suggestion from @Copilot

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

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-06 06:59:30 -05:00
TheWitness a7991dc6cf QA: Update Copyrights to 2025 2025-06-16 09:26:09 -04:00
TheWitness 99f57500c7 Fix: #714 - Increase name value to 255 characters 2025-06-08 09:40:28 -04:00
Sean Mancini 3ba6f292b4 Ensure show_units column is added (#716)
In version 1.5 of thold there was a Bug where some columns were missed during install  the upgrade script looked for a thold version of less than 1.5 to add the columns
2025-03-20 07:21:01 -04:00
TheWitness 48446bdf20 QA: Allow the thold plugin to use the new registration function 2024-11-03 11:48:01 -05:00
Petr Macek f0320f3d15 missing thread_id (#698) 2024-09-25 14:27:48 -04:00
TheWitness 59b964d545 QA: Fixing Inconsistencies with template_enabled flag 2024-04-15 10:06:48 -04:00
TheWitness 5bc909d372 QA: Fixing issues related to Cacti 1.3 Integration 2024-04-05 17:35:49 -04:00
TheWitness 4b14a89172 Allow Templates and Thresholds to have an External ID
feature: Allow Templates and Thresholds to include an External ID
2024-01-30 20:22:37 -05:00
Linegod 1520ee1868 typos 2023-12-05 23:07:22 -06:00
Petr Macek e5775b1a32 Fix 621 and 635 (#640)
* add missing column

* fixing first fix

* add missing indexes
2023-11-13 06:08:24 -08:00
Petr Macek 45c2e6936d add missing column (#639)
* add missing column

* fixing first fix
2023-11-13 03:41:09 -08:00
TheWitness 2ca8a0083c Fixing #635 and notification delay
* Problem with non-templated tholds
* This notification delay change is not final.
* Users running the 1.8 Alpha will have to re-upgrade their databases
2023-11-11 15:14:16 -05:00
TheWitness d23b7af454 QA: Add one more column for notification delay 2023-10-08 12:46:03 -04:00
TheWitness db10e243d3 QA: Add columns for Notification Delay 2023-10-07 11:56:46 -04:00
TheWitness 1df3786a6b Starting to rough in notification delay
* This is not all the feature, just saving the work.
* It's going to take a few commits to completely implement this feature
* This version adds a new column to notifification_queue
* It adds a % at Site in addition to raw number of devices in a site
* It starts the logic of expiration of notification delays
* ToDo: Custom Email and Command notification based upon restoration or expiration
* ToDo: Adding new Notification delays to the list of existing notifications.
2023-08-15 20:05:59 -04:00
Jing Chen 938aa89ed8 Hack fix for name/name_cache length for v0.4.4 and v1.2 (#605) 2023-08-10 05:35:55 -04:00
TheWitness f4f30f80b3 Fixing #135 - Customized Email Subjects
- Ability to change the subject for the threshold alert message
- Rearranged a bit of the forms here as well for readability.
2023-08-05 13:14:49 -04:00
TheWitness 063bb35aa0 Fixing #601 and Adding 5 More Baseline Types 2023-08-04 11:20:13 -04:00
TheWitness d53222e82c QA: Tune Notification Delay
These changes simply make the settings delay a Cacti styled Multi-Select.
2023-07-30 10:00:24 -04:00
TheWitness 0ed9fe730f QA: Increase column width and minor notification issues 2023-07-28 19:44:59 -04:00
TheWitness c6501c1911 Starting #590 - Just the settings with some outstanding issues
Found that there is no good way to hook the settings page without a global JavaScript file.  Really need a hook at the bottom of the settings page.
2023-07-27 21:48:06 -04:00
TheWitness dc83bde317 Allow specification of units suffix and decimal digits
* feature: Allow the specification of the units suffix overriding automatic the number of significant digits to display
2023-07-27 09:10:00 -04:00
Sean Manciniandseanmancini fae05a418d Fix for 596 (#600)
* Update thold_functions.php

fix for #597

* Update thold_functions.php

* Add missing Enabled field

---------

Co-authored-by: seanmancini <sean.mancini@rci.rogers.com>
2023-07-26 10:54:01 -04:00
Petr Macek 0a29043cbf sql errors during the install plugin (#594) 2023-07-26 08:36:36 -04:00
Sean Mancini ecb2eb3877 Update database.php (#592)
Add missing ,
2023-07-25 13:34:31 -04:00
TheWitness 72050a81e9 feature: Allow specification of timespan for threshold or template
* feature: Allow the specification of the Graph Timespan when editing/creating the Threshold or Template
2023-07-25 09:37:44 -04:00
TheWitness c31bd71f0a Feature: Support Format Files in Thold
Another long sought after feature request now addressed.
2023-07-24 23:45:31 -04:00
TheWitness 3e0f7a18a8 2 Features around Enabling and Disabling Tholds and Templates
* feature: Mass Enable/Disable at Template Level
* feature: Make Enabling and Disabling a Thold Different than Enabling or Disabling a Template
* QA: Cleanup some of the state calculation logic to make similar between pages.
2023-07-24 22:24:41 -04:00
TheWitness e8cb979cb2 Allow disabling a notification list through the UI
This is one part of Feature Request #31
2023-07-24 20:40:26 -04:00
TheWitness ae6639c72e QA: Issue #453 - Rename a column , add two more
- Anyone testing the Notification Queue will have to recreate the table as I'm dropping the intermediary upgrade logic.
2023-07-24 19:00:44 -04:00
Petr Macek 16cd1e7ec5 missing apostrophes (#589) 2023-07-24 14:37:46 -04:00
TheWitness 62c9656213 Add object_name, notification_list_id, event_processed_time
This will make it possible to group Email notifications, though maybe not so elegantly.
2023-07-24 13:36:13 -04:00
TheWitness 7bffd503dc Make the type a bit wider, add 'object_id'. 2023-07-23 13:32:30 -04:00
TheWitness e9742a0a6d More updates for #435
* Drop environment column, it can be in the data space
* Add thold command execution to notification_queue
* Add device command execution to notification_queue
2023-07-22 22:22:46 -04:00
TheWitness 7898c57fb4 Minor table change for #435
This adds the parallel processing columns  and columns for command execution type notications.
2023-07-22 21:24:04 -04:00
TheWitness 21c921b888 Issue #435 - Notification Queue Implementation
This is the beginning of the notification queue.
It is not complete yet as the daemon and data collector must still be written.
Then the command line executor will have to be written as well.

Columns that have yet to be added include: environment, and process_id

It's likely that I will change the schema ever so slightly before I'm done as well.
2023-07-22 21:18:19 -04:00
TheWitness a028fbc6e3 Feature #185, Issue #586 - Multiple issues and features
* feature: Allow quick links to the Threshold Template when editing a Thold
* feature#185: Baseline deviation with exact changes
* issue#586: Attempting to edit a non-existing thold template results in plugin being disabled
2023-07-22 18:18:00 -04:00
TheWitness 6ac9141cfb Do the first insert in bulk 2023-07-22 16:07:16 -04:00
TheWitness 9a05ed6fc0 Fixing #445 More selective auto-create
Allow removal of Threshold from a specifc device ignoring device template
2023-07-22 16:03:20 -04:00
TheWitness dd0f9cf5fc Minor QA on #486
Wrong table updated twice.
2023-07-22 13:29:06 -04:00
TheWitness fe2053079f Fixing #486 - Add Skipscale to HRules
add ":skipscale" option to prevent diagram area from being scaled by threshold lines, thus losing granularity in the graphs
2023-07-22 13:25:22 -04:00
TheWitness 8f681a7273 QA: Remove all references to plugin_thold_daemon_processes table 2023-07-22 12:29:42 -04:00
TheWitness bedaa20992 Introduce BCC to Notification Lists #528
* feature#528: Allow Thold to Use the BCC in addition to the TO line for Notification Lists
* INFO file to 1.8 is only temporary.  This will not be released.
2023-07-22 11:40:20 -04:00
netniV 4d9210e76b Update copyright for 2023 2023-01-04 22:31:06 +00:00