changed how zabbix syncs
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user