esxi cli

最後更新: 2015-02-04

目錄

 


CPU Info

 

Check VT or AMD-V support

esxcfg-info|grep "HV Support"

~ # esxcfg-info|grep "HV Support"
         |----HV Support............................................3

0 - VT/AMD-V indicates that support is not available for this hardware.

1 - VT/AMD-V indicates that VT or AMD-V might be available but it is not supported for this hardware.

2 - VT/AMD-V indicates that VT or AMD-V is available but is currently not enabled in the BIOS.

3 - VT/AMD-V indicates that VT or AMD-V is enabled in the BIOS and can be used.

Check Number of CPU

esxcli hardware cpu global get

   CPU Packages: 1
   CPU Cores: 24
   CPU Threads: 48
   Hyperthreading Active: true
   Hyperthreading Supported: true
   Hyperthreading Enabled: true
   HV Support: 3

Check CPU Core Info

esxcli hardware cpu list

CPU:0                       # 會見到 48 Threads
   Id: 0
   Package Id: 0
   Family: 6
   Model: 85
   Type: 0
   Stepping: 7
   Brand: GenuineIntel
   Core Speed: 2194843642
   Bus Speed: 24941404
   APIC ID: 0x0
   Node: 0
   L2 Cache Size: 1048576
   L2 Cache Associativity: 16
   L2 Cache Line Size: 64
   L2 Cache CPU Count: 2
   L3 Cache Size: 37486592
   L3 Cache Associativity: 11
   L3 Cache Line Size: 64
   L3 Cache CPU Count: 48

CPU:1
    ...

VM

 

查看有什麼 vm:

vim-cmd vmsvc/getallvms

Vmid   Name        File                           Guest OS          Version   Annotation
1      vm.xp       [SATA_500G] vm.xp/vm.xp.vmx    winXPProGuest     vmx-08
29     NAS         [2TB_A] NAS/NAS.vmx            freebsdGuest      vmx-08

vim-cmd vmsvc/power.getstat vmid

Retrieved runtime info
Powered off

VM on | off | reset:

vim-cmd vmsvc/power.off vmid

vim-cmd vmsvc/power.on vmid

vim-cmd vmsvc/power.reset vmid

registervm:

vim-cmd solo/registervm /vmfs/vol/datastore/dir/vm.vmx

vim-cmd vmsvc/unregister vmid

maintenance_mode:

vim-cmd hostsvc/maintenance_mode_enter

vim-cmd hostsvc/maintenance_mode_exit

Other useful Opts:

  • get.config
  • get.capability
  • get.summary

 


Process

 

Usage:

esxcli [options] {namespace}+ {cmd} [cmd options]

# esxcli vm process list

NAS
   World ID: 65671
   Process ID: 0
   VMX Cartel ID: 65670
   UUID: 56 4d aa 6a f7 4d 34 d2-1e 4f 2a 3a 57 6e 2a 98
   Display Name: NAS
   Config File: /vmfs/volumes/506d38af-b9a08598-0abb-902b34980f6f/NAS/NAS.vmx

# esxcli vm process kill --type=[soft,hard,force] --world-id=WorldNumber

 


Network

 

# vim-cmd hostsvc/net/info

..................

 

# esxcfg-nics -l

Name    PCI           Driver      Link Speed     Duplex MAC Address       MTU    Description
vmnic0  0000:02:00.00 r8168       Up   100Mbps   Full   90:2b:34:98:0f:6f 1500   Realtek Realtek 8168 Gigabit Ethernet

 

# esxcfg-vswitch -l

Switch Name      Num Ports   Used Ports  Configured Ports  MTU     Uplinks
vSwitch0         128         8           128               1500    vmnic0

  PortGroup Name        VLAN ID  Used Ports  Uplinks
  VM Network            0        4           vmnic0
  Management Network    0        1           vmnic0

Switch Name      Num Ports   Used Ports  Configured Ports  MTU     Uplinks
vSwitch1         128         1           128               1500

  PortGroup Name        VLAN ID  Used Ports  Uplinks
  ClusterHeartbeat      0        0

 

  -a|--add                    Add a new virtual switch.
  -d|--delete                 Delete the virtual switch.

  -V|--dvp=dvport             Specify a DVPort Id for the operation.
  -p|--pg=portgroup           Specify a portgroup for operation

  -A|--add-pg=name            Add a new portgroup to the virtual switch.
  -D|--del-pg=name            Delete the portgroup from the virtual switch.

 

