Source
DBexecute("INSERT INTO group_discovery (groupdiscoveryid, groupid, parent_group_prototypeid, name, lastcheck, ts_delete) VALUES(50, ".
<?php
/*
** Zabbix
** Copyright (C) 2001-2023 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.
**/
class DiscoveredHosts {
const DISCOVERED_HOST = 'Discovered host from prototype 1';
const DISCOVERED_HOST2 = 'Discovered host from prototype 11';
const DISCOVERED_HOSTID = 90000079;
const DISCOVERED_HOSTID2 = 90000080;
const DISCOVERED_INTERFACEID = 90000080;
const DISCOVERED_HOST_GROUPID = 90000081;
const DISCOVERED_HOST_GROUPID2 = 90000082;
const DISCOVERED_GROUP = 'Group created from host prototype 1';
const DISCOVERED_GROUP2 = 'Group created from host prototype 11';
const DISCOVERED_GROUPID = 90000079;
const DISCOVERED_GROUPID2 = 90000080;
const DISCOVERED_HOST_GROUP_PROTOTYPEID = 90000083;
const DISCOVERED_HOST_GROUP_PROTOTYPEID2 = 90000084;
/**
* Parent hostid.
*
* @var integer
*/
protected static $hostid;
/**
* Create data for testFormHost, Discovered host scenario.
*
* @return array
*/
public static function load() {
// Create hostgroup for discovered host test.
$hostgroups = CDataHelper::call('hostgroup.create', [
[
'name' => 'Group for discovered host test'
]
]);
$hostgroupid = $hostgroups['groupids'][0];
$hosts = CDataHelper::call('host.create', [
'host' => 'Test of discovered host',
'groups' => [
['groupid' => $hostgroupid]
],
'interfaces' => [
'type'=> 1,
'main' => 1,
'useip' => 1,
'ip' => '127.0.0.1',
'dns' => '',
'port' => 10050
]
]);
self::$hostid = $hosts['hostids'][0];
$interfaceid = CDBHelper::getValue('SELECT interfaceid FROM interface WHERE hostid='.zbx_dbstr(self::$hostid));
// Create discovery rule.
$llds = CDataHelper::call('discoveryrule.create', [
'name' => 'LLD for Discovered host tests',
'key_' => 'vfs.fs.discovery',
'hostid' => self::$hostid,
'type' => ITEM_TYPE_ZABBIX,
'interfaceid' => $interfaceid,
'delay' => 30
]);
$lldid = $llds['itemids'][0];
// Create host prototype.
$host_prototypes = CDataHelper::call('hostprototype.create', [
'host' => 'Host created from host prototype {#KEY}',