'HG_for_proxies']]); $hostgroupid = $hostgroups['groupids'][0]; // Create enabled hosts. $enabled_hosts_data = []; foreach (self::$enabled_hosts as $host) { $enabled_hosts_data[] = [ 'host' => $host, 'groups' => [['groupid' => $hostgroupid]], 'status' => 0 ]; } $enabled_hosts = CDataHelper::call('host.create', $enabled_hosts_data); $enabled_hostids = CDataHelper::getIds('host'); // Create hosts for filtering scenario. CDataHelper::call('host.create', [ ['host' => 'Host_1 with proxy', 'groups' => [['groupid' => 4]]], ['host' => 'Host_2 with proxy', 'groups' => [['groupid' => 4]]] ]); $filter_hostids = CDataHelper::getIds('host'); // Disabled hosts data. $disabled_hosts_data = []; foreach (self::$disabled_hosts as $host) { $disabled_hosts_data[] = [ 'host' => $host, 'groups' => [['groupid' => $hostgroupid]], 'status' => HOST_STATUS_NOT_MONITORED ]; } $disabled_hosts = CDataHelper::call('host.create', $disabled_hosts_data); $disabled_hostids = CDataHelper::getIds('host'); // Create active proxies. $active_proxy_data = []; foreach (self::$active_proxies as $proxy) { $active_proxy_data[] = [ 'name' => $proxy, 'operating_mode' => PROXY_OPERATING_MODE_ACTIVE ]; } $active_proxies = CDataHelper::call('proxy.create', $active_proxy_data); $active_proxyids = CDataHelper::getIds('name'); // Create passive proxies. $passive_proxy_data = []; foreach (self::$passive_proxies as $proxy) { $passive_proxy_data[] = [ 'name' => $proxy, 'operating_mode' => PROXY_OPERATING_MODE_PASSIVE, 'address' => '127.0.0.1', 'port' => '10051' ]; } $passive_proxies = CDataHelper::call('proxy.create', $passive_proxy_data); $passive_proxyids = CDataHelper::getIds('name'); // Add hosts to proxies. CDataHelper::call('proxy.update', [ [ 'proxyid' => $active_proxyids['active_proxy1'], 'hosts' => [ ['hostid' => $enabled_hostids['enabled_host1']] ] ], [ 'proxyid' => $passive_proxyids['passive_proxy1'], 'hosts' => [ ['hostid' => $disabled_hostids['disabled_host1']] ] ], [ 'proxyid' => $active_proxyids['active_proxy2'], 'hosts' => [ ['hostid' => $enabled_hostids['enabled_host2']], ['hostid' => $enabled_hostids['enabled_host3']] ] ], [ 'proxyid' => $passive_proxyids['passive_proxy2'], 'hosts' => [ ['hostid' => $enabled_hostids['enabled_host4']], ['hostid' => $enabled_hostids['enabled_host5']] ] ], [ 'proxyid' => $active_proxyids['active_proxy3'], 'hosts' => [ ['hostid' => $disabled_hostids['disabled_host2']], ['hostid' => $disabled_hostids['disabled_host3']] ] ], [ 'proxyid' => $passive_proxyids['passive_proxy3'], 'hosts' => [ ['hostid' => $disabled_hostids['disabled_host4']], ['hostid' => $disabled_hostids['disabled_host5']] ] ], [ 'proxyid' => $active_proxyids['active_proxy4'], 'hosts' => [ ['hostid' => $enabled_hostids['enabled_host6']], ['hostid' => $disabled_hostids['disabled_host6']] ] ], [ 'proxyid' => $passive_proxyids['passive_proxy4'], 'hosts' => [ ['hostid' => $enabled_hostids['enabled_host7']], ['hostid' => $enabled_hostids['enabled_host8']], ['hostid' => $disabled_hostids['disabled_host7']], ['hostid' => $disabled_hostids['disabled_host8']] ] ], [ 'proxyid' => $active_proxyids['Active proxy 1'], 'hosts' => [ ['hostid' => 99136] // Test item host. ] ], [ 'proxyid' => $active_proxyids['Proxy_1 for filter'], 'hosts' => [ ['hostid' => $filter_hostids['Host_1 with proxy']] ] ], [ 'proxyid' => $active_proxyids['Proxy_2 for filter'], 'hosts' => [ ['hostid' => $filter_hostids['Host_2 with proxy']] ] ] ]); /** * Add proxies versions. * Supported version "60400" is hardcoded one time, so that no need to change it, * even if newer versions of Zabbix are released. */ DBexecute('UPDATE proxy_rtdata SET version=60400, compatibility=1 WHERE proxyid='.zbx_dbstr($active_proxyids['active_current'])); DBexecute('UPDATE proxy_rtdata SET version=60200, compatibility=2 WHERE proxyid='.zbx_dbstr($passive_proxyids['passive_outdated'])); DBexecute('UPDATE proxy_rtdata SET version=0, compatibility=0 WHERE proxyid='.zbx_dbstr($active_proxyids['active_unknown'])); DBexecute('UPDATE proxy_rtdata SET version=50401, compatibility=3 WHERE proxyid='.zbx_dbstr($passive_proxyids['passive_unsupported'])); DBexecute('UPDATE config SET server_status='.zbx_dbstr('{"version": "6.4.0alpha1"}')); } }