86 Commits
Author SHA1 Message Date
Thomas Vincent 36190b211c fix: bind SQL values in setup.php as prepared statements (#282)
Closes #207

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
2026-10-24 09:48:11 -04:00
TheWitness 353766eba5 bug: pass bool (not int) to api_plugin_register_hook() enable argument (#271)
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.
2026-10-08 15:00:36 -04:00
TheWitness 0409ecb532 Fix select2 change recursion from double-wired Criticality device filter (#270)
* Fix select2 change recursion from double-wired Criticality device filter

Gate the client-side Criticality filter injection on whether core already rendered the field (device_filters/CactiTableFilter) instead of a CACTI_VERSION string. When core renders it natively the handler now bails, avoiding the second widget/handler that drove the select2 change -> selection:update recursion. Legacy releases still inject once, matching core's widget engine and binding a single namespaced change handler.

* test: cover monitor_device_table_bottom() filter injection

Exercise the device_table_bottom hook that injects the legacy Criticality filter, locking in the select2 change-recursion fix: the bail guard when core already rendered the field, a single namespaced change.monitor handler, a single widget engine (never both), theme gating, and the selected-option build. Covers the previously untested changed lines (setup.php patch-coverage gate).
2026-10-08 14:58:19 -04:00
TheWitnessandCopilot 66358e0998 Adopt plugin table API and relocate schema to includes/database.php (#254)
* Relocate schema to includes/database.php via plugin table API + db_update_table upgrade

* CI: allowlist unmeasured schema bootstrap and web entry points

* CI: keep include_once for the settings-page-only lib/reports.php load (uncoverable)

* Add manifest.json + upgrade-time file pruning; consolidate themes/ into css/

* database: keep user-owned dashboards table across uninstall

api_plugin_db_table_create() records plugin_monitor_dashboards in
plugin_db_changes, so api_plugin_db_changes_remove() (run by
api_plugin_uninstall() after plugin_monitor_uninstall()) would drop it
even though monitor_drop_tables() intentionally leaves it in place. Remove
the 'create' ownership record after provisioning (install and upgrade
paths) so user dashboards survive an uninstall. Adds a regression test.

* 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 libraries into includes/, flatten css, drop sonar config

db_functions.php, monitor_render.php and monitor_controller.php move into
includes/ (the latter two lose the monitor_ prefix, becoming render.php and
controller.php); monitor.php and the tests load them from there. Each per-theme
stylesheet css/<theme>/monitor.css becomes css/<theme>.css so users can drop
their own css/<theme>.css into the css base, and plugin_monitor_page_head()
looks there, falling back to css/monitor.css. The unreferenced
sonar-project.properties is removed. Old paths are tombstoned so existing
installs drop the stale copies on upgrade.

* Rename includes/db_functions.php to includes/functions.php

Follows the fleet convention for the plugin's shared library filename; monitor.php,
the measured-source list and the unit test load it from the new name.

* 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 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.

* Bump plugin version to 3.0 so the upgrade-time cleanup migration runs

Add a 3.0 CHANGELOG section for this cycle's schema/manifest work and set
INFO version = 3.0 so existing 2.9 installs detect the version change and
run the schema refresh and manifest-based file prune.

---------

Co-authored-by: Copilot <copilot@users.noreply.github.com>
2026-10-01 01:39:53 -05:00
TheWitness 8f961badb7 security(csp): version-safe inline-script nonce wrapper + strengthen PO/MO instructions (#249)
* security(csp): add version-safe inline-script nonce wrapper; strengthen PO/MO instructions

* test(csp): exercise nonce delegation in isolated process
2026-09-28 08:49:50 -04:00
TheWitness 86480ea85c Add PHPDoc blocks to all functions in setup.php (#248)
* Add PHPDoc blocks to all functions in setup.php

This plugin's other PHP files (db_functions.php, monitor_controller.php,
monitor_render.php, poller_functions.php) already have complete PHPDoc
coverage from prior work. This adds PHPDoc blocks (description,
@param, @return, and applicable @global tags) to the 25 functions in
setup.php, the one file that had none.

No functional changes; documentation only. Validated with php -l.

* Address review feedback and refresh translation template

- Correct plugin_monitor_uninstall() docblock to list the three tables it actually drops
- Fix @global type/usage for $page_refresh_interval in monitor_config_settings()
- Fix @return type for monitor_top_graph_refresh() (int|string, not int)
- Regenerate locales/po/cacti.pot (source line references only)

* Fix .gitignore pattern for compiled .mo files (they live under locales/LC_MESSAGES/, not locales/po/)
2026-09-24 17:00:29 -04:00
TheWitness 7ba762c1c6 Skip selectmenu init on criticality select if Cacti core already applied select2 (#247)
* fix: don't apply jQuery UI selectmenu on the criticality select if select2 already did

Cacti core is converting its global select-enhancement catch-all from
jQuery UI selectmenu to select2. If core's catch-all already turned the
dynamically-inserted #criticality select into a select2, skip re-applying
selectmenu to it here too, so it doesn't render twice.

* chore: bump minimum compatible Cacti version to 1.2.32

* fix: wire applyFilter() to the select2 branch of the criticality select

Copilot review caught this: the select2-hidden-accessible branch skipped
selectmenu's change:applyFilter() callback entirely, so choosing a
criticality no longer reloaded the filtered device list once core had
already converted the select to select2. Bind change->applyFilter()
directly in that branch instead.

Also regenerate locales/po/cacti.pot (and the merged .po/.mo files) via
locales/build_gettext.sh - setup.php's line numbers shifted.
2026-09-23 10:25:39 -04:00
TheWitness b92262e796 chore: move monitor.css into css/ directory (#233) 2026-09-15 11:23:51 -04:00
Thomas VincentandTheWitness 11fa109548 refactor: safe PHP 7.4 modernization (#212)
* refactor: add strict typing and clean up standalone infra

* refactor: safe PHP 7.4 modernization (arrays, null coalescing)

* fix: restore corrupted function calls from refactor tool

Revert bulk array()->[] rewrite damage affecting:
- is_array, in_array, xml2array
- call_user_func_array, filter_var_array
- Function declarations with _array suffix

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

* fix: restore corrupted syntax from refactor tool

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

* fix: remove duplicate declare(strict_types) statements

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

* fix(security): escape request reuse in monitor views

* fix:Run php-cs-fixit to resolve workflows

* fix: Remove strict types for now

---------

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Co-authored-by: TheWitness <thewitness@cacti.net>
2026-07-09 09:20:25 -04:00
501622a676 Refactor codebase for PSR12 compliance and modernization (#202)
* PSR12 - First run

Rename functions to match PSR12 requirements

* PSR12 run 1

- Change tabs to spaces
- add consts

* reduce cognetive complexity scores based on PSR12 and sonar scans

* Split poller_monitor  with helper file

* update docblocks

* code reorginization

Breaking up  some of the large files

* modernize js

Replaced legacy var with const/let.
Switched loose checks to strict (===, !==, strict typeof checks).
Added default param: applyFilter(action = '').
Used template literals for URL/query string assembly.
Converted many callbacks to arrow functions and shorthand methods.
Removed one duplicate object key in saveFilter payload (trim was defined twice with same value).
Kept existing flow, DOM selectors, action names, and endpoints unchanged.

* Update monitor.js

Applied the Sonar-requested cleanups in monitor.js:

* remove unused variables

* remove unused variables

* Update copilot-instructions.md

* PSR12 formatting

* Update db_functions.php

* refactor functions

Refactor rending function and Ajax call functions
Lowe cognetive complexity
prepare for easier testing

* Add missing docblocks

* Apply typing

* remove checks for min php version

* correct installation errors after PSR12

* try iinstall fix one more time

* .

* Update monitor_controller.php

* Update monitor_controller.php

* Update monitor_render.php

* fix typing errors

* apply php cs-fixer updates

* missed 2 commits

* Update js/monitor.js

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

* Update js/monitor.js

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

* Update copilot-instructions.md

---------

Co-authored-by: TheWitness <thewitness@cacti.net>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-03-07 11:55:27 -05:00
d9d25655da CI workflow and CS fixer updates (#198)
* add CI workflow and AI instructions

* Apply csfixer updates

* Update .github/agents/mysql-mariadb.agent.md

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

* Update .github/agents/mysql-mariadb.agent.md

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

* Update .github/agents/triage_agent.md.agent.md

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

---------

Co-authored-by: TheWitness <thewitness@cacti.net>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-14 20:04:33 -05:00
TheWitness 89a2a485ad Update copyrights to 2026 (#199) 2026-02-14 15:56:15 -05:00
TheWitness c9ea6ecd34 QA: Update Copyrights to 2025 2025-06-16 09:20:41 -04:00
Petr MacekandTheWitness f2e3546466 fix incorrect rows, missing default value, php error (#188)
* fix incorrect rows, missing default value, php error

* better value

* update

---------

Co-authored-by: TheWitness <thewitness@cacti.net>
2025-05-28 15:50:54 -04:00
Petr Macek 49894faf45 add new view - names only (#186)
* add names only display

* table format

* update
2025-04-26 13:53:48 -04:00
TheWitness 17929f0170 QA: Light repositioning 2025-01-27 21:32:08 -05:00
TheWitness 3e02420d16 QA: Reposition Form in Cacti 1.3 2025-01-12 13:31:11 -05:00
TheWitness be58872a4f QA: Support for Cacti 1.3 2024-12-19 21:03:19 -05:00
TheWitness 232b0d42cb Feature: Support for Cacti 1.3
* This version of the plugin is required to restore functionality on the Devices page in Cacti 1.3+
2024-12-19 20:06:40 -05:00
TheWitness b3bc7f2989 Feature: Support new form_dropicon in Cacti
* This will allow the user to see what the Icon looks like before making the changes.
2024-12-04 13:34:23 -05:00
TheWitness b6ed48ea55 QA: Allow monitor to use the new registration function
* This is only half implemented.
* Once this plugin only support 1.3+, we can further simplify this implementation.
2024-11-03 11:44:55 -05:00
TheWitness c84c9ef36c QA: Remove warnings in Cacti 1.3 2024-10-29 17:59:02 -04:00
MSSandTheWitness e3aab2860c Add a feature to send the reboot email as one email to all recipients (#180)
* Add a feature (send one email to all recipients in case of device reboot)

Add a feature (send one email to all recipients in case of device reboot)

* Add a feature (send one email to all recipients in case of device reboot)

Add a feature (send one email to all recipients in case of device reboot)

* Update poller_monitor.php

* Update setup.php

---------

Co-authored-by: TheWitness <thewitness@cacti.net>
2024-06-17 15:09:40 -04:00
TheWitness cae4012523 QA: Updating Copyrights to 2024 2024-03-16 04:57:13 +05:30
Petr Macek e662532d7c add missing column (#170) 2024-01-28 15:29:07 -05:00
TheWitness 488a0dd780 QA: Fix #169 - Monitor disabled due to null seed
* Some light psr
* Loving these new guardrails in PHP
2024-01-28 13:28:30 -05:00
Petr Macek 47fee07239 add icons for devices (#167)
* add icons for devices

* update

* better include my variable

* remove wrong include

* fix global
2024-01-27 14:43:41 -05:00
Linegod c48c138303 typos 2023-12-11 22:03:23 -06:00
TheWitness dec724f175 Fixing #161 - This should be a fix to the uptime issue
Keep us posted.
2023-12-10 16:44:06 -05:00
TheWitness a06c046cd6 Fixing PHP8.x Issue 2023-08-28 10:02:28 -04:00
TheWitness 13621613f1 QA: Re-arrange for readability 2023-04-11 21:14:48 -04:00
TheWitness 567c87491d Update monitor 2023-04-10 15:58:53 -04:00
TheWitness a16e9a5e9c QA: Missing update 2023-02-23 11:09:09 -05:00
netniV f0b6bf5e54 Update copyright for 2023 2023-01-04 22:15:22 +00:00
TheWitness a191f4e997 Merge branch 'develop' of https://github.com/Cacti/plugin_monitor into develop 2022-11-25 22:30:49 -05:00
Matthew Arthur 9a9ee8fe8d Fixes #152 (#153)
Fixed spelling mistake 'Enter the Email Name to send the notifications form' > 'Enter the Email Name to send the notifications from'
2022-11-25 22:29:51 -05:00
TheWitness 0bae478b94 QA: Refixing most recent bug 2022-04-15 22:34:40 -04:00
TheWitness bec9695a68 Fix a monitor bug limiting Cacti QA tests 2022-04-15 14:06:06 -04:00
TheWitness 499366e7da Some updates for double byte characters in monitor 2022-03-01 22:08:04 -05:00
TheWitness d71e5158a6 Another update for #142 - Syntax error 2021-12-31 10:21:01 -05:00
TheWitness d88f11debe Fixing #142 PHP Backtraces
Monitor generates PHP Backtrace Errors
2021-12-31 10:19:14 -05:00
TheWitness 6febb16363 Fixing Issue Related to Cacti Issue #4192
Filter including a special character not handled correctly
2021-03-22 22:50:47 -04:00
TheWitness ce822e5b9b Fixing Issue #340 - Spelling
Fix "Notification" Spelling Error
2021-02-23 07:42:08 -05:00
TheWitness 608e1a683e Resolve multiple issues
* Correct additional PSR issues from recent pull request
* Monitor can remove all main data collector devices
* Monitor poller should not be run on remote data collectors
* Split off CHANGELOG.md from README.md
2020-12-12 16:48:52 -05:00
Datatech UK LtdandTheWitness 4610a66ce5 Added option to zoom when a device is down (#136)
* Added option to Loop the alarm sound.

* Minor fix for undefined **get_monitor_sound_loop** shown in logs

* Fix issue with sound still looping even when user set not to loop sound

* Update README.md

* Fix spelling mistake for Monitor Size Drop-down.
The default is Medium, but it defaults to Extra Small due to this spelling mistake.

* Feature - Add zoom with options on device down for monitor plugin.

* Mostly Cacti PSR Updates

* More PSR Updates

* More PSR Updates

* More PSR Updates

Co-authored-by: TheWitness <thewitness@cacti.net>
2020-12-12 14:42:38 -05:00
Datatech UK Ltd 323d1a6038 Added option to Loop the alarm sound. (#134) 2020-11-20 20:16:55 -05:00
TheWitness 6176b53620 Correct copyright, and don't send email if there is not one 2020-09-13 14:31:06 -04:00
Georgi D. Sotirov 8171f91352 Add location filter (#129)
Add the new location filter introduced with Cacti 1.2.11

See issues #2156 and #3424.
2020-04-16 19:45:21 -04:00
TheWitness e14f4dcd1b Minor update to support roles 2020-03-19 20:20:32 -04:00
cigamit 7eea9578d8 issue: Add more checks for removed Device conditions 2020-02-08 13:09:10 -06:00