changed how zabbix syncs

This commit is contained in:
Luca Haid
2025-04-14 13:54:09 +02:00
parent 7c30a356dc
commit a55ee900d8
2 changed files with 3 additions and 5 deletions

View File

@@ -24,8 +24,7 @@ class DeviceMonitoringController extends mfBaseController {
public function syncToolZabbix() {
foreach (DeviceModel::getAll() as $device) {
$ip = $device->ip;
$hosts = $this->zabbix->getHosts($ip);
$hosts = array_merge($this->zabbix->getHosts(null, $device->ip), $this->zabbix->getHosts($device->name));
if (empty($hosts)) {
echo "{$device->name}({$device->ip}) not found in Zabbix." . PHP_EOL;
@@ -36,12 +35,11 @@ class DeviceMonitoringController extends mfBaseController {
$icmpItems = $this->zabbix->getICMPItems($hostId);
$status = 0;
foreach ($icmpItems as $icmpItem) {
foreach ($icmpItems as $icmpItem)
if (strpos($icmpItem['key_'], 'icmpping[') !== false) {
$status = $icmpItem['lastvalue'] + 1;
break;
}
}
echo "{$device->name}({$device->ip}) found in Zabbix with host ID: {$hostId} and status: {$status}" . PHP_EOL;
$device->zabbix_online = $status;