Source
$req = DBselect('SELECT number_compressed_chunks FROM hypertable_compression_stats(\''.self::TABLENAME.'\')');
<?php
/*
** Zabbix
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
require_once dirname(__FILE__).'/../include/CIntegrationTest.php';
/**
* Test Timescale DB extension.
*
* @required-components server
* @hosts test_timescale
* @backup history
*/
class testTimescaleDb extends CIntegrationTest {
const HOSTNAME = 'test_timescale';
const TRAPNAME = 'trap_timescale';
const TABLENAME = 'history_uint';
const HIST_COUNT = 3000;
/*
storing old data deep in the past - 20 days, which is way longer that the minimum 7days,
and must be guaranteed to be compressed
*/
const COMPRESSION_OLDER_THAN = 20 * 24 * 3600;
static $db_extension = '';
private static $itemid;
/**
* Component configuration provider.
*
* @return array
*/
public function serverConfigurationProvider() {
return [
self::COMPONENT_SERVER => [
'DebugLevel' => 5,
'LogFileSize' => 0
]
];
}
private function retrieveExtention() {
self::$db_extension = '';
$sql = 'SELECT db_extension'.
' FROM config';
$res = DBfetch(DBselect($sql));
if ($res) {
self::$db_extension = $res['db_extension'];
}
}
/**
* Test TimescaleDb extension.
*/
private function clearChunks() {
$sql = 'SELECT drop_chunks(\''.self::TABLENAME.'\', older_than => '.time().')';
$res = DBfetch(DBselect($sql));
}
/**
* Test server is up with TimescaleDb.
*
* @required-components server
* @configurationDataProvider serverConfigurationProvider
*/
public function testTimescaleDb_checkServerUp() {
$this->assertEquals(self::$db_extension, ZBX_DB_EXTENSION_TIMESCALEDB);
self::waitForLogLineToBePresent(self::COMPONENT_SERVER, 'TimescaleDB version:');
}