<?php
require_once dirname(__FILE__).'/../include/CIntegrationTest.php';
class testItemTimeouts extends CIntegrationTest {
const HOSTNAME_AGENT = "agent_host_timeouts";
const HOSTNAME_AGENT2 = "agent2_host_timeouts";
const HOSTNAME_SNMP = "snmp_host_timeouts";
const HOSTNAME_SSH = "ssh_host_timeouts";
const HOSTNAME_SIMPLE = "simple_host_timeouts";
private static $hostids;
private static $itemids;
public function prepareData() {
$response = $this->call('host.create', [
[
'host' => self::HOSTNAME_AGENT,
'interfaces' => [
'type' => 1,
'main' => 1,
'useip' => 1,
'ip' => '127.0.0.1',
'dns' => '',
'port' => $this->getConfigurationValue(self::COMPONENT_AGENT, 'ListenPort')
],
'groups' => [['groupid' => 4]],
'status' => HOST_STATUS_MONITORED
],
[
'host' => self::HOSTNAME_AGENT2,
'interfaces' => [
'type' => 1,
'main' => 1,
'useip' => 1,
'ip' => '127.0.0.1',
'dns' => '',
'port' => $this->getConfigurationValue(self::COMPONENT_AGENT2, 'ListenPort')
],
'groups' => [['groupid' => 4]],
'status' => HOST_STATUS_MONITORED
]
]);
$this->assertArrayHasKey('hostids', $response['result']);
$this->assertArrayHasKey(0, $response['result']['hostids']);
self::$hostids[self::HOSTNAME_AGENT] = $response['result']['hostids'][0];
self::$hostids[self::HOSTNAME_AGENT2] = $response['result']['hostids'][1];
$response = $this->call('host.get', [
'output' => ['host'],
'hostids' => [
self::$hostids[self::HOSTNAME_AGENT],
self::$hostids[self::HOSTNAME_AGENT2]
],
'selectInterfaces' => ['interfaceid'],
'sortfield' => 'hostid'
]);
$this->assertArrayHasKey(0, $response['result']);
$this->assertArrayHasKey('interfaces', $response['result'][0]);
$this->assertTrue(count($response['result']) == 2);
$agent_interfaceid = $response['result'][0]['interfaces'][0]['interfaceid'];
$agent2_interfaceid = $response['result'][1]['interfaces'][0]['interfaceid'];