Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@ When generating code for this repository:

```
thold/ # Repository root (install to plugins/thold/ in Cacti)
├── extras/ # Supplementary assets
├── cli/ # Non-polling CLI tools: thresholds.php, import.php, apply_realms.php, upgrade.php, upgrade_legacy.php
├── includes/ # functions.php (core logic), webapi.php (web API), polling.php (poller hooks), settings.php (config UI), tab.php
├── service/ # systemd unit for thold_daemon
├── tests/ # Test suite (phpunit.xml)
├── css/ # CSS theme overlays
├── cli_import.php / cli_thresholds.php # CLI threshold management utilities
├── notify_lists.php / notify_queue.php # Notification list/queue administration
├── thold.php # Main threshold administration UI
├── thold_daemon.php # Standalone high-scale daemon (bypasses poller hook)
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Documentation update (unreleased): Refresh README release/source compatibility,
installation guidance and source-checked behavior.

--- develop ---
* issue#839: The plugin upgrade now migrates only from Thold 1.5 or later, which retires the 1.0.1 - 1.2.4 migrations and everything before 1.0 from `includes/database.php`. An older install is refused with a Cacti log error, nothing changed, until `php plugins/thold/cli/upgrade_legacy.php` (with `--dry-run` and `--debug`) has brought a 1.0 - 1.4 install to 1.5 and run the normal upgrade. Installs older than 1.0 are no longer supported. A forced upgrade now re-runs the migrations from 1.5
* issue#839: Move the non-polling command line scripts into `cli/` without the `cli_` prefix: `cli_thresholds.php` is now `cli/thresholds.php`, `cli_import.php` is `cli/import.php`, and `extras/upgrade.php` and `extras/apply_realms.php` are `cli/upgrade.php` and `cli/apply_realms.php`. The old paths and `extras/` are tombstoned, so an upgrade removes them
* issue#691: Validate a new threshold's values before its first save, so one created from Console > Data Sources can no longer be saved with impossible or missing limits; only the non-templated wizard's empty first save skips validation. A rejected save now returns to the edit form with its data source instead of a blank page
* issue#882: Replace triple percent (`%%%`) format specifiers with `%%` in `includes/arrays.php`, `includes/functions.php`, and `setup.php` so PHP 8 `sprintf()` and `msgfmt --check-format` handle percent signs cleanly, and refresh `locales/po/cacti.pot`; also fold the four alert/warning percentage HRULE blocks in `setup.php` into one loop with no behavior change, to keep new-code duplication under the project's quality gate; remove orphan `locales/LC_MESSAGES/ka.mo` and `locales/LC_MESSAGES/uk.mo`
* issue#889: Read the Threshold Daemon queue in bounded batches, check each queued threshold once, delete exactly the rows a worker read, and purge rows for deleted thresholds
Expand Down
27 changes: 23 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,19 +163,38 @@ thresholds, note that you must modify and install the thold_daemon.service file
into your systemd configuration, and then start and test the service. If you
fail to perform these steps, thold will appear to not work as expected.

Two command line scripts are included in the plugin directory. Run
`cli_thresholds.php --auto-create=N` (or select Devices, Graph Templates,
Command line scripts that are not part of polling live in the plugin's `cli/`
directory; run them from the Cacti directory, for example
`php plugins/thold/cli/thresholds.php --auto-create=N`. Use
`cli/thresholds.php --auto-create=N` (or select Devices, Graph Templates,
Threshold Templates or Graphs with `--host-ids`, `--graph-template`,
`--thold-template` and `--graph-ids`) to create Thresholds from Threshold
Templates, and `cli_import.php --filename=N` to import a Threshold Template
exported from the plugin.
Templates, `cli/import.php --filename=N` to import a Threshold Template
exported from the plugin, `cli/apply_realms.php` to grant the Thold realms,
`cli/upgrade.php` to force a database upgrade, and `cli/upgrade_legacy.php`
to upgrade an install older than 1.5 (see below). These scripts were
previously `cli_thresholds.php`, `cli_import.php` and `extras/`; an upgrade
removes the old copies.

When upgrading the plugin while the Threshold Daemon is running, restart the
`thold_daemon` service (for example `systemctl restart thold_daemon`) after
the upgrade so the long-lived process picks up the new code. On upgrade the
plugin also prunes its own bundled development-only files (for example the
`tests/` directory) from the installed tree.

The plugin upgrades automatically from Thold 1.5 or later. An install older
than 1.5 is left untouched and an error is written to the Cacti log until
you run the legacy upgrade from the Cacti directory:

```
php plugins/thold/cli/upgrade_legacy.php --dry-run # show what would run
php plugins/thold/cli/upgrade_legacy.php
```

It applies the 1.0.1 to 1.2.4 migrations, records 1.5, and then runs the
normal upgrade to the current release. Installs older than 1.0 are not
supported; uninstall Thold and install the current release instead.

Lastly, please note that several forks of the thold plugin are available from
different sources. These forks of thold are not necessarily compatible with the
current version of Cacti's thold plugin. Please be aware of this when
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions cli_import.php → cli/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

error_reporting(E_ALL);

include(__DIR__ . '/../../include/cli_check.php');
include(__DIR__ . '/../../../include/cli_check.php');
include_once($config['base_path'] . '/lib/xml.php');
include_once($config['base_path'] . '/plugins/thold/includes/functions.php');

Expand Down Expand Up @@ -182,7 +182,7 @@ function display_help() {

print PHP_EOL;

print 'usage: cli_import.php --filename=N' . PHP_EOL . PHP_EOL;
print 'usage: import.php --filename=N' . PHP_EOL . PHP_EOL;

print 'Simple CLI command to import a threshold template.' . PHP_EOL . PHP_EOL;
print '--filename=N - A valid threshold template exported using the thold plugin.' . PHP_EOL . PHP_EOL;
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions cli_thresholds.php → cli/thresholds.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
chdir($dir);

if (strpos($dir, 'plugins') !== false) {
chdir('../../');
chdir('../../../');
}

include('./include/cli_check.php');
Expand Down Expand Up @@ -227,7 +227,7 @@ function display_help() {

print PHP_EOL;

print 'usage: cli_thresholds.php --auto-create=N | [--host-ids=\'N1 N2 ...\'] [--graph-template=N] [--thold-template=N] [--graph-ids=\'N1 N2 ...\']' . PHP_EOL . PHP_EOL;
print 'usage: thresholds.php --auto-create=N | [--host-ids=\'N1 N2 ...\'] [--graph-template=N] [--thold-template=N] [--graph-ids=\'N1 N2 ...\']' . PHP_EOL . PHP_EOL;

print 'There are two usage methods:' . PHP_EOL . PHP_EOL;

Expand Down
File renamed without changes.
Loading