wmare下 host端如何更精确的取得虚拟机的状态

VMCI socket是vmare开发的,通过vmare自定义socket使得esxi(host)端与客户操作系统 之间能够在没有网络的情况下进行通信的机制。类似有kvm的qga功能。

esxi端通过vmci socket与虚拟机通信,通过这个机制esxi可以执行虚拟机的各个性能相关的命令,更加具体的了解虚拟机的性能。以下是参考vmci socket手册开发的,vmare下如何获取虚拟机的状态

开发的代码仓库在:

使用方法如下:https://github.com/yanxiaofeng2016/vmci-socket

vmci-socket
This program is used to communicate between esxi(host) and the operating system running in the virtual machine.The operating system can be either Windows or Linux.
This program is able to input the commands supported by the client operating system on the host side and return the results after the client runs the commands。

# how to use this tools

First, you need to run the binary program "socket" (window for socket.exe) on the client's operating system. and then run the next command on esxi(host) side.

usage for linux system running in virtual machine 
client cid:port command

PC#./client 100000:123456 "ls -l"

-rw-r--r--. 1 root root 2236 Jan  4 17:19 client.c 
-rw-r--r--. 1 root root  590 Jan  4 17:24 GNUmakefile 
-rw-r--r--. 1 root root  379 Jan  4 17:31 README.md 
-rw-r--r--. 1 root root 5424 Jan  4 17:19 socket.c  
-rw-r--r--. 1 root root  249 Jan  7 11:21 sock-portable.h 
-rw-r--r--. 1 root root  310 Jan  7 11:21 sock-posix.c 
-rw-r--r--. 1 root root  520 Jan  4 17:20 sock-windows.c 
-rwxr-xr-x. 1 root root  317 Jan  4 17:23 vmci-cflags 

usage for windows system running in virtual machine 
client cid:port command  

PC#./client 100000:123456 "ipconfig" 

Windows IP Configuration 

Ethernet adapter Ethernet0: 

   Media State . . . . . . . . . . . : Media disconnected 
   Connection-specific DNS Suffix  . :
  
  
# How to build:
for linux: 
PC#make 

for window: 
PC#make WINDOWS=1 

so, the binary "client" is usually for linux because esxi system is derived from Linux.
and the binary "socket" or "socket.exe" need to be compiled for two parts. one is for linux ,the other is for windows system.

more useful tools:
app.py apiserver.py this two files is used to output restful API. So app developer can call standard rest API to implent communication between client side and host side
first,you run app.py and then open a web browser. you can type url like the next example
http://target_host_machine/cid:port/os_command
a special example:
http://127.0.0.1/12345678:1234/ipconfig /all   

猜你喜欢

转载自blog.csdn.net/xiaofeng_yan/article/details/87913664