fixed consolidation
This commit is contained in:
@@ -162,22 +162,30 @@ class Zabbix {
|
||||
}
|
||||
|
||||
|
||||
public function createHost($visibleName, $ip, $groupId, $templateId) {
|
||||
public function createHost($visibleName, $ip, $groupId, $templateIds) {
|
||||
$templatesData = array_map(function($id) {
|
||||
return ['templateid' => $id];
|
||||
}, $templateIds);
|
||||
|
||||
$params = [
|
||||
'host' => $ip, // Technical name is the IP
|
||||
'name' => $visibleName, // Visible name
|
||||
'interfaces' => [
|
||||
'interfaces' => [ // <-- Corrected structure
|
||||
[
|
||||
'type' => 1, // Agent interface
|
||||
'type' => 2, // 2 for SNMP
|
||||
'main' => 1,
|
||||
'useip' => 1,
|
||||
'ip' => $ip,
|
||||
'dns' => '',
|
||||
'port' => '10050'
|
||||
'port' => '161',
|
||||
'details' => [
|
||||
'version' => 2,
|
||||
'community' => 'public_xinon'
|
||||
]
|
||||
]
|
||||
],
|
||||
'groups' => [['groupid' => $groupId]],
|
||||
'templates' => [['templateid' => $templateId]]
|
||||
'templates' => $templatesData // Use the correctly formatted array
|
||||
];
|
||||
|
||||
$response = $this->zabbixRequest('host.create', $params);
|
||||
|
||||
Reference in New Issue
Block a user