phy link:

  -L|--link=pnic                Set pnic as an uplink for the vswitch.
  -U|--unlink=pnic            Remove pnic from the uplinks for the vswitch.

  -M|--add-pg-uplink=uplink   Add an uplink to the list of uplinks for a portgroup
  -N|--del-pg-uplink=uplink   Delete an uplink from the list of uplinks for a portgroup

exist:

-C|--check-pg=name                            Check to see if a portgroup exists.

-c|--check <sw name>                         Check to see if a virtual switch exists.

vlan:

-v|--vlan=id                Set vlan id for portgroup specified by -p 0 would disable the vlan

route:

# esxcfg-route -l

VMkernel Routes:
Network          Netmask          Gateway          Interface
192.168.88.0     255.255.255.0    Local Subnet     vmk0
default          0.0.0.0          192.168.88.1     vmk0

# esxcfg-vmknic -l

Interface  Port Group/DVPort   IP Family IP Address       Netmask         Broadcast       MAC Address       MTU     TSO MSS   Enabled Type
vmk0       Management Network  IPv4      192.168.88.8     255.255.255.0   192.168.88.255  90:2b:34:98:0f:6f 1500    65535     true    STATIC

-a|--add

-d|--del

-e|--enable

-D|--disable

-i|--ip <X.X.X.X>

-n|--netmask <X.X.X.X>

-p|--portgroup                Setting portgroup as connection point

Example:

esxcfg-vmknic -a -i x.x.x.x -n 255.255.255.0 pgName

 

# Service:

chkconfig -l

iked           off
lsassd         off
lwiod          on
ntpd           on
ESXShell       on
DCUI           on
netlogond      off
SSH            on
usbarbitrator  on
rhttpproxy     on
vprobed        off
lbtd           on
storageRM      on
sensord        on
hostd          on
slpd           on
memscrubd      on
lacp           on
cdp            on
smartd         on
dcbd           on
vmamqpd        off
vobd           on
vpxa           on
sfcbd-watchdog on
snmpd          on
sfcbd          on
wsman          on
xorg           on

Example - Set IP

 

esxcfg-vswitch -l

Switch Name      Num Ports   Used Ports  Configured Ports  MTU     Uplinks
vSwitch0         128         4           128               1500    vmnic1

  PortGroup Name        VLAN ID  Used Ports  Uplinks
  202.85.138.x          0        1           vmnic1
  Management Network    0        1           vmnic1

Switch Name      Num Ports   Used Ports  Configured Ports  MTU     Uplinks
vSwitch1         128         7           128               1500    vmnic0

esxcfg-vswif -i a.b.c.d -n w.x.y.z vswif0

 


Set Gateway

 

esxcfg-route -h

-d|--del                   Delete route from the VMkernel.

-a|--add                   Add route to the VMkernel

Example:

# Set route

esxcfg-route -a 192.168.100.0/24 192.168.0.1

# Set default gw

esxcfg-route 192.168.0.1

Or

esxcfg-route -a default 192.168.0.1
 

P.S.

Only one vmkernel default gateway can be configured on an ESXi/ESX host.

In ESXi 5.0, static routes are not persistent across reboots. To ensure that any added static routes are persistent, add the command to the /etc/rc.local file

 


esxtop

 

esxtop

 5:10:35pm up 12 days 15:58, 344 worlds, 4 VMs, 6 vCPUs; CPU load average: 0.01, 0.01, 0.01
PCPU USED(%): 1.2 1.1  98  26 AVG:  31
PCPU UTIL(%): 0.0 0.0 100  35 AVG:  33

      ID      GID NAME             NWLD   %USED    %RUN    %SYS   %WAIT %VMWAI
       1        1 idle                4  222.10  400.00    0.00    0.00
 1256800  1256800 esxtop.746558       1  162.17   81.83    0.00    0.00
  105860   105860 vm.xp              10    0.47    0.44    0.00  817.67    1.1
  105792   105792 faxbox              7    0.22    0.21    0.00  572.59    0.0
  105778   105778 vm.ns3              7    0.18    0.22    0.00  572.67   16.2
 1256662  1256662 sshd.746481         1    0.15    0.14    0.00   81.75
  105852   105852 NAS                10    0.15    0.14    0.00  818.10   87.3
    2649     2649 openwsmand.5490     3    0.02    0.02    0.00  245.82
    2369     2369 vpxa.5330          19    0.02    0.02    0.00 1557.22
    1795     1795 hostd.5031         23    0.02    0.02    0.00 1886.35
    1459     1459 rhttpproxy.4860    14    0.02    0.01    0.00 1148.73
       2        2 system              9    0.00    0.00    0.00  739.34
       8        8 helper             80    0.00    0.00    0.00 6564.83
       9        9 drivers            12    0.00    0.00    0.00  983.98
      10       10 ft                  4    0.00    0.00    0.00  327.95
      11       11 vmotion             1    0.00    0.00    0.00   81.98
      49       49 vmkapimod          15    0.00    0.00    0.00 1229.53
     284      284 init.4224           1    0.00    0.00    0.00   81.97

