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

@@ -352,6 +352,12 @@ class DeviceController extends mfBaseController
case "getZabbixConsolidationData":
$this->getZabbixConsolidationData();
break;
case "getZabbixTemplates":
$this->getZabbixTemplates();
break;
case "createZabbixHost":
$this->createZabbixHost();
break;
case "updateZabbixCoordinates":
$this->updateZabbixCoordinates();
break;
@@ -674,7 +680,7 @@ class DeviceController extends mfBaseController
self::returnJson($results);
}
protected function getZabbixTemplatesAction() {
protected function getZabbixTemplates() {
$zabbix = new Zabbix(ZABBIX_API_URL, ZABBIX_API_KEY);
$templateNames = [
"ICMP Ping",
@@ -690,12 +696,12 @@ class DeviceController extends mfBaseController
self::returnJson($formattedTemplates);
}
protected function createZabbixHostAction() {
protected function createZabbixHost() {
$this->postData = json_decode(file_get_contents('php://input'), true);
$deviceId = $this->postData['deviceId'] ?? null;
$templateId = $this->postData['templateId'] ?? null;
if (!$deviceId || !$templateId) {
$templateIds = $this->postData['templateIds'] ?? null;
if (!$deviceId || !$templateIds) {
self::sendError("Device ID or Template ID is missing.");
}
@@ -717,7 +723,7 @@ class DeviceController extends mfBaseController
self::sendError("Host group '$groupName' not found in Zabbix.");
}
$result = $zabbix->createHost($device->name, $device->ip, $groupId, $templateId);
$result = $zabbix->createHost($device->name, $device->ip, $groupId, $templateIds);
if (isset($result['hostids'])) {
$device->zabbix_host_id = $result['hostids'][0];