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
6 changes: 4 additions & 2 deletions .github/workflows/plugin-ci-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,10 @@ jobs:
run: php tests/regression/cli_schema_upgrade_test.php
working-directory: ${{ github.workspace }}/cacti/plugins/syslog

- name: Run threshold recovery database checks
run: php tests/regression/threshold_recovery_database_test.php
- name: Run Syslog database regression checks
run: |
php tests/regression/threshold_recovery_database_test.php
php tests/regression/quality_must_fix_database_test.php
working-directory: ${{ github.workspace }}/cacti/plugins/syslog
env:
SYSLOG_TEST_MYSQL_DSN: 'mysql:host=127.0.0.1;port=3306'
Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@

--- develop ---

* style: Keep all SonarCloud-reported lines within the 120-character limit by reflowing long SQL calls, ternaries, mappings and misaligned PHPDoc comment blocks, and associate the Device Alert Rule filter controls (Search, Enabled, Rules) with accessible labels
* bug: Suppress automatic schema repair during plugin lifecycle operations and while Syslog is disabled or uninstalled; stop stale processor launches before they can recreate removed tables

* bug: Repair missing tables automatically on the main collector as well as remotes, and skip processing when schema repair fails

* bug: Resolve Cacti 1.2.x main-poller default database connections explicitly for Syslog rule replication

* bug: Automatically repair collector-local schema before remote Syslog queries and processing after reinstall; keep failed message queries from disabling the plugin with a return-type error

* bug: Remove all plugin-owned tables from remote collectors through Cacti's native API when uninstalling all Syslog data

* security: Escape stored removal and report rule names in all bulk-action confirmations
* bug: Route rule imports to the configured Syslog database and publish complete remote rule snapshots with source-aware schema transfer and failure-safe replacement
* bug: Bound digest backfill to the registered master and a fixed migration range, retaining the last durable cursor when a batch or progress write fails
* bug: Report dashboard write failures and roll back partial deletes, copies and panel ordering changes
* bug: Count equal retained and removed log totals correctly and remove all plugin-owned tables during uninstall-all
* test: Repair the schema CLI fixture and add dedicated-database, rule synchronization, migration, output escaping and dashboard rollback regression coverage
* test: Measure lib/QueryBuilder.php in the patch-coverage gate and cover the QueryBuilder availability guards, the timeseries dashboard panel branch, invalid-database partition guards, retroactive removal-rule field maps, dMaxValue metadata extraction and the metadata label/filter button renderers

* bug: Restore the incoming-to-syslog archive INSERT so its outer SELECT no longer redeclares a second unbound poller_id placeholder (SQLSTATE HY093 "Invalid parameter number" made every transfer fail with "Unable to archive incoming records") and reads the derived table's columns instead of the out-of-scope syslog_incoming alias
* feature: Add an optional Recovery command to threshold alert rules, with correlated breach/clear script context and durable collector-owned clear retries
* feature: Add poller-driven pipeline health alerts for stalled processing, incoming backlogs, remote synchronization failures or delays, and blocked partition maintenance; expand the existing Status health card with check results and email delivery status, with optional problem, reminder, and recovery notifications
Expand Down
16 changes: 15 additions & 1 deletion cli/syslog_schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
require_once(dirname(__DIR__) . '/includes/schema.php');
require_once(dirname(__DIR__) . '/includes/settings.php');

/* process calling arguments */
// process calling arguments
$parms = $_SERVER['argv'];
array_shift($parms);

Expand All @@ -44,12 +44,15 @@
switch ($arg) {
case '--audit':
$audit = true;

break;
case '--repair':
$repair = true;

break;
case '--upgrade':
$upgrade = true;

break;
case '--help':
case '-H':
Expand All @@ -68,12 +71,14 @@
}

syslog_determine_config();

if (!defined('SYSLOG_CONFIG')) {
fwrite(STDERR, 'ERROR: Syslog database configuration is missing.' . PHP_EOL);
exit(1);
}

$database_last_error = '';

if (!syslog_connect()) {
fwrite(STDERR, 'ERROR: Unable to connect to the Syslog database.' . PHP_EOL);
exit(1);
Expand All @@ -100,12 +105,15 @@ function syslog_schema_repair_database(): bool {
'db_type' => 'part',
'days' => read_config_option('syslog_install_days')
], true);

if (!syslog_check_upgrade(true)) {
fwrite(STDERR, 'ERROR: Syslog schema upgrade failed; check the Cacti log.' . PHP_EOL);

return false;
}

$success = syslog_schema_report_audit_results(false);

if ($success) {
print 'Syslog schema upgrade completed; all required tables exist.' . PHP_EOL;
}
Expand All @@ -132,12 +140,14 @@ function syslog_schema_report_audit_results(bool $audit = true): bool {
'syslog_saved_searches_perm', 'syslog_device_rule', 'syslog_replication_output',
'syslog_replication_recovery'
];

