$entry) { $vmwVmDisplayName = $entry['vmwVmDisplayName']; $vmwVmGuestOS = $entry['vmwVmGuestOS']; $vmwVmMemSize = $entry['vmwVmMemSize']; $vmwVmState = $entry['vmwVmState']; $vmwVmCpus = $entry['vmwVmCpus']; /* * VMware does not return an INTEGER but a STRING of the vmwVmMemSize. This bug * might be resolved by VMware in the future making this code obsolete. */ if (preg_match('/^([0-9]+) .*$/', $vmwVmMemSize, $matches)) { $vmwVmMemSize = $matches[1]; } /* * Check whether the Virtual Machine is already known for this host. */ if (dbFetchCell("SELECT COUNT(id) FROM `vminfo` WHERE `device_id` = ? AND `vmwVmVMID` = ? AND vm_type='vmware'", [$device['device_id'], $index]) == 0) { $vmid = dbInsert(['device_id' => $device['device_id'], 'vm_type' => 'vmware', 'vmwVmVMID' => $index, 'vmwVmDisplayName' => mres($vmwVmDisplayName), 'vmwVmGuestOS' => mres($vmwVmGuestOS), 'vmwVmMemSize' => mres($vmwVmMemSize), 'vmwVmCpus' => mres($vmwVmCpus), 'vmwVmState' => mres($vmwVmState)], 'vminfo'); log_event(mres($vmwVmDisplayName) . " ($vmwVmMemSize GB / $vmwVmCpus vCPU) Discovered", $device, 'system', 3, $vmid); echo '+'; // FIXME eventlog } else { echo '.'; } /* * Save the discovered Virtual Machine. */ $vmw_vmlist[] = $index; } /* * Get a list of all the known Virtual Machines for this host. */ $sql = "SELECT id, vmwVmVMID, vmwVmDisplayName FROM vminfo WHERE device_id = '" . $device['device_id'] . "' AND vm_type='vmware'"; foreach (dbFetchRows($sql) as $db_vm) { /* * Delete the Virtual Machines that are removed from the host. */ if (! in_array($db_vm['vmwVmVMID'], $vmw_vmlist)) { dbDelete('vminfo', '`id` = ?', [$db_vm['id']]); log_event(mres($db_vm['vmwVmDisplayName']) . ' Removed', $device, 'system', 4, $db_vm['vmwVmVMID']); echo '-'; // FIXME eventlog } } /* * Finished discovering VMware information. */ echo "\n"; }//end if