Friday, 5 October 2012

VMware ESXi commands

To find ESXi software version & build
# vmware -v
VMware ESXi 5.0.0 build-469512
# vmware -l
VMware ESXi 5.0.0 GA

To see the running process
 # esxtop
To list the network cards properties
# esxcfg-vmknic -l
Interface  Port Group/DVPort   IP Family IP Address      Netmask         Broadcast       MAC Address       MTU     TSO MSS   Enabled Type     
vmk0       Management Network  IPv4     10.78.203.72 255.255.255.0   10.78.203.255   00:10:18:a7:76:88 1500    65535     true    STATIC #

#esxcfg-nics -l
Name    PCI           Driver      Link Speed     Duplex MAC Address       MTU    Description
vmnic0  0000:0b:00.00 bnx2        Up   1000Mbps  Full   00:10:18:a7:76:88 1500   Broadcom Corporation Broadcom NetXtreme II BCM5709 1000Base-T
vmnic1  0000:0b:00.01 bnx2        Up   1000Mbps  Full   00:10:18:a7:76:8a 1500   Broadcom Corporation Broadcom NetXtreme II BCM5709 1000Base-T
vmnic2  0000:0c:00.00 bnx2        Up   1000Mbps  Full   00:10:18:a7:76:8c 1500   Broadcom Corporation Broadcom NetXtreme II BCM5709 1000Base-T

# esxcfg-vswitch -l
Switch Name      Num Ports   Used Ports  Configured Ports  MTU     Uplinks
vSwitch0         128         3           128               1500    vmnic0
  PortGroup Name        VLAN ID  Used Ports  Uplinks
  VM Network            0        0           vmnic0
  Management Network    0        1           vmnic0

Switch Name      Num Ports   Used Ports  Configured Ports  MTU     Uplinks
vSwitch1         128         3           128               1500    vmnic1
  PortGroup Name        VLAN ID  Used Ports  Uplinks
  Ted Network           0        1           vmnic1
 # vsish -e get net/pNics/vmnic0/propertiesproperties {
   Driver Name:bnx2
   Driver Version:2.0.15g.v50.11-5vmw
   Driver Firmware Version:bc 5.2.3
   System Device Name:vmnic0
   Module Interface Used By The Driver:vmklinux
   Device Hardware Cap Supported:: 0x483c032b -> VMNET_CAP_SG VMNET_CAP_IP4_CSUM VMNET_CAP_HIGH_DMA VMNET_CAP_TSO VMNET_CAP_HW_TX_VLAN VMNET_CAP_HW_RX_VLAN VMNET_CAP_SG_SPAN_PAGES VMNET_CAP_IPV6_CSUM VMNET_CAP_TSO6 VMNET_CAP_TSO256k VMNET_CAP_OFFLOAD_16OFFSET VMNET_CAP_SCHED
   Device Hardware Cap Activated:: 0x83c032b -> VMNET_CAP_SG VMNET_CAP_IP4_CSUM VMNET_CAP_HIGH_DMA VMNET_CAP_TSO VMNET_CAP_HW_TX_VLAN VMNET_CAP_HW_RX_VLAN VMNET_CAP_SG_SPAN_PAGES VMNET_CAP_IPV6_CSUM VMNET_CAP_TSO6 VMNET_CAP_TSO256k VMNET_CAP_OFFLOAD_16OFFSET
   Device Software Cap Activated:: 0x34800000 -> VMNET_CAP_RDONLY_INETHDRS VMNET_CAP_OFFLOAD_8OFFSET
   PCI Bus:11
   PCI Slot:0
   PCI Fn:0
   PCI Vendor:0x14e4
   PCI Device ID:0x1639
   Interrupt Vector:0xc0
   Link Up:1
   Speed (Mb/s):1000
   Full Duplex:1
   Uplink Port ID:0x01000002
   Flags:: 0x1a0e -> DEVICE_PRESENT DEVICE_OPENED DEVICE_EVENT_NOTIFIED DEVICE_SCHED_CONNECTED DEVICE_RESPOOLS_SCHED_ALLOWED DEVICE_RESPOOLS_SCHED_SUPPORTED
   Network Hint:0 10.78.203.128/255.255.255.128
   MAC address:00:10:18:a7:76:88
   VLanHwTxAccel:1
   VLanHwRxAccel:1
   Queue Stopped:8
   Pseudo Device:0
   Respools sched allowed:1
   Respools sched supported:1
