Source
<?php
/*
** 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 DynamicItemWidgets {
public static function load() {
// Create hostgroups for hosts.
CDataHelper::call('hostgroup.create', [
['name' => 'Dynamic widgets HG1 (H1 and H2)'],
['name' => 'Dynamic widgets HG2 (H3)']
]);
$groupids = CDataHelper::getIds('name');
// Create hosts with items.
$hosts = CDataHelper::createHosts([
[
'host' => 'Dynamic widgets H1',
'groups' => [
'groupid' => $groupids['Dynamic widgets HG1 (H1 and H2)']
],
'items' => [
[
'name' => 'Dynamic widgets H1I1',
'key_' => 'dynamic[1]',
'type' => ITEM_TYPE_TRAPPER,
'value_type' => ITEM_VALUE_TYPE_FLOAT
],
[
'name' => 'Dynamic widgets H1I2',
'key_' => 'dynamic[2]',
'type' => ITEM_TYPE_TRAPPER,
'value_type' => ITEM_VALUE_TYPE_FLOAT
]
]
],
[
'host' => 'Dynamic widgets H2',
'groups' => [
'groupid' => $groupids['Dynamic widgets HG1 (H1 and H2)']
],
'items' => [
[
'name' => 'Dynamic widgets H2I1',
'key_' => 'dynamic[1]',
'type' => ITEM_TYPE_TRAPPER,
'value_type' => ITEM_VALUE_TYPE_FLOAT
]
]
],
[
'host' => 'Dynamic widgets H3',