Check Disk IO

d to switch to disk view HBA mode (per HBA basis)

 ADAPTR PATH                 NPTH   CMDS/s  READS/s WRITES/s MBREAD/s MBWRTN/s
 vmhba0 -                       1     0.00     0.00     0.00     0.00     0.00
 vmhba1 -                       1     0.00     0.00     0.00     0.00     0.00
vmhba32 -                       2     0.00     0.00     0.00     0.00     0.00
vmhba33 -                       1     0.00     0.00     0.00     0.00     0.00
vmhba34 -                       0     0.00     0.00     0.00     0.00     0.00

u to switch to disk view LUN mode(per-LUN basis)

DEVICE                                PATH/WORLD/PARTITION DQLEN WQLEN ACTV QU
t10.ATA_____ADATA_SU650_____________           -               1     -    0
t10.ATA_____ST1000DM0032D1SB10C_____           -               1     -    0
t10.ATA_____WDC_WD2000FYYZ2D01UL1B2_           -               1     -    0
t10.ATA_____WDC_WD20EARX2D00PASB0___           -               1     -    0
t10.ATA_____WDC_WD5000AAKX2D003CA0__           -               1     -    0

v to switch to disk view (virtual machine mode)

Fields

Press f to modify the fields that are displayed.

Press b, c, d, e, h, and j to toggle the fields and press Enter.

Refresh

Press s and then 2 to alter the update time to every 2 seconds and press Enter.

Sorting

Press 'N' to sort by VMNAME column.

CMDS/s     Commands/sec     Number of commands issued per second.

Input/Output Operations Per Second and other SCSI commands such as SCSI reservations,
locks, vendor string requests, unit attention commands etc.
In most cases, CMDS/s = IOPS unless there are a lot of metadata operations 
(such as SCSI reservations)

READS/s     Reads/sec     Number of read commands issued per second. (r)

WRITES/s     Writes/sec     Number of write commands issued per second.(w)

MBREAD/s     MBytes Read/sec     Megabytes read per second.(R)

MBWRTN/s     MBytes Written/sec     Megabytes written per second.(T)

 


# Vmware interactive shell

vsish

# errors

vmkerrcode -l

 

 


Check RAM

 

# ESXi5

smbiosDump | less

  Memory Device: #4352
    Location: "DIMM_A1"
    Manufacturer: "00CE04B380CE"
    Serial: "33CB2DC1"
    Asset Tag: "02122321"
    Part Number: "M393B5273DH0-YH9"
    Memory Array: #4096
    Form Factor: 0x09 (DIMM)
    Type: 0x18 (DDR3)
    Type Detail: 0x2080 (Synchronous, Registered)
    Data Width: 64 bits (+8 ECC bits)
    Size: 4 GB
    Speed: 1333 MHz

 

 


partedUtil

 

Version: ESXi 5.x

Deleting a partition

partedUtil delete "/vmfs/devices/disks/DeviceName" PartitionNumber

 


esxcli

 

Available Namespaces:
  esxcli                Commands that operate on the esxcli system itself allowing users to get additional information.
  fcoe                  VMware FCOE commands.
  hardware              VMKernel hardware properties and commands for configuring hardware.
  iscsi                 VMware iSCSI commands.
  network               Operations that pertain to the maintenance of networking on an ESX host. This includes a wide
                        variety of commands to manipulate virtual networking components (vswitch, portgroup, etc) as well
                        as local host IP, DNS and general host networking settings.
  sched                 VMKernel system properties and commands for configuring scheduling related functionality.
  software              Manage the ESXi software image and packages
  storage               VMware storage commands.
  system                VMKernel system properties and commands for configuring properties of the kernel core system.
  vm                    A small number of operations that allow a user to Control Virtual Machine operations.

 