To view the ESXi host console interface
#dcui
1.      To power on a virtual machine from the command line:#vim-cmd vmsvc/getallvms
/sbin # vim-cmd vmsvc/getallvms
Vmid   Name          File             Guest OS      Version   Annotation
2      VM2    [nfs] VM2_1/VM2.vmx   winXPProGuest   vmx-08
4      VM1    [nfs] VM1/VM1.vmx     winXPProGuest   vmx-08
#vim-cmd vmsvc/getallvms | grep VM1
Vmid   Name          File             Guest OS      Version   Annotation
4      VM1    [nfs] VM1/VM1.vmx     winXPProGuest   vmx-08
Note: The first column of the output shows the vmid.
2.      Check the power state of the virtual machine with the command:#vim-cmd vmsvc/power.getstate <vmid>
    #  vim-cmd vmsvc/power.getstate 4
      Retrieved runtime info
Powered off
  1. Power-on the virtual machine with the command:vim-cmd vmsvc/power.on <vmid>
#  vim-cmd vmsvc/power.on 4
Powering on VM:
 #  vim-cmd vmsvc/power.getstate 4
Retrieved runtime info
Powered on

ESXi 4.1
To power on a virtual machine from the command line:
  1. List the inventory ID of the virtual machine with the command:vim-cmd vmsvc/getallvms |grep <vm name>
    Note: The first column of the output shows the vmid.
  2. Check the power state of the virtual machine with the command:vim-cmd vmsvc/power.getstate <vmid>
  3. Power-on the virtual machine with the command:vim-cmd vmsvc/power.on <vmid>
To view the vms guest os
#  vim-cmd vmsvc/get.guest 4
Guest information:

