From 5e94eeed5e163c4291da66479924f5e219a74a6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrejs=20Gri=C5=A1=C4=8Denko?= Date: Thu, 5 May 2022 14:16:02 +0300 Subject: ..F....... [ZBX-20743] added a warning icon indicating the reason if compression is not supported --- ui/app/controllers/CControllerHousekeepingEdit.php | 9 +++- ui/app/views/administration.housekeeping.edit.php | 57 ++++++++++++++++++++-- ui/include/defines.inc.php | 9 ++++ 3 files changed, 69 insertions(+), 6 deletions(-) diff --git a/ui/app/controllers/CControllerHousekeepingEdit.php b/ui/app/controllers/CControllerHousekeepingEdit.php index d5a3d836254..75d6f2e7ddd 100644 --- a/ui/app/controllers/CControllerHousekeepingEdit.php +++ b/ui/app/controllers/CControllerHousekeepingEdit.php @@ -102,7 +102,8 @@ class CControllerHousekeepingEdit extends CController { CHousekeepingHelper::HK_TRENDS_GLOBAL )), 'hk_trends' => $this->getInput('hk_trends', CHousekeepingHelper::get(CHousekeepingHelper::HK_TRENDS)), - 'compression_availability' => 0, + 'compression_availability' => false, + 'compression_state' => ZBX_STATE_UNKNOWN, 'compression_status' => $this->getInput('compression_status', CHousekeepingHelper::get( CHousekeepingHelper::COMPRESSION_STATUS )), @@ -119,7 +120,11 @@ class CControllerHousekeepingEdit extends CController { foreach (json_decode($dbversion_status, true) as $dbversion) { if ($dbversion['database'] === ZBX_DB_EXTENSION_TIMESCALEDB && array_key_exists('compression_availability', $dbversion)) { - $data['compression_availability'] = (int) $dbversion['compression_availability']; + $data['timescaledb_min_version'] = $dbversion['min_version']; + $data['timescaledb_max_version'] = $dbversion['max_version']; + $data['timescaledb_min_supported_version'] = $dbversion['min_supported_version']; + $data['compression_availability'] = $dbversion['compression_availability']; + $data['compression_state'] = $dbversion['compression_state']; break; } } diff --git a/ui/app/views/administration.housekeeping.edit.php b/ui/app/views/administration.housekeeping.edit.php index ac9404474fa..224f27ec71d 100644 --- a/ui/app/views/administration.housekeeping.edit.php +++ b/ui/app/views/administration.housekeeping.edit.php @@ -154,13 +154,63 @@ $house_keeper_tab = (new CFormList()) ); if ($data['db_extension'] === ZBX_DB_EXTENSION_TIMESCALEDB) { + switch ($data['compression_state']) { + case ZBX_STATE_UNKNOWN: + $timescaledb_error = _('Unable to retrieve TimescaleDB compression support status.'); + break; + + case ZBX_TIMESCALEDB_POSTGRES_TOO_OLD: + $timescaledb_error = _('Compression is not supported.').' '. + _('PostgreSQL database server version is too old.'); + break; + + case ZBX_TIMESCALEDB_VERSION_FAILED_TO_RETRIEVE: + $timescaledb_error = _('Compression is not supported.').' '. + _('Unable to retrieve TimescaleDB version.'); + break; + + case ZBX_TIMESCALEDB_VERSION_LOWER_THAN_MINIMUM: + $timescaledb_error = _('Compression is not supported.').' '. + _s('Minimum required TimescaleDB version is %1$s.', $data['timescaledb_min_version']); + break; + + case ZBX_TIMESCALEDB_VERSION_NOT_SUPPORTED: + $timescaledb_error = _s('Unsupported TimescaleDB version. Should be at least %1$s.', + $data['timescaledb_min_supported_version'] + ); + + if (!$data['compression_availability']) { + $timescaledb_error = _('Compression is not supported.').' '.$timescaledb_error; + } + break; + + case ZBX_TIMESCALEDB_VERSION_HIGHER_THAN_MAXIMUM: + $timescaledb_error = _s('Unsupported TimescaleDB version. Must not be higher than %1$s.', + $data['timescaledb_max_version'] + ); + break; + + case ZBX_TIMESCALEDB_LICENSE_NOT_COMMUNITY: + $timescaledb_error = _('Detected TimescaleDB license does not support compression. Compression is supported in TimescaleDB Community Edition.'); + break; + + case ZBX_TIMESCALEDB_COMPRESSION_SUPPORTED: + default: + $timescaledb_error = ''; + } + + $timescaledb_error = $timescaledb_error !== '' + ? (makeErrorIcon($timescaledb_error))->addStyle('margin-left: 5px;') + : null; + $compression_status_checkbox = (new CCheckBox('compression_status')) + ->setChecked($data['compression_status'] == 1) + ->setEnabled($data['compression_availability']); + $house_keeper_tab ->addRow((new CTag('h4', true, _('History and trends compression')))->addClass('input-section-header')) ->addRow( new CLabel(_('Enable compression'), 'compression_status'), - (new CCheckBox('compression_status')) - ->setChecked($data['compression_status'] == 1) - ->setEnabled($data['compression_availability'] == 1) + [$compression_status_checkbox, $timescaledb_error] ) ->addRow( (new CLabel(_('Compress records older than'), 'compress_older')) @@ -174,7 +224,6 @@ $house_keeper_tab = (new CFormList()) ); } - $house_keeper_tab ->addRow((new CTag('h4', true, _('Audit')))->addClass('input-section-header')) ->addRow(new CLink(_('Audit settings'), (new CUrl('zabbix.php'))->setArgument('action', 'audit.settings.edit')) diff --git a/ui/include/defines.inc.php b/ui/include/defines.inc.php index 2e41a1eca51..25671fb0315 100644 --- a/ui/include/defines.inc.php +++ b/ui/include/defines.inc.php @@ -153,6 +153,15 @@ define('ZBX_DB_POSTGRESQL', 'POSTGRESQL'); define('ZBX_DB_EXTENSION_TIMESCALEDB', 'timescaledb'); +define('ZBX_STATE_UNKNOWN', 0); +define('ZBX_TIMESCALEDB_COMPRESSION_SUPPORTED', 1); +define('ZBX_TIMESCALEDB_POSTGRES_TOO_OLD', 2); +define('ZBX_TIMESCALEDB_VERSION_FAILED_TO_RETRIEVE', 3); +define('ZBX_TIMESCALEDB_VERSION_LOWER_THAN_MINIMUM', 4); +define('ZBX_TIMESCALEDB_VERSION_NOT_SUPPORTED', 5); +define('ZBX_TIMESCALEDB_VERSION_HIGHER_THAN_MAXIMUM', 6); +define('ZBX_TIMESCALEDB_LICENSE_NOT_COMMUNITY', 7); + define('ZBX_DB_MAX_ID', '9223372036854775807'); // maximum number of records for create() or update() API calls -- cgit v1.2.3