VMware Virtual Infrastructure Remote CLI 查找 ESX/i 中未使用的计算机/磁盘
在 VMware ESX/i 中,如何使用 VMware Virtual Infrastructure Remote CLI 查找未使用的计算机/磁盘? 我有大量的库存和磁盘上的许多文件,并且我想找到要删除的候选文件。
我想要的是确定
- 主机上的任何
vmx
机器是否正在使用vmdk
磁盘,或者 - 主机中是否存在
vmx
机器主机上的库存。
肯定有一些聪明的方法可以找到这个吗? 如果不是 VIRCLI,那么也许还有其他东西? 或者我需要虚拟中心吗?
编辑:这是一个不与任何其他主机共享计算机或磁盘的单一主机。
In VMware ESX/i, how can I use the VMware Virtual Infrastructure Remote CLI to find unused machines/disks? I have a huge inventory and many files on disk, and I want to find files that are candidates for deletion.
What I want is to determine whether
- a
vmdk
disk is in use by anyvmx
machine on the host, or whether - a
vmx
machine exists in the inventory on the host.
Surely some smart method exists for finding this? If not the VIRCLI, then maybe something else? Or do I need Virtual Center for this?
EDIT: This is a single host that does not share machines or disks with any other host.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
IC 不知道这些磁盘是否由另一台 ESXi 主机共享和使用,后端有 SAN 且多个主机访问同一存储设备是很常见的情况。 在这种情况下,无法知道哪些主机正在访问哪些计算机,您描述的场景仅在您只有一台主机时才有意义 - 这对于许多 VMware 企业客户来说不是典型场景。
使用 RCLI 或 shell,您可以迭代所有现有计算机,然后将其与磁盘上的列表进行比较。 然而,如果您在主机之间共享磁盘,那么事情就会变得更加复杂,您还需要遍历每台计算机上的设备。
更新:是的,现在更多的是具体细节脚本/编程问题;)
从 RCLI 文档 我可能会执行类似使用
vmware-cmd -l
列出主机上所有已注册计算机的操作。 然后使用vifs
下载配置文件,grep
通过那些查找虚拟磁盘 (.vmdk
) 的提及并将所有这些存储在文件中。第二部分,将编写一个脚本来执行递归目录列表,再次使用
vifs
,再次运行grep
以仅包含.vmdk
和.vmx
文件。 现在您已经有了两个列表,通过sort
对它们进行管道处理,然后diff
结果来找出哪些.vmx
文件未在系统上注册。计算机以及哪些.vmdk
文件未被任何活动虚拟机使用。 然后你就有了要删除的候选者:)The IC doesn't know if you've got those disks shared an in use by another ESXi host, it's very common to have a SAN on the backend and multiple hosts accessing the same storage device. In this case there's no way to know which hosts are accessing which machines, the scenario you describe only makes sense if you've got a single host - which is not the typical scenario for many of VMware's corporate customers.
Using the RCLI or shell you could iterate through all existing machines and then compare that to a list of what's on disk. If you've got disks shared between hosts however, then things become a lot more complicated and you'd need to iterate through the devices on each machine as well.
Update: Right, now it's more of a nuts n bolts scripting/programming question ;)
Starting with the RCLI documentation I'd probably do something like using
vmware-cmd -l
to list all registered machines on the host. Then usingvifs
download the config files,grep
through those looking for mentions of virtual disks (.vmdk
) and storing all those in a file.Part two, would be writing a script to do a recursive directory listing, again using
vifs
, runninggrep
again on that to only include.vmdk
and.vmx
files. Now you've got two lists, pipe these throughsort
and thendiff
the results to find out what.vmx
files are not registered on the machine and what.vmdk
files are not in use by any active VM. And then you have your candidates for deletion :)