(vim.vm.GuestInfo) {
   dynamicType = <unset>,
   toolsStatus = "toolsOk",
   toolsVersionStatus = "guestToolsCurrent",
   toolsVersionStatus2 = "guestToolsCurrent",
   toolsRunningStatus = "guestToolsRunning",
   toolsVersion = "8384",
   guestId = "winXPProGuest",
   guestFamily = "windowsGuest",
   guestFullName = "Microsoft Windows XP Professional (32-bit)",
   hostName = "ciscovm1",
   ipAddress = "169.254.44.229",
   net = (vim.vm.GuestInfo.NicInfo) [
      (vim.vm.GuestInfo.NicInfo) {
         dynamicType = <unset>,
         network = "VM Network",
         ipAddress = (string) [
            "169.254.44.229"
         ],
         macAddress = "00:50:56:a7:34:5c",
         connected = true,
         deviceConfigId = 4001,
         dnsConfig = (vim.net.DnsConfigInfo) {
            dynamicType = <unset>,
            dhcp = false,
            hostName = "",
            domainName = "",
         },
         ipConfig = (vim.net.IpConfigInfo) {
            dynamicType = <unset>,
            ipAddress = (vim.net.IpConfigInfo.IpAddress) [
               (vim.net.IpConfigInfo.IpAddress) {
                  dynamicType = <unset>,
                  ipAddress = "169.254.44.229",
                  prefixLength = 16,
                  origin = "random",
                  state = "preferred",
                  lifetime = <unset>,
               }
            ],
            dhcp = (vim.net.DhcpConfigInfo) null,
            autoConfigurationEnabled = <unset>,
         },
         netBIOSConfig = (vim.net.NetBIOSConfigInfo) null,
      },
      (vim.vm.GuestInfo.NicInfo) {
         dynamicType = <unset>,
         network = "VM Network",
         ipAddress = (string) [
            "169.254.7.162"
         ],
         macAddress = "00:0c:29:61:59:32",
         connected = true,
         deviceConfigId = 4000,
         dnsConfig = (vim.net.DnsConfigInfo) {
            dynamicType = <unset>,
            dhcp = false,
            hostName = "",
            domainName = "",
         },
         ipConfig = (vim.net.IpConfigInfo) {
            dynamicType = <unset>,
            ipAddress = (vim.net.IpConfigInfo.IpAddress) [
               (vim.net.IpConfigInfo.IpAddress) {
                  dynamicType = <unset>,
                  ipAddress = "169.254.7.162",
                  prefixLength = 16,
                  origin = "random",
                  state = "preferred",
                  lifetime = <unset>,
               }
            ],
            dhcp = (vim.net.DhcpConfigInfo) null,
            autoConfigurationEnabled = <unset>,
         },
         netBIOSConfig = (vim.net.NetBIOSConfigInfo) null,
      }
   ],
   ipStack = (vim.vm.GuestInfo.StackInfo) [
      (vim.vm.GuestInfo.StackInfo) {
         dynamicType = <unset>,
         dnsConfig = (vim.net.DnsConfigInfo) null,
         ipRouteConfig = (vim.net.IpRouteConfigInfo) {
            dynamicType = <unset>,
            ipRoute = (vim.net.IpRouteConfigInfo.IpRoute) [
               (vim.net.IpRouteConfigInfo.IpRoute) {
                  dynamicType = <unset>,
                  network = "169.254.0.0",
                  prefixLength = 16,
                  gateway = (vim.net.IpRouteConfigInfo.Gateway) {
                     dynamicType = <unset>,
                     ipAddress = "169.254.44.229",
                     device = "0",
                  },
               },
               (vim.net.IpRouteConfigInfo.IpRoute) {
                  dynamicType = <unset>,
                  network = "169.254.0.0",
                  prefixLength = 16,
                  gateway = (vim.net.IpRouteConfigInfo.Gateway) {
                     dynamicType = <unset>,
                     ipAddress = "169.254.7.162",
                     device = "1",
                  },
               },
               (vim.net.IpRouteConfigInfo.IpRoute) {
                  dynamicType = <unset>,
                  network = "169.254.255.255",
                  prefixLength = 32,
                  gateway = (vim.net.IpRouteConfigInfo.Gateway) {
                     dynamicType = <unset>,
                     ipAddress = "169.254.44.229",
                     device = "0",
                  },
               },
               (vim.net.IpRouteConfigInfo.IpRoute) {
                  dynamicType = <unset>,
                  network = "169.254.255.255",
                  prefixLength = 32,
                  gateway = (vim.net.IpRouteConfigInfo.Gateway) {
                     dynamicType = <unset>,
                     ipAddress = "169.254.7.162",
                     device = "1",
                  },
               },
               (vim.net.IpRouteConfigInfo.IpRoute) {
                  dynamicType = <unset>,
                  network = "224.0.0.0",
                  prefixLength = 4,
                  gateway = (vim.net.IpRouteConfigInfo.Gateway) {
                     dynamicType = <unset>,
                     ipAddress = "169.254.44.229",
                     device = "0",
                  },
               },
               (vim.net.IpRouteConfigInfo.IpRoute) {
                  dynamicType = <unset>,
                  network = "224.0.0.0",
                  prefixLength = 4,
                  gateway = (vim.net.IpRouteConfigInfo.Gateway) {
                     dynamicType = <unset>,
                     ipAddress = "169.254.7.162",
                     device = "1",
                  },
               },
               (vim.net.IpRouteConfigInfo.IpRoute) {
                  dynamicType = <unset>,
                  network = "255.255.255.255",
                  prefixLength = 32,
                  gateway = (vim.net.IpRouteConfigInfo.Gateway) {
                     dynamicType = <unset>,
                     ipAddress = "169.254.44.229",
                     device = "0",
                  },
               },
               (vim.net.IpRouteConfigInfo.IpRoute) {
                  dynamicType = <unset>,
                  network = "255.255.255.255",
                  prefixLength = 32,
                  gateway = (vim.net.IpRouteConfigInfo.Gateway) {
                     dynamicType = <unset>,
                     ipAddress = "169.254.7.162",
                     device = "1",
                  },
               }
            ],
         },
         dhcpConfig = (vim.net.DhcpConfigInfo) null,
      }
   ],
   disk = (vim.vm.GuestInfo.DiskInfo) [
      (vim.vm.GuestInfo.DiskInfo) {
         dynamicType = <unset>,
         diskPath = "C:\",
         capacity = 10725732352,
         freeSpace = 7530975232,
      }
   ],
   screen = (vim.vm.GuestInfo.ScreenInfo) {
      dynamicType = <unset>,
      width = 640,
      height = 480,
   },
   guestState = "running",
   powerPolicy = (vim.vm.PowerPolicy) null,
   appHeartbeatStatus = "appStatusGray",
   guestOperationsReady = true,
   interactiveGuestOperationsReady = false,
}

No comments:

Post a Comment