Storage

 

Understanding Storage Device Naming

Each storage device, or LUN, is identified by several names

  • SCSI INQUIRY identifiers
  • Path-based identifier
  • Runtime Name

SCSI INQUIRY identifiers

  • naa.number
  • t10.number
  • eui.number

Path-based identifier

this identifier is neither unique nor persistent and could change after every boot.

i.e.

mpx.vmhba1:C0:T1:L3.

Runtime Name

i.e.

vmhbaAdapter:CChannel:TTarget:LLUN

vmhbaAdapter

the name of the storage adapter. The name refers to the physical adapter on the host, not to the SCSI controller used by the virtual machines.

CChannel

the storage channel number.

Software iSCSI adapters and dependent hardware adapters use the channel number to show multiple paths to the same target.

TTarget

the target number. Target numbering is determined by the host and might change if the mappings of targets visible to the host change. Targets that are shared by different hosts might not have the same target number.

LLUN

the LUN number that shows the position of the LUN within the target. The LUN number is provided by the storage system. If a target has only one LUN, the LUN number is always zero (0).

Check Name By CMD

esxcli storage core device list

naa.6782bcb0138478001f540cc410d12907
   Display Name: Local DELL Disk (naa.6782bcb0138478001f540cc410d12907)
   Has Settable Display Name: true
   Size: 7629824
   Device Type: Direct-Access
   Multipath Plugin: NMP
   Devfs Path: /vmfs/devices/disks/naa.6782bcb0138478001f540cc410d12907
   Vendor: DELL
   Model: PERC H700
   Revision: 2.10
   SCSI Level: 5
   Is Pseudo: false
   Status: on
   Is RDM Capable: false
   Is Local: true
   Is Removable: false
   Is SSD: false
   Is VVOL PE: false
   Is Offline: false
   Is Perennially Reserved: false
   Queue Full Sample Size: 0
   Queue Full Threshold: 0
   Thin Provisioning Status: unknown
   Attached Filters:
   VAAI Status: unsupported
   Other UIDs: vml.02000000006782bcb0138478001f540cc410d12907504552432048
   Is Shared Clusterwide: false
   Is Local SAS Device: false
   Is SAS: false
   Is USB: false
   Is Boot USB Device: false
   Is Boot Device: true
   Device Max Queue Depth: 128
   No of outstanding IOs with competing worlds: 32
   Drive Type: logical
   RAID Level: RAID6
   Number of Physical Drives: 4
   Protection Enabled: false
   PI Activated: false
   PI Type: 0
   PI Protection Mask: NO PROTECTION
   Supported Guard Types: NO GUARD SUPPORT
   DIX Enabled: false
   DIX Guard Type: NO GUARD SUPPORT
   Emulated DIX/DIF Enabled: false

esxcli storage core path list

unknown.vmhba1-unknown.2:0-naa.6782bcb0138478001f540cc410d12907
   UID: unknown.vmhba1-unknown.2:0-naa.6782bcb0138478001f540cc410d12907
   Runtime Name: vmhba1:C2:T0:L0
   Device: naa.6782bcb0138478001f540cc410d12907
   Device Display Name: Local DELL Disk (naa.6782bcb0138478001f540cc410d12907)
   Adapter: vmhba1
   Channel: 2
   Target: 0
   LUN: 0
   Plugin: NMP
   State: active
   Transport: parallel
   Adapter Identifier: unknown.vmhba1
   Target Identifier: unknown.2:0
   Adapter Transport Details: Unavailable or path is unclaimed
   Target Transport Details: Unavailable or path is unclaimed
   Maximum IO Size: 131072

esxcli storage vmfs extent list

Volume Name  VMFS UUID                            Extent Number  Device Name                                                   Partition
-----------  -----------------------------------  -------------  ------------------------------------------------------------  ---------
RAID6        57b8930b-a409c0a6-c88b-d4ae5275577e              0  naa.6782bcb0138478001f540cc410d12907                                  3

esxcli storage filesystem list

Mount Point                                        Volume Name  UUID                                 Mounted  Type             Size           Free
-------------------------------------------------  -----------  -----------------------------------  -------  ------  -------------  -------------
/vmfs/volumes/57b8930b-a409c0a6-c88b-d4ae5275577e  RAID6        57b8930b-a409c0a6-c88b-d4ae5275577e     true  VMFS-5  7992397266944  3275820630016

 


Netstat

 

esxcli network ip connection list