if ((int) $config['poller_id'] <= 1) {
$tables[] = 'syslog_replication_receipts';
$tables[] = 'syslog_replication_collectors';
}

$missing = [];

foreach ($tables as $table) {
if (!syslog_db_table_exists($table, false)) {
$missing[] = $table;
Expand All @@ -146,16 +156,20 @@ function syslog_schema_report_audit_results(bool $audit = true): bool {

if (!empty($database_last_error)) {
fwrite(STDERR, 'ERROR: Schema check encountered a database error; check the Cacti log.' . PHP_EOL);

return false;
}

if ($missing) {
fwrite(STDERR, 'ERROR: Missing tables: ' . implode(', ', $missing) . PHP_EOL);

return false;
}

if ($audit) {
print 'Syslog schema audit passed; all required tables exist.' . PHP_EOL;
}

return true;
}

Expand Down
7 changes: 7 additions & 0 deletions docs/setup-modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,10 @@ rule changes reach remote collectors during Cacti's next full replication cycle,
through the registered `syslog_replicate_out` hook. The save handler does not
query or change Cacti's collector tables, or discover and connect to collectors.
Synchronized remote collectors continue to reject local rule edits.

The rule snapshot helper uses the main Syslog connection for source schema and
Cacti's supplied remote connection for delivery. It builds each snapshot in a
plugin-owned staging table and publishes it with an atomic table rename, so an
empty source clears deleted rules and a failed copy preserves the live table.
Remote collectors copy Cacti's local rule snapshot into a dedicated Syslog
database only from the registered master process.
28 changes: 14 additions & 14 deletions includes/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ function syslog_db_execute($sql, $log = true): bool {
/**
* syslog_db_execute_prepared - run an sql query and do not return any output
*
* @param string $sql The sql query to execute
* @param string $sql The sql query to execute
* @param array<int,mixed> $parms The sql params for the prepare
* @param bool $log Whether to log error messages, defaults to true
* @param bool $log Whether to log error messages, defaults to true
*
* @return bool true for success, false for error
*/
Expand Down Expand Up @@ -106,10 +106,10 @@ function syslog_db_fetch_cell($sql, $col_name = '', $log = true) {
* syslog_db_fetch_cell_prepared - run a 'select' sql query and return the first column of the
* first row found
*
* @param string $sql The sql query to execute
* @param string $sql The sql query to execute
* @param array<int,mixed> $params An array of parameters
* @param string $col_name Use this column name instead of the first one
* @param bool $log Whether to log error messages, defaults to true
* @param string $col_name Use this column name instead of the first one
* @param bool $log Whether to log error messages, defaults to true
*
* @return mixed The output of the sql query as a single variable
*/
Expand All @@ -136,9 +136,9 @@ function syslog_db_fetch_row($sql, $log = true) {
/**
* syslog_db_fetch_row_prepared - run a 'select' sql query and return the first row found
*
* @param string $sql The sql query to execute
* @param string $sql The sql query to execute
* @param array<int,mixed> $params An array of parameters
* @param bool $log Whether to log error messages, defaults to true
* @param bool $log Whether to log error messages, defaults to true
*
* @return array<string, mixed>|false The first row of the result as a hash
*/
Expand All @@ -165,9 +165,9 @@ function syslog_db_fetch_assoc($sql, $log = true) {
/**
* syslog_db_fetch_assoc_prepared - run a 'select' sql query and return all rows found
*
* @param string $sql The sql query to execute
* @param string $sql The sql query to execute
* @param array<int,mixed> $params An array of parameters
* @param bool $log Whether to log error messages, defaults to true
* @param bool $log Whether to log error messages, defaults to true
*
* @return list<array<string, mixed>>|false The entire result set as a multi-dimensional hash
*/
Expand All @@ -191,9 +191,9 @@ function syslog_db_fetch_insert_id(): int {
/**
* syslog_db_replace - replaces the data contained in a particular row
*
* @param string $table_name The name of the table to make the replacement in
* @param array<string, mixed> $array_items An array containing each column -> value mapping in the row
* @param string|array<string> $keyCols The name of the column containing the primary key
* @param string $table_name The name of the table to make the replacement in
* @param array<string, mixed> $array_items An array containing each column -> value mapping in the row
* @param string|array<string> $keyCols The name of the column containing the primary key
*
* @return int|false The auto incriment id column (if applicable), or false for error
*/
Expand Down Expand Up @@ -272,9 +272,9 @@ function syslog_db_column_exists($table, $column, $log = true): bool {
/**
* syslog_db_add_column - adds a column to a table
*
* @param string $table The name of the table
* @param string $table The name of the table
* @param array<string, mixed> $column The column definition
* @param bool $log Whether to log error messages, defaults to true
* @param bool $log Whether to log error messages, defaults to true
*
* @return bool true if the column was added, false otherwise
*/
Expand Down
Loading
Loading