fixed consolidation

This commit is contained in:
Luca Haid
2025-08-20 09:40:39 +02:00
parent e27fd1a398
commit ebc06a0208
3 changed files with 26 additions and 12 deletions

View File

@@ -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);