Source
* Check if function is aggregating wildcarded host/item queries and is exclusive to calculated item formulas.
<?php declare(strict_types = 0);
/*
** 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 Affero General Public License as published by the Free Software Foundation, version 3.
**
** 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 Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
/**
* Class containing information on history functions.
*/
final class CHistFunctionData {
public const PERIOD_MODE_DEFAULT = 0;
public const PERIOD_MODE_SEC = 1;
public const PERIOD_MODE_SEC_ONLY = 2;
public const PERIOD_MODE_NUM_ONLY = 3;
public const PERIOD_MODE_TREND = 4;
/**
* Known history functions along with definition of parameters.
*
* @var array
*/
private const PARAMETERS = [
'avg' => [
['rules' => [['type' => 'query']]],
['rules' => [['type' => 'period', 'mode' => self::PERIOD_MODE_DEFAULT]]]
],
'avg_foreach' => [
['rules' => [['type' => 'query']]],
['rules' => [['type' => 'period', 'mode' => self::PERIOD_MODE_SEC_ONLY]]]
],
'bucket_percentile' => [
['rules' => [['type' => 'query']]],
['rules' => [['type' => 'period', 'mode' => self::PERIOD_MODE_SEC_ONLY]]],
['rules' => [
['type' => 'regexp', 'pattern' => '/^((\d+(\.\d{0,4})?)|(\.\d{1,4}))$/'],
['type' => 'number', 'min' => 0, 'max' => 100]
]]
],
'bucket_rate_foreach' => [
['rules' => [['type' => 'query']]],
['rules' => [['type' => 'period', 'mode' => self::PERIOD_MODE_SEC_ONLY]]],
['rules' => [
['type' => 'regexp', 'pattern' => '/^\d+$/'],
['type' => 'number', 'min' => 1]
], 'required' => false]
],
'change' => [
['rules' => [['type' => 'query']]]
],
'changecount' => [
['rules' => [['type' => 'query']]],
['rules' => [['type' => 'period', 'mode' => self::PERIOD_MODE_DEFAULT]]],
['rules' => [['type' => 'regexp', 'pattern' => '/^(inc|dec|all)$/']], 'required' => false]
],
'count' => [
['rules' => [['type' => 'query']]],
['rules' => [['type' => 'period', 'mode' => self::PERIOD_MODE_DEFAULT]]],
['rules' => [['type' => 'regexp', 'pattern' => '/^(eq|ne|gt|ge|lt|le|like|bitand|regexp|iregexp)$/']],
'required' => false
],
['required' => false]
],
'count_foreach' => [
['rules' => [['type' => 'query']]],
['rules' => [['type' => 'period', 'mode' => self::PERIOD_MODE_SEC_ONLY]]],
['rules' => [['type' => 'regexp', 'pattern' => '/^(eq|ne|gt|ge|lt|le|like|bitand|regexp|iregexp)$/']],
'required' => false
],
['required' => false]
],
'countunique' => [
['rules' => [['type' => 'query']]],
['rules' => [['type' => 'period', 'mode' => self::PERIOD_MODE_DEFAULT]]],
['rules' => [['type' => 'regexp', 'pattern' => '/^(eq|ne|gt|ge|lt|le|like|bitand|regexp|iregexp)$/']],
'required' => false
],
['required' => false]
],
'exists_foreach' => [
['rules' => [['type' => 'query']]]