Skip to content

fix(daemon): load lib/time.php in the worker for <GRAPH> alerts - #894

Merged
bmfmancini merged 1 commit into
Cacti:developfrom
somethingwithproof:fix/mail-timespan-include
Dec 2, 2026
Merged

bmfmancini merged 1 commit into
Cacti:developfrom
somethingwithproof:fix/mail-timespan-include

Conversation

@somethingwithproof

Copy link
Copy Markdown
Member

Fixes #893.

thold_mail() calls get_timespan() for the <GRAPH> tag, which is in the default alert text. The daemon worker, thold_process.php, never included lib/time.php, so the first such alert was a fatal error and core's shutdown handler disabled the plugin.

Change

  • thold_process.php: require_once core lib/time.php, next to the existing lib/rrd.php include.
  • tests/bin/daemon-graph-alert-check.php and a CI step: run the real worker against one breaching threshold with <GRAPH> alert text and the notification queue on (no mail is sent). The check passes only if the worker is still running, the plugin is still enabled, the threshold is in alert, and an alert is in the notification queue. It refuses to run unless THOLD_DAEMON_DB_CHECK=1 is set and the thold tables are empty, and it cleans up after itself.

The include is in the entry point rather than in thold_mail() because the unit bootstrap stubs get_timespan(), and including the real file there redeclares it.

Testing

Local, MariaDB 11.8, PHP 8.4, Cacti 1.2.x:

Tree Result
develop FAIL: the worker exited, the plugin was disabled, no alert queued; cacti.log shows the same fatal as the report
this branch OK: alert queued, plugin enabled, no FATAL/ERROR/WARNING lines in cacti.log

No CHANGELOG entry yet: #892 also edits the CHANGELOG, so I will add the #893 line once that merges, to avoid a conflict.

thold_mail() calls get_timespan() when the alert text has a <GRAPH> tag.
The daemon worker never loaded lib/time.php, so the first such alert was
a fatal error and Cacti disabled the plugin.

Add a CI check that runs the real worker against a breaching threshold
with a <GRAPH> alert and confirms the plugin stays enabled and the alert
is queued.

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

sonarqubecloud Bot commented Dec 2, 2026

Copy link
Copy Markdown

@bmfmancini
bmfmancini merged commit 78e39bb into Cacti:develop Dec 2, 2026
7 checks passed
TheWitness added a commit to somethingwithproof/plugin_thold that referenced this pull request Dec 3, 2026
Resolve the CI workflow conflict by keeping both daemon database checks:
the queue/worker check from this branch runs first, followed by the
graph-alert worker check added on develop (Cacti#894).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Daemon worker fatal on alerts with <GRAPH>: get_timespan() undefined, plugin disabled

2 participants