Вы находитесь на странице: 1из 65

VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

VMware ESXi esxcli Command:


A Quick Tutorial
Home > Virtualization > VMware ESXi esxcli Command: A Quick Tutorial

The esxcli is a command tool that is available on VMware ESXi for


managing ESXi. Unlike the vim-cmd command, it focuses on underlying
infrastructure and touches lower level of controls of the ESXi hypervisor
itself. Although it’s just one command, it packs a lot of functionalities with
different namespaces/sub-namespaces, and sub-commands. Because they
are organized in nice tree hierarchy, it’s actually quite easy to use most
times.

You can run the esxcli command directly in ESXi BusyBox Shell. For that
you will need to have either direct access to the ESXi console, or SSH to the
ESXi (you need to turn on the SSH Shell access). Should you have multiple
ESXi servers to run the commands simultaneously, try the free
DoubleCloud ICE I developed.

Time to learn how to "Google" and manage your VMware and clouds in a fast and secure
HTML5 App

Alternatively, you can install vCLI on Windows or Linux from where you
want to remotely manage ESXi servers. If you don’t want to install the
package by yourself, you can download the vMA virtual appliance which
has everything pre-installed and pre-configured. When you run the
command this way, there is additional parameters for remote ESXi server
address and credential. Other than that, the command syntax should be the
same as native esxcli command.

There is actually another choice which is not documented but I digged it


out anyway – You can run esxcli command in a browser. If you are
interested, you can check out this post. Note that this is not supported by

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 1 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

VMware.

This tutorial will guide you through all functionalities with samples and
tips/tricks assuming we are using the native esxcli command. Given the
complexity of the command, I cannot run all the combinations of
parameters, please feel free to use the help and try by yourself when you
cannot find exact sample. Should you find something worth sharing, please
feel free to post them in the comments.

Where Is It Installed?
The esxcli command utility comes with the ESXi installation. If you type in
the following commands you will find where it’s installed. Even more is
that you will uncover the a little secret of esxcli – it’s essentially a Python
script. If you are interested in what is in the script, you can simply check it
out with vi command. We’ll not dig deeper there, but focus on the usage of
the command as a user.

~ # which esxcli
/sbin/esxcli
~ # ls -l /sbin/esxcli
lrwxrwxrwx 1 root root 15 Aug 2 2012 /sbin/esxcli -> /sbin

What You Can Do With It?


Unlike the vim-cmd command which mainly focuses on the virtual
machine related management, the esxcli focuses on the infrastructure like
hardware, storage, networking, esxi software, etc.

Typing the esxcli command without any argument will displays the
command usage. With the options, you can control the format of the
output to be xml, csv, key/value pair, or json.

The esxcli command is a very complex command that achieve a lot given

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 2 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

it’s a single command. To help user to use the command without getting
confused, the namespaces are used to group the commands. The
namespaces can be further divided into sub-namespaces depending the
complexity.

The following command shows the top level namespaces, each of which can
be nicely mapped to a group of functionality. Just reading description of
these commands should give you an idea on what esxcli can do for you.
We’ll dig deeper into each of them in the following sections.

~ # esxcli
Usage: esxcli [options] {namespace}+ {cmd} [cmd options]

Options:
--formatter=FORMATTER
Override the formatter to use for a given command.
Available formatter: xml, csv, keyvalue
--debug Enable debug or internal use options
--version Display version information for the script
-?, --help Display usage information for the script

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.

A bit more on the format. In the interactive mode, the default format of

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 3 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

output is perfect. If you use the esxcli command for automation, other
formats may be preferred. For example, the CSV can be easily imported
into Excel or other spreadsheet for reporting and analytics. The XML is
very good for data exchange. The key and value pairs are good shell script
to consume. There are actually undocumented formats as I blogged about a
while back.

High Level Conventions


In some way, the esxcli namespaces are like Java packages. At certain
points down the namespace hierarchy, you can find available commands
(think of them as methods on a class). One big difference is that there can
be commands on a non-leaf namespace. Simply entering the full esxcli and
namespace path will show both available namespaces and available
commands.

The commands are mostly verbs as follows:

* list – retrieve a list of the objects that are represented by the namespace
* get – get information like property
* set – set a value
* load/unload – load/unload configuration

Note that they are not necessarily available in all the namespaces. When in
double, always checkout the command line.

Depending on the command, there may be additional options specific to


the command. These options are different from the general options which
are always available for all commands.

Without further due, let’s jump to the sub-commands one by one.

Listing All esxcli Namespaces and


Commands
http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 4 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

Interestingly, the esxcli can also be a sub command to the esxcli command
itself. What it does is very simple — list all the available namespaces and
their commands. Because there are so many lines in the output, I will just
show you the first few lines. You can easily find out in your SSH to ESXi.

~ # esxcli esxcli command


Usage: esxcli esxcli command {cmd} [cmd options]

Available Commands:
list This command will list all of the esxcli commands with their na
object, command name and description.
~ # esxcli esxcli command list
Namespace Command
------------------------------------------------------ -----------
esxcli.command list
fcoe.adapter list
fcoe.nic disable
fcoe.nic discover
fcoe.nic list
hardware.bootdevice list
hardware.clock get
hardware.clock
...

Now, let’s take a look how to interpret the output. For each line, there is a
corresponding esxcli command. Let’s pick up the second line
“fcoe.adapter.” The related command is like the following:

$ esxcli fcoe adapter list

The rule of thumb is to replace the dot with space and combine string
together with top esxcli command and last command. For some
commands, there are additional parameters, you may need to add there.
For the list command, it’s mostly fine without additional parameters except
the format as we discussed earlier.

Managing Fiber Channel Over Ethernet

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 5 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

(FCOE)
We will not cover FCOE here as there are many good introduction already.
Check out Cormac’s blog.

The following command shows it has two name spaces: adapter and nic.

~ # esxcli fcoe
Usage: esxcli fcoe {cmd} [cmd options]

Available Namespaces:
adapter Operations that can be performed on FCOE-type storage HBAs
nic Operations that can be performed on FCOE-capable CNA devices

To list adapters, you can use the following command:

# esxcli fcoe adapter list

I don’t have a FCOE adapter in my home lab, but got a sample out from
VMware KB article here for each adapter:

vmhba35
Source MAC: bc:30:5b:01:82:3c
FCF MAC: 00:05:73:bf:48:33
VNPort MAC: 0e:fc:00:47:02:24
Physical NIC: vmnic8
User Priority: 3
VLAN id: 2008

For the NIC namespace, there are more commands available:

~ # esxcli fcoe nic


Usage: esxcli fcoe nic {cmd} [cmd options]

Available Commands:
disable Disable rediscovery of FCOE storage on behalf of an FCOE-capabl
next boot.
discover Initiate FCOE adapter discovery on behalf of an FCOE-capable CN

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 6 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

list List FCOE-capable CNA devices.

Here are the sample commands: (Again, the output sample from above KB
article)

# esxcli fcoe nic list

vmnic4
User Priority: 3
Source MAC: FF:FF:FF:FF:FF:FF
Active: false
Priority Settable: false
Source MAC Settable: false
VLAN Range Settable: false

~ # esxcli fcoe nic discover -n vmnic1


PNIC "vmnic1" is not FCoE-capable

~ # esxcli fcoe nic disable -n vmnic4


PNIC "vmnic4" is not FCoE-capable

Managing Hardware
All the hardware related commands fit in the hardware namespace. As you
can see the following output, you can retrieve information or manage
various aspects of the hardware including cpu, ipmi, boot device, clock,
memory, pci, platform (a little vague term, but will elaborate more soon),
trusted boot.

Because hardware is hard, you cannot do much about it but retrieving the
information about these components or aspects. So the list command is the
most commonly used in this category.

~ # esxcli hardware
Usage: esxcli hardware {cmd} [cmd options]

Available Namespaces:
cpu CPU information.
ipmi IPMI information.

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 7 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

bootdevice Boot device information.


clock Interaction with the hardware clock.
memory Memory information.
pci PCI device information and configuration.
platform Platform information.
trustedboot Information about the status of trusted boot.

The following command lists the CPU related information. There are 8
cores, but I just show 2 core inforation here – the rest 6 is pretty much the
same.

~ # esxcli hardware cpu list


CPU:0
Id: 0
Package Id: 0
Family: 6
Model: 58
Type: 0
Stepping: 9
Brand: GenuineIntel
Core Speed: 3392293892
Bus Speed: 99773344
APIC ID: 0x0
Node: 0
L2 Cache Size: 262144
L2 Cache Associativity: 8
L2 Cache Line Size: 64
L2 Cache CPU Count: 2
L3 Cache Size: 8388608
L3 Cache Associativity: 16
L3 Cache Line Size: 64
L3 Cache CPU Count: 2

CPU:1
Id: 1
Package Id: 0
Family: 6
Model: 58
Type: 0
Stepping: 9
Brand: GenuineIntel
Core Speed: 3392293892
Bus Speed: 99773344
APIC ID: 0x1
Node: 0
L2 Cache Size: 262144
L2 Cache Associativity: 8

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 8 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

L2 Cache Line Size: 64


L2 Cache CPU Count: 2
L3 Cache Size: 8388608
L3 Cache Associativity: 16
L3 Cache Line Size: 64
L3 Cache CPU Count: 2

IPMI stands for Intelligent Platform Management Interface


(http://en.wikipedia.org/wiki/Intelligent_Platform_Management_Interfa
ce). It allows remotely managing the server over IP network. From the
esxcli commmand, you can further manage the Field Replaceable Unit,
Sensor Data Repository, and System event log.

~ # esxcli hardware ipmi


Usage: esxcli hardware ipmi {cmd} [cmd options]

Available Namespaces:
fru Information from IPMI Field Replaceable Unit inventory (
sdr Information from IPMI Sensor Data Respository (SDR).
sel Information from IPMI System Event Log (SEL).

My server in use does not have the IPMI support, so the following
commands return nothing or empty values. If you have enabled servers,
you will see more with the same commands.

~ # esxcli hardware ipmi fru


Usage: esxcli hardware ipmi fru {cmd} [cmd options]

Available Commands:
get Get IPMI Field Replaceable Unit (FRU) device details.
list List IPMI Field Replaceable Unit (FRU) inventory.
~ # esxcli hardware ipmi fru list
~ # esxcli hardware ipmi fru get
Device IDs:
Features:
Raw:
Sizebytes:
~ # esxcli hardware ipmi sdr get
Feature:
Free Space:
Last Added:
Last Cleared:

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 9 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

Raw:
Total Records:
Version:
~ # esxcli hardware ipmi sdr list
~ # esxcli hardware ipmi sel get
Enabled:
Last Added:
Last Cleared:
Maximum Records:
Overflow:
Raw:
Sel Clock:
Total Records:
Version:
~ # esxcli hardware ipmi sel list

Listing the boot devices is supported with the bootdevice namespace as


follows. Interestingly, the output lists nothing – the server did boot
successfully.

~ # esxcli hardware bootdevice list

Every computer has a clock. With esxcli command, you can get the time on
the clock, and change the time on the clock. The parameters to set up new
time is a little tricky, but using the help should be very easy. You can set
individual component of the time, say year, month, etc.

~ # esxcli hardware clock get


2015-04-19T01:49:44Z
~ # esxcli hardware clock set
You must specify one of year, month, day, hour, minute or second
~ # esxcli hardware clock set 2015
Error: Unknown command or namespace hardware clock set 2015

~ # esxcli hardware clock set --help


Usage: esxcli hardware clock set [cmd options]

Description:
set Set the hardware clock time. Any missing parameters will defaul
current time.

Cmd options:

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 10 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

-d|--day= Day
-H|--hour= Hour
-m|--min= Minute
-M|--month= Month
-s|--sec= Second
-y|--year= Year
~ # esxcli hardware clock set -y 2015

Retrieving the physical memory of ESXi server is very simple with the
following command. It also shows the NUMA node count.

~ # esxcli hardware memory get


Physical Memory: 12845969408 Bytes
NUMA Node Count: 1

PCI information can be retrieved with the pci name space as follows. The
output is pretty long, so I just include the first device. With the long output,
you can pipeline it to grep command for exact information you are
interested in.

~ # esxcli hardware pci list


000:000:00.0
Address: 000:000:00.0
Segment: 0x0000
Bus: 0x00
Slot: 0x00
Function: 0x00
VMkernel Name:
Vendor Name: Intel Corporation
Device Name: Ivy Bridge DRAM Controller
Configured Owner: Unknown
Current Owner: VMkernel
Vendor ID: 0x8086
Device ID: 0x0150
SubVendor ID: 0x17aa
SubDevice ID: 0x364e
Device Class: 0x0600
Device Class Name: Host bridge
Programming Interface: 0x00
Revision ID: 0x09
Interrupt Line: 0xff
IRQ: 255
Interrupt Vector: 0x00

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 11 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

PCI Pin: 0x74


Spawned Bus: 0x00
Flags: 0x0200
Module ID: -1
Module Name: None
Chassis: 0
Physical Slot: 255
Slot Description:
Passthru Capable: false
Parent Device:
Dependent Device:
Reset Method: None
FPT Sharable: false

Now it’s time for the vague platform namespace. Let’s start with the
command itself. With that, I don’t need to explain what the platform is.

~ # esxcli hardware platform get


Platform Information
UUID: 0x7a 0x9d 0x99 0xec 0x9d 0xa9 0x11 0xe1 0xaf 0x78 0xb8 0xfd 0x56 0x1b 0x2a 0x0
Product Name: IdeaCentre K430
Vendor Name: LENOVO
Serial Number: ES09832596
IPMI Supported: false

Last one in the hardware is the trusted boot. Again, my server does not
have the feature. For more details on the technology, check out this wiki
page: http://en.wikipedia.org/wiki/Trusted_Execution_Technology

~ # esxcli hardware trustedboot get


Drtm Enabled: false
Tpm Present: false

ESXi Kernel Scheduling


With the sched namespace, we can manage VMKernel system properties
and configure scheduling related functionality like swapping.

~ # esxcli sched swap system

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 12 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

Usage: esxcli sched swap system {cmd} [cmd options]

Available Commands:
get Get current state of the options of the system-wide shared
swap space.
set Change the configuration of system-wide shared swap space.
~ # esxcli sched swap system get
Datastore Active: false
Datastore Enabled: false
Datastore Name:
Datastore Order: 0
Hostcache Active: false
Hostcache Enabled: true
Hostcache Order: 1
Hostlocalswap Active: false
Hostlocalswap Enabled: true
Hostlocalswap Order: 2

The changing of properties is through the set command. You can change
one or more properties at a time with the switches as listed below.

~ # esxcli sched swap system set --help


Usage: esxcli sched swap system set [cmd options]

Description:
set Change the configuration of system-wide shared swap space.

Cmd options:
-d|--datastore-enabled
If the datastore option should be enabled or not.
-n|--datastore-name=
The name of the datastore used by the datastore option.
-D|--datastore-order=
The order of the datastore option in the preference of the
options
-c|--hostcache-enabled
If the host cache option should be enabled or not.
-C|--hostcache-order=
The order of the host cache option in the preference of
the options.
-l|--hostlocalswap-enabled
If the host local swap option should be enabled or not.
-L|--hostlocalswap-order=
The order of the host local swap option in the preference
of the options.

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 13 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

Managing VIB Software


The design of ESXi is to keep the hypervisor as small as possible. Being
small has many benefits, for example, less exposure to security attacks. At
the same time, we need some flexibility to install new drivers or other
software agents on the ESXi. This allows VMware partners to customize
the system and extend the system with additional functionalities.

For that purpose, VMware created VIB format based on a Linux package
system. It has related SDK for others to build the VIB. The commands in
this section is about how to manage the VIBs with command line.

~ # esxcli software
Usage: esxcli software {cmd} [cmd options]

Available Namespaces:
sources Query depot contents for VIBs and image profiles
acceptance Retrieve and set the host acceptance level setting
profile Display, install, update or validates image profiles
vib Install, update, remove, or display individual VIB
packages

You can use the sources namespace to “browse” the VIB packages in a VIB
depot. Before running the command, you want to modify firewall to allow
HTTP client.

~ # esxcli network firewall ruleset set -e true -r httpClient


~ # esxcli software sources vib list -d http://vibsdepot.v-front.de
Name Version Vendor Creation Date Accep
---------------------------- ------------------------- -------- -------------
sata-xahci 1.28-1 VFrontDe 2015-02-20 Commu
sata-xahci 1.25-1 VFrontDe 2014-11-23 Commu
sata-xahci 1.24-1 VFrontDe 2014-09-06 Commu
sata-xahci 1.16-1 VFrontDe 2014-04-12 Commu
...

In this sample, I used the v-front.de which has a rich collection of VIBs. In
your company, you may have your own VIB depot.
http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 14 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

If you use the get command, you will get a lot more details than the list.
The following shows one part of the long output.

~ # esxcli software sources vib get -d http://vibsdepot.v-front.de


VFrontDe_bootbank_sata-xahci_1.28-1
Name: sata-xahci
Version: 1.28-1
Type: bootbank
Vendor: VFrontDe
Acceptance Level: CommunitySupported
Summary: Adds mappings for unsupported SATA AHCI controllers
Description: Adds mappings for unsupported SATA AHCI controllers
ReferenceURLs: kb|http://vibsdepot.v-front.de/wiki/index.php/Sata-xahci
Creation Date: 2015-02-20
Depends: sata-ahci
Conflicts:
Replaces:
Provides:
Maintenance Mode Required: True
Hardware Platforms Required:
Live Install Allowed: False
Live Remove Allowed: False
Stateless Ready: True
Overlay: False
Tags:
Payloads: sata-xah

This blog post has excellent introduction and more sample commands.

You can list the image profiles as follows. I intentionally used ESXi-6.0 for
grep, or will get a lot more lines in output. Again, it connects to external
site and you want to open firewall before this.

~ # esxcli software sources profile list -d https://hostupdate.vmware.com/software/VUM/


ESXi-6.0.0-20150404001-no-tools VMware, Inc. PartnerSupported
ESXi-6.0.0-20150404001-standard VMware, Inc. PartnerSupported
ESXi-6.0.0-2494585-no-tools VMware, Inc. PartnerSupported
ESXi-6.0.0-2494585-standard VMware, Inc. PartnerSupported

To find out the exact content in an image profile:

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 15 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

~ # esxcli software sources profile get -d https://hostupdate.vmware.com/software/VUM/P

Supposedly you can download a zip and point the depot to it as follows.
Somehow it does not work even though I had the full path to the zip file as
recommended by a few bloggers.

~ # esxcli software sources profile list -d /vmfs/volumes/datastore1/ESXi510-201406001.


[MetadataDownloadError]
Could not download from depot at zip:/vmfs/volumes/datastore1/ESXi510-201406001
url = zip:/vmfs/volumes/datastore1/ESXi510-201406001.zip?index.xml
Please refer to the log file for more details.

The error message is not true because the zip file seems a valid zip file (not
all output lines are listed)

~ # unzip -l /vmfs/volumes/datastore1/ESXi510-201406001.zip
Archive: /vmfs/volumes/datastore1/ESXi510-201406001.zip
Length Date Time Name
-------- ---- ---- ----
319 06-14-14 15:45 index.xml
207 06-14-14 15:45 vendor-index.xml
80403 06-14-14 15:45 metadata.zip
177231686 04-14-14 07:31 vib20/tools-light/VMware_locker_tools-light_5.1.0-2.28.1743
63758 08-01-12 20:49 vib20/scsi-bnx2i/VMware_bootbank_scsi-bnx2i_1.9.1d.v50.1-5v

ESXi has different level of acceptance for installing new VIBs. Changing
acceptance levels enables installing VIBs from other vendors possible.

~ # esxcli software acceptance


Usage: esxcli software acceptance {cmd} [cmd options]

Available Commands:
get Gets the host acceptance level. This controls what VIBs will be
set Sets the host acceptance level. This controls what VIBs will be

~ # esxcli software acceptance get


PartnerSupported

~ # esxcli software acceptance set --level CommunitySupported

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 16 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

Host acceptance level changed to 'CommunitySupported'.

The level must be one of the values: VMwareCertified, VMwareAccepted,


PartnerSupported, CommunitySupported. The acceptance level decides if
some packages can be installed or not. From VMwareCertified to
CommunitySupported, the criteria loosens up.

Different VIBs combined together forms a big collection called image


profile. To manage image profile, the following commands can be used:

~ # esxcli software profile


Usage: esxcli software profile {cmd} [cmd options]

Available Commands:
get Display the installed image profile.
install Installs or applies an image profile from a depot to this host.
completely replaces the installed image with the image defined
profile, and may result in the loss of installed VIBs. The comm
and image profile will be skipped. To preserve installed VIBs,
instead. WARNING: If your installation requires a reboot, you n
first.
update Updates the host with VIBs from an image profile in a depot. In
upgraded (or downgraded if --allow-downgrades is specified
removed. Any VIBs in the image profile which are not related to
will be added to the host. WARNING: If your installation requir
to disable HA first.
validate Validates the current image profile on the host against an imag

~ # esxcli software profile get


ESXi-5.1.0-799733-standard
Name: ESXi-5.1.0-799733-standard
Vendor: VMware, Inc.
Creation Time: 2012-12-16T13:24:21
Modification Time: 2015-04-19T13:06:04
Stateless Ready: True
Description:

The general availability release of VMware ESXi Server 5.1.0


brings whole new levels of virtualization performance to
datacenters and enterprises.

VIBs: ata-pata-amd 0.3.10-3vmw.510.0.0.799733, ata-pata-atiixp 0.4.6-4vmw.510.0.0.79

~ # esxcli software vib


Usage: esxcli software vib {cmd} [cmd options]

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 17 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

Available Commands:
get Displays detailed information about one or more installed VIBs
install Installs VIB packages from a URL or depot. VIBs may be installe
downgraded. WARNING: If your installation requires a reboot, yo
first.
list Lists the installed VIB packages
remove Removes VIB packages from the host. WARNING: If your installati
you need to disable HA first.
update Update installed VIBs to newer VIB packages. No new VIBs will b
updates. WARNING: If your installation requires a reboot, you n
first.

It’s quite easy to list all the VIBs installed on the system. The following
shows the command and part of output.

~ # esxcli software vib list


Name Version Vendor Acceptance L
----------------------------- ---------------------------------- ------ ------------
ata-pata-amd 0.3.10-3vmw.510.0.0.799733 VMware VMwareCertif
ata-pata-atiixp 0.4.6-4vmw.510.0.0.799733 VMware VMwareCertif
ata-pata-cmd64x 0.2.5-3vmw.510.0.0.799733 VMware VMwareCertif
ata-pata-hpt3x2n 0.3.4-3vmw.510.0.0.799733 VMware VMwareCertif
ata-pata-pdc2027x 1.0-3vmw.510.0.0.799733 VMware VMwareCertif
ata-pata-serverworks 0.4.3-3vmw.510.0.0.799733 VMware VMwareCertif
ata-pata-sil680 0.4.8-3vmw.510.0.0.799733 VMware VMwareCertif
ata-pata-via 0.3.3-2vmw.510.0.0.799733 VMware VMwareCertif
block-cciss 3.6.14-10vmw.510.0.0.799733 VMware VMwareCertif
ehci-ehci-hcd 1.0-3vmw.510.0.0.799733 VMware VMwareCertif
esx-base 5.1.0-0.0.799733 VMware VMwareCertif
esx-dvfilter-generic-fastpath 5.1.0-0.0.799733 VMware VMwareCertif
esx-tboot 5.1.0-0.0.799733 VMware VMwareCertif
esx-xlibs 5.1.0-0.0.799733 VMware VMwareCertif
...

To get more details of a specific VIB, you can use the get command as
follows with the VIB name.

~ # esxcli software vib get -n net-e1000e


VMware_bootbank_net-e1000e_1.1.2-3vmw.510.0.0.799733
Name: net-e1000e
Version: 1.1.2-3vmw.510.0.0.799733
Type: bootbank
Vendor: VMware

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 18 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

Acceptance Level: VMwareCertified


Summary: e1000e: net driver for VMware ESX
Description: Intel(R) PRO/1000 PCI-E Network Driver
ReferenceURLs:
Creation Date: 2012-08-02
Depends: vmkapi_2_1_0_0, com.vmware.driverAPI-9.2.1.0
Conflicts:
Replaces:
Provides:
Maintenance Mode Required: True
Hardware Platforms Required:
Live Install Allowed: False
Live Remove Allowed: False
Stateless Ready: True
Overlay: False
Tags: driver, module
Payloads: net-e100

To install a VIB, you should install command with VIB locations. For the
VIB not signed, you want to turn off the signature checking with –no-sig-
check option. WARNING: If your installation requires a reboot, you need
to disable HA first.

$ esxcli software vib install -v /tmp/doublecloud-latest.vib --no-sig-check

To remove a VIB, just use the remove command.


$ esxcli software vib remove -n doublecloud

iSCSI Management
iSCSI allows ESXi to use storages on remote iSCSC servers. The esxcli
command can help to manage this feature on different layers in the stack.
Again, I don’t have the set up with iSCSI support. Instead of real
commands, the following commands shows mostly the help so that you can
see what are theree.

~ # esxcli iscsi
Usage: esxcli iscsi {cmd} [cmd options]

Available Namespaces:

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 19 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

adapter Operations that can be performed on iSCSI adapters


networkportal Operations that can be performed on iSCSI Network Portal
physicalnetworkportal Operations that can be performed on iSCSI Physical Network Port
session Operations that can be performed on iSCSI sessions
ibftboot Operations that can be performed on iSCSI IBFT boot table
logicalnetworkportal Operations that can be performed on iSCSI Logical Network Porta
plugin Operations that can be performed on iSCSI management plugins
software Operations that can be performed on software iSCSI

~ # esxcli iscsi adapter


Usage: esxcli iscsi adapter {cmd} [cmd options]

Available Namespaces:
auth Operations that can be performed on iSCSI adapter authenticatio
discovery Operations that can be performed on iSCSI adapter discovery
target Operations that can be performed on iSCSI targets
capabilities Operations that can be performed on iSCSI adapter capabilities
firmware Operations that can be performed on iSCSI adapter firmware
param Operations that can be performed on iSCSI adapter parameters

Available Commands:
get List the iSCSI information for the iSCSI Host Bus Adapter.
list List all the iSCSI Host Bus Adapters on the system.
set Set the iSCSI name and alias for the iSCSI Host Bus Adapter.
~ # esxcli iscsi software
Usage: esxcli iscsi software {cmd} [cmd options]

Available Commands:
get Software iSCSI information.
set Enable or disable software iSCSI.
~ # esxcli iscsi software get
false

Network Management
ESXi has a rich set of features in networking. All the network related
commands are grouped in the network namespace. To take a look at what
are available there, simply type in:

~ # esxcli network
Usage: esxcli network {cmd} [cmd options]

Available Namespaces:
fence Commands to list fence information
firewall A set of commands for firewall related operations

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 20 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

ip Operations that can be performed on vmknics


nic Operations having to do with the configuration of
Network Interface Card and getting and updating the
NIC settings.
port Commands to get information about a port
sriovnic Operations having to do with the configuration of
SRIOV enabled Network Interface Card and getting and
updating the NIC settings.
vm A set of commands for VM related operations
vswitch Commands to list and manipulate Virtual Switches on an
ESX host.
diag Operations pertaining to network diagnostics

As you can find there are more sub-namespaces, each of which is still a big
topic of itself.

Firewall Management
To find out the current firewall status, get command is the way to go:

~ # esxcli network firewall get


Default Action: DROP
Enabled: false
Loaded: true

Firewall module can be unloaded or loaded using the unload and load
command as follows:

~ # esxcli network firewall unload


~ # esxcli network firewall load

When firewall working, you can enable and disable the firewall as follows.
You want to keep the firewall enabled all the time.

~ # esxcli network firewall set --enabled true


~ # esxcli network firewall set --enabled false

You can also set the default action of firewall to let pass everything or block
http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 21 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

everything. When true is used, the firewall lets go everything unless


specified otherwise; when false is used, it blocks everything by default.

~ # esxcli network firewall set --default-action=true


~ # esxcli network firewall set --default-action=false

After you change firewall configuration, the ruleset may be out of sync with
the active. To keep in sync, you can simply run the refresh command.

~ # esxcli network firewall refresh

Above is the overall control of firewall. You can fine tune each individual
rule set within the ruleset namespace.

~ # esxcli network firewall ruleset list


Name Enabled
------------------ -------
sshServer true
sshClient true
nfsClient true
dhcp true
dns true
snmp true
ntpClient false
CIMHttpServer true
CIMHttpsServer true
CIMSLP true
iSCSI false
vpxHeartbeats true
updateManager false
faultTolerance true
webAccess true
vMotion true
vSphereClient true
activeDirectoryAll false
NFC true
HBR true
ftpClient false
httpClient true
gdbserver false
DVFilter false
DHCPv6 true

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 22 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

DVSSync false
syslog false
IKED false
WOL true
vSPC false
remoteSerialPort false
vprobeServer false

You can change individual ruleset to be enabled or disabled, and change


the behavior to all all IP addresses or only those specified.

~ # esxcli network firewall ruleset set --ruleset-id=syslog --enabled true --allowed-al

Each ruleset consists of a collection of rules. You can list them using rule
namespace. If you don’t provide ruleset-id as follows, you will get a long
list of rules from all the rulesets.

~ # esxcli network firewall ruleset rule list --ruleset-id syslog


Ruleset Direction Protocol Port Type Port Begin Port End
------- --------- -------- --------- ---------- --------
syslog Outbound UDP Dst 514 514
syslog Outbound TCP Dst 514 514
syslog Outbound TCP Dst 1514 1514

~ # esxcli network firewall ruleset allowedip add --ruleset-id syslog --ip-address=10.2


~ # esxcli network firewall ruleset allowedip list --ruleset-id syslog
Ruleset Allowed IP Addresses
------- --------------------
syslog 10.20.30.1

~ # esxcli network firewall ruleset allowedip remove --ruleset-id syslog --ip-address=1

Note that even with the powerful esxcli command, you can not modify
much of the firewall configurations. For all the configurations, you want to
go directly edit the configuration file then refresh the firewall:

~ # vi /etc/vmware/service/service.xml

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 23 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

Managing Fencing Switches


For this feature, you must distributed virtual switch configured; or you will
see the same output as I saw here.

~ # esxcli network fence list


Unable to find vds with fence enabled

To get all fence network bridge table entries information, you can use the
following command.

~ # esxcli network fence network bte list --vds-name lab-switch1 --fence-id 10

To get all fence port info on the fence network, you can use the following
command:

~ # esxcli network fence network bte list --vds-name lab-switch1 --fence-id 10

Managing IP Addresses and Configurations


To get the IPv6 related support, simply type the following.

~ # esxcli network ip get


IPv6Enabled: true

To turn off or turn on IPv6 support, you can use the set command. Note:
you have to restart the ESXi for the configuration to take effect.

~ # esxcli network ip set --ipv6-enabled false

To manage vmKernel network interfaces, you can use the interface


namespace as follows:

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 24 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

# esxcli network ip interface add -i vmk3 -p bootPG


~ # esxcli network ip interface ipv4 get
Name IPv4 Address IPv4 Netmask IPv4 Broadcast Address Type DHCP DNS
---- ------------- ------------- -------------- ------------ --------
vmk0 192.168.0.201 255.255.255.0 192.168.0.255 STATIC false

To change the IP address for ESXi on an existing interface is easy too, but
be careful with this operation because your SSH session may be terminated
immediately.

# esxcli network ip interface ipv4 set -i vmk3 -I 192.168.2.2 -N 255.255.255.0 -t

Managing DNS server

The ESXi depends on the DNS setting to resolve server names. The
following commands help manage the DNS.

~ # esxcli network ip dns server add -s 8.8.8.8


~ # esxcli network ip dns server list
DNSServers: 192.168.0.1, 8.8.8.8
~ # esxcli network ip dns server remove -s 8.8.8.8

You also change the default search domain for the DNS settings.

~ # esxcli network ip dns search add -d doublecloud.net


~ # esxcli network ip dns search list
DNSSearch Domains: doublecloud.net
~ # esxcli network ip dns search remove -d doublecloud.net

Network Security

There are two aspects you can manage the security: security association,
and security policy. There are quite a few options you can tune. Combined
together, they can cover a lot of cases.

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 25 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

~ # esxcli network ip ipsec sa add --help


Usage: esxcli network ip ipsec sa add [cmd options]

Description:
add Add a Security Association.

Cmd options:
-e|--encryption-algorithm=
Encryption algorithm for the Security Association. Should be on
cbc, aes128-cbc]. (required)
-k|--encryption-key=
Encryption key(ASCII or hex). Length of hex key is dependent up
Required when a encryption algorithm has been specified.
-i|--integrity-algorithm=
Integrity algorithm for the Security Association. Should be one
hmac-sha2-256]. (required)
-K|--integrity-key=
Integrity key(ASCII or hex). Length of hex key is dependent upo
(required)
-d|--sa-destination=
Ipv6 address of Security Association destination. Can be specif
correct IPv6 address. (required)
-m|--sa-mode= Security Association mode. Should be one in set [transport, tunnel
-n|--sa-name= Name for the Security Association to be added. (required)
-s|--sa-source= Ipv6 address of Security Association source. Can be specified
IPv6 address. (required)
-p|--sa-spi= SPI value for the Security Association(hex). (required)

~ # esxcli network ip ipsec sp add --help


Usage: esxcli network ip ipsec sp add [cmd options]

Description:
add Add a Security Policy.

Cmd options:
-A|--action= Action for Security Policy. Should be one in set [none, discard, ip
-P|--destination-port=
Destination Port for Security Policy. '0' stands for 'any'
-w|--flow-direction=
Flow direction for Security Policy. Should be one in set
-a|--sa-name= Name for the Security Association. Not being Specified lets vmkernel
choose an Security Association. If no applicable Security Assoc
vmkernel may request one using IKE.
-p|--source-port=
Source Port for Security Policy. '0' stands for 'any' (required
-d|--sp-destination=
Ipv6 address and prefix length of Security Policy destination.
'any' or a correct Ipv6 network address. (required)
-m|--sp-mode= Security Policy mode. Should be one in set [transport, tunnel
-n|--sp-name= Name for the Security Policy to be added. (required)

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 26 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

-s|--sp-source= Ipv6 address and prefix length of Security Policy source. Can be spe
a correct IPv6 network address. (required)
-u|--upper-layer-protocol=
Upper layer protocol for Security Policy, Should be one
icmp6].

Managing Gateways

You can manage both IPv4 and IPv6 networks. I first show the IPv4 here
because the IPv6 is very similar.

~ # esxcli network ip route ipv4 list


Network Netmask Gateway Interface Source
----------- ------------- ----------- --------- ------
default 0.0.0.0 192.168.8.1 vmk0 MANUAL
192.168.8.0 255.255.255.0 0.0.0.0 vmk0 MANUAL

To change the gateway, try the following command. Again, you session may
be terminated with invalid parameter.

~ # esxcli network ip route ipv4 add --gateway=192.168.0.1 --network=default

To remove a route, you can use remove command with same parameters as
the add command. Again, be careful as your session may be terminated
right away.

For the IPv6 listing of routes, you can see something similar as follows:

~ # esxcli network ip route ipv6 list


Network Netmask Gateway Interface
------- --------------------- ------- ---------
fe80:: ffff:ffff:ffff:ffff:: fe80::1 lo0
fe80:: ffff:ffff:ffff:ffff:: :: vmk0
ff01:: ffff:ffff:: ::1 lo0
ff01:: ffff:ffff:: :: vmk0
ff02:: ffff:ffff:: ::1 lo0
ff02:: ffff:ffff:: :: vmk0

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 27 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

List Live Network Connections

At any given time, you can find out what live connections are there.

~ # esxcli network ip connection list


Proto Recv Q Send Q Local Address Foreign Address State World ID
----- ------ ------ ------------------ ------------------- ----------- --------
tcp 0 0 127.0.0.1:8307 127.0.0.1:55067 ESTABLISHED
tcp 0 0 127.0.0.1:55067 127.0.0.1:8307 ESTABLISHED
tcp 0 0 127.0.0.1:443 127.0.0.1:50352 ESTABLISHED
tcp 0 0 127.0.0.1:50352 127.0.0.1:443 ESTABLISHED 2333889

The type of connection can be filtered as follows. I intentionally used udp


as it’s a lot less than the tcp connections.

~ # esxcli network ip connection list --type udp


Proto Recv Q Send Q Local Address Foreign Address State World ID World Name
----- ------ ------ ----------------- --------------- ----- -------- ----------
udp 0 0 192.168.0.201:427 0.0.0.0:0 2959
udp 0 0 0.0.0.0:427 0.0.0.0:0 2959
udp 0 0 :::8301 :::0 2421
udp 0 0 :::8302 :::0 2421
udp 0 0 :::8200 :::0 2548

Finding Neighbour on Network

You can use the esxcli command to list the network neighbors on the same
network.

~ # esxcli network ip neighbor list


Neighbor Mac Address Vmknic Expiry State
------------------------- ----------------- ------ -------- ---------
192.168.0.1 00:26:5a:cb:1f:0b vmk0 1189 sec
192.168.0.3 00:11:32:21:9b:09 vmk0 740 sec
fe80::8e89:a5ff:fed2:b40f 8c:89:a5:d2:b4:0f vmk0 0 sec Reachable

Managing Network Interface Card (NIC)

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 28 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

~ # esxcli network nic list


Name PCI Device Driver Link Speed Duplex MAC Address MTU Descriptio
------ ------------- ------ ---- ----- ------ ----------------- ---- ----------
vmnic0 0000:004:00.0 r8168 Up 1000 Full 8c:89:a5:d2:b4:0f 1500 Realtek Re

~ # esxcli network nic set --help


Usage: esxcli network nic set [cmd options]

Description:
set Set the general options for the specified ethernet device.

Cmd options:
-a|--auto Set the speed and duplexity settings to autonegotiate.
-D|--duplex= The duplex to set this NIC to. Acceptable values are : [full, half
-l|--message-level=
Sets the driver message level. Meaning differ per driver.
-n|--nic-name= The name of the NIC to configured. This must be one of the cards lis
list command. (required)
-P|--phy-address=
Set the PHY address of the device
-p|--port= Selects device port. Available device ports are aui: Select aui
port bnc: Select bnc as the device port fibre: Select m
mii: Select mii as the device port tp: Select tp as the dev
-S|--speed= The speed to set this NIC to. Acceptable values are : [10, 100
-t|--transceiver-type=
Selects transeiver type. Currently only internal and external c
future future types might be added. Available transeiver types
the transceiver type to external internal: Set the transcei
-w|--wake-on-lan=
Sets Wake-on-LAN options. Not all devices support this. The arg
a string of characters specifying which options to enable. p W
wake on unicast messages m Wake on multicast messages b wake on
Wake on ARP g Wake on MagicPacket(tm) s Enable SecureOn(
MagicPacket(tm)

To turn on NIC VLAN stats, we can use set command as follows, and then
we can check the VLAN stats.

~ # esxcli network nic vlan stats set --nic-name=vmnic0 --enabled true


~ # esxcli network nic vlan stats get --nic-name=vmnic0
VLAN 0
Packets received: 111
Packets sent: 221

For each NIC, you can get its stats with the stats namespace.

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 29 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

~ # esxcli network nic stats get --nic-name=vmnic0


NIC statistics for vmnic0
Packets received: 76577956
Packets sent: 166128469
Bytes received: 26876727438
Bytes sent: 217556196739
Receive packets dropped: 0
Transmit packets dropped: 0
Total receive errors: 0
Receive length errors: 0
Receive over errors: 0
Receive CRC errors: 0
Receive frame errors: 0
Receive FIFO errors: 0
Receive missed errors: 0
Total transmit errors: 0
Transmit aborted errors: 0
Transmit carrier errors: 0
Transmit FIFO errors: 0
Transmit heartbeat errors: 0
Transmit window errors: 0

To get the current configuration of a network interface, you can use the get
command with the name of the interface.

~ # esxcli network nic get --nic-name=vmnic0


Advertised Auto Negotiation: true
Advertised Link Modes: 10baseT/Half, 10baseT/Full, 100baseT/Half, 100baseT/Full, 100
Auto Negotiation: true
Cable Type: Twisted Pair
Current Message Level: 51
Driver Info:
Bus Info: 0000:04:00.0
Driver: r8168
Firmware Version:
Version: 8.013.00-NAPI
Link Detected: true
Link Status: Up
Name: vmnic0
PHYAddress: 0
Pause Autonegotiate: false
Pause RX: false
Pause TX: false
Supported Ports: TP
Supports Auto Negotiation: true
Supports Pause: false

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 30 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

Supports Wakeon: true


Transceiver: internal
Wakeon: MagicPacket(tm)

You can set the NIC with different parameters like speed, duplex mode. For
easy life, you can simply use the –auto option which let the ESXi
automatically negoatiate these with other system. When you have –auto
option, you must not specify the speed and duplex mode. NOTE: if you use
SSH to your ESXi server, be careful not to mess up the NIC underlying.

~ # esxcli network nic set --nic-name=vmnic0 --auto --wake-on-lan=p

For a particular NIC adapter, you can also turn it on and off. Be careful not
to turn off the NIC underlying your SSH session, or you have to have
physical access or IPMI.

~ # esxcli network nic up --nic-name=vmnic0


~ # esxcli network nic down --nic-name=vmnic0

Virtual Machine Related Networking


To list all the virtual machines and their ports and networks they connect
to, use the list command as follows.

~ # esxcli network vm list


World ID Name Num Ports Networks
-------- ----------------------- --------- ----------
42898 vCenter_VA 1 VM Network
44126 ESXi60 1 VM Network
879855 CentOS64Web 1 VM Network

Further down the port namespace, we can get more details of ports used by
a specific virtual machine which is identified by the world id. Please note
that you can also find the uplink port ID, which can used as normal VM

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 31 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

port ID for its stats and filters.

~ # esxcli network vm port list --world-id=42898


Port ID: 33554439
vSwitch: vSwitch0
Portgroup: VM Network
DVPort ID:
MAC Address: 00:0c:29:7b:a1:f4
IP Address: 0.0.0.0
Team Uplink: vmnic0
Uplink Port ID: 33554434
Active Filters:

Getting Port Related Stats and Filters


For each port, you can get the stats based its port number. The following
command shows what are included in the stats.

~ # esxcli network port stats get --portid=33554439


Packet statistics for port 33554439
Packets received: 2692640
Packets sent: 3076405
Bytes received: 2131115950
Bytes sent: 522406213
Broadcast packets received: 115193
Broadcast packets sent: 213179
Multicast packets received: 25794
Multicast packets sent: 10
Unicast packets received: 2551653
Unicast packets sent: 2863216
Receive packets dropped: 0
Transmit packets dropped: 0

To get port filter related stats, run the following command. Somehow I
don’t have filter therefore nothing is shown in output.

~ # esxcli network port filter stats get --portid=33554434

Managing SR-IOV
http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 32 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

SR-IOV stands for Single Root I/O Virtualization. It allow one PCI device
appears as multiple NIC cards to the hypervisor. Scott Lowe has a nice blog
post on this topic.

To list the NICs that support SR-IOV, and list the virtual functions (VF) on
a nic, run the following commands.

~ # esxcli network sriovnic list


~ # esxcli network sriovnic vf list --nic-name=vmnic0

There is no SRIOV Nic with name vmnic0

Managing Virtual Switches


The standard and distributed virtual switch are in two parallel namespaces.
They allow lots of control over virtual switches.

To list all the virtual switches, use the list command as follows:

~ # esxcli network vswitch standard list


vSwitch0
Name: vSwitch0
Class: etherswitch
Num Ports: 128
Used Ports: 11
Configured Ports: 128
MTU: 1500
CDP Status: listen
Beacon Enabled: false
Beacon Interval: 1
Beacon Threshold: 3
Beacon Required By:
Uplinks: vmnic0
Portgroups: VM Network, Management Network

To create a new virtual switch, use the add command with port number
and name.

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 33 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

~ # esxcli network vswitch standard add --vswitch-name="LabOnly" --ports=1024

The newly created virtual switch takes default for mtu, and cdp, but you
can change them using the set command with the options below.

Cmd options:
-c|--cdp-status= The CDP status of the given virtual switch. It can be 'down',
'both'
-m|--mtu= The MTU size of the given virtual switch.
-v|--vswitch-name=
The name of virtual switch to apply the configurations.

You can delete a virtual switch by the remove command

~ # esxcli network vswitch standard remove --vswitch-name=LabOnly

There are many policies you can change with esxcli command, namely
failover, security, shaping. You can set these policies using the set
command under the corresponding namespace. The name for the virtual
switch is case sensitive.

~ # esxcli network vswitch standard policy failover get --vswitch-name=vSwitch1


Load Balancing: srcport
Network Failure Detection: link
Notify Switches: true
Failback: true
Active Adapters:
Standby Adapters:
Unused Adapters:
~ # esxcli network vswitch standard policy security get --vswitch-name=vSwitch1
Allow Promiscuous: false
Allow MAC Address Change: true
Allow Forged Transmits: true
~ # esxcli network vswitch standard policy shaping get --vswitch-name=vSwitch1
Enabled: false
Average Bandwidth: -1 Kbps
Peak Bandwidth: -1 Kbps
Burst Size: -1 Kib

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 34 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

To add a new uplink to a virtual switch, you can run the following
command. The uplink name must be a valid pnic name.

# esxcli network vswitch standard uplink add --vswitch-name=vSwitch1 --uplink-name

To remove an uplink, just use the remove commmand

# esxcli network vswitch standard uplink remove --vswitch-name=vSwitch1 --uplink-name

Managing Port Groups


Port group is a “virtual” concept. It defines a common behavior for a group
of ports.

~ # esxcli network vswitch standard portgroup list


Name Virtual Switch Active Clients VLAN ID
------------------ -------------- -------------- -------
Management Network vSwitch0 1 0
Private VM Network vSwitch1 0 0
VM Network vSwitch0 7 0

To add a new port group, use the add command

~ # esxcli network vswitch standard portgroup add --vswitch-name=vSwitch1 --portgroup-n

To remove a port group, use the remove command:

~ # esxcli network vswitch standard portgroup remove --portgroup-name=SysTest --vswitch

You can change the VLAN ID with set command. Note that this may affect
the network connectivity.

~ # esxcli network vswitch standard portgroup set --portgroup-name="VM Network" --vlan-

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 35 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

There are similar policies that are associated with port groups as with the
virtual switch. The following shows 3 commands and you can see what are
included in the policy.

~ # esxcli network vswitch standard portgroup policy failover get --portgroup-name="VM


Load Balancing: srcport
Network Failure Detection: link
Notify Switches: true
Failback: true
Active Adapters: vmnic0
Standby Adapters:
Unused Adapters:
Override Vswitch Load Balancing: false
Override Vswitch Network Failure Detection: false
Override Vswitch Notify Switches: false
Override Vswitch Failback: false
Override Vswitch Uplinks: false
~ # esxcli network vswitch standard portgroup policy security get --portgroup-name="VM
Allow Promiscuous: true
Allow MAC Address Change: true
Allow Forged Transmits: true
Override Vswitch Allow Promiscuous: true
Override Vswitch Allow MAC Address Change: false
Override Vswitch Allow Forged Transmits: false
~ # esxcli network vswitch standard portgroup policy shaping get --portgroup-name="VM N
Enabled: false
Average Bandwidth: -1 Kbps
Peak Bandwidth: -1 Kbps
Burst Size: -1 Kib
Override Vswitch Enabled: false
Override Vswitch Average Bandwidth: false
Override Vswitch Peak Bandwidth: false
Override Vswitch Burst Size: false

Distributed Virtual Switch

Distributed virtual switch is similar to standard virtual switch but the


control is centralized in vCenter server. The esxcli command allows control
of the vmware virtual switch. For the Cisco Nexus 1000v, you can use their
own command line that I introduced before.

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 36 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

~ # esxcli network vswitch dvs vmware


Usage: esxcli network vswitch dvs vmware {cmd} [cmd options]

Available Namespaces:
lacp A set of commands for LACP related operations
vxlan A set of commands for VXLAN related operations

Available Commands:
list List the VMware vSphere Distributed Switch currently configured on
the ESXi host.

Diagnosing Network Connection with Ping


The ping command is very useful for testing network connection. The
esxcli command comes with a handy one as well with additional controls. I
found it’s extremely helpful when I tested the jumbo frame configuration
for my ESXi to a NAS server.

~ # esxcli network diag ping --ipv4 --host=192.168.11.3 --size=9000


Summary:
Duplicated: 0
Host Addr: 192.168.11.3
Packet Lost: 100
Recieved: 0
Roundtrip Avg MS: -2147483648
Roundtrip Max MS: 0
Roundtrip Min MS: 999999000
Transmitted: 3
Trace:

There are more options as shown in the following.

Cmd options:
-c|--count= Specify the number of packets to send.
-D|--debug VMKPing debug mode.
-d|--df Set DF bit on IPv4 packets.
-H|--host= Specify the host to send packets to. (required)
-I|--interface= Specify the outgoing interface.
-i|--interval= Set the interval for sending packets in seconds.

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 37 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

-4|--ipv4 Ping with ICMPv4 echo requests.


-6|--ipv6 Ping with ICMPv6 echo requests.
-N|--nexthop= Override the system's default route selection, in dotted quad notati
Requires interface option)
-s|--size= Set the payload size of the packets to send.
-t|--ttl= Set IPv4 Time To Live or IPv6 Hop Limit
-W|--wait= Set the timeout to wait if no responses are received in seconds.

Managing Storage
The storage is another heavy aspect of ESXi management. It includes 6
different sub namespaces, each of which is a big topic by itself.

~ # esxcli storage
Usage: esxcli storage {cmd} [cmd options]

Available Namespaces:
core VMware core storage commands.
nmp VMware Native Multipath Plugin (NMP). This is the VMware defaul
Pluggable Storage Architecture.
san IO device management operations to the SAN devices on the syste
vmfs VMFS operations.
filesystem Operations pertaining to filesystems, also known as datastores,
nfs Operations to create, manage and remove Network Attached Storag

Managing NFS
To list all the NFS volumes that are already mounted on the host, just run
the list command.

~ # esxcli storage nfs list


Volume Name Host Share Accessible Mounted Read-Only Hardware Accele
----------- ----------- ------------ ---------- ------- --------- ---------------
vms 192.168.0.3 /volume1/vms true true false Not Supported

To add a new NFS volume, you want to use the add command:

~ # esxcli storage nfs add --host=192.168.0.3 --share="/volume1/vms" --volume-name=vms

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 38 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

To remove an existing volume, then the remove command is handy.

~ # esxcli storage nfs remove --volume-name=vms2

Managing File System


To list all the mount points, you can run the following command. You can
check out the volume names, types, size, free space.

~ # esxcli storage filesystem list


Mount Point Volume Name UUID
------------------------------------------------- ----------- -----------------------
/vmfs/volumes/f3956571-cbbda790 vms f3956571-cbbda790
/vmfs/volumes/50cdcb68-6fc8e606-bb76-8c89a5d2b40f datastore1 50cdcb68-6fc8e606-bb76-
/vmfs/volumes/50cdcb6a-6cac08ca-6b16-8c89a5d2b40f 50cdcb6a-6cac08ca-6b16-
/vmfs/volumes/ce5db771-45edfd5c-a23e-edcce43edff3 ce5db771-45edfd5c-a23e-
/vmfs/volumes/7431f671-c7c192c1-91ce-5255b286bbb3 7431f671-c7c192c1-91ce-
/vmfs/volumes/50cdcb4f-7e8fc89e-7ed1-8c89a5d2b40f 50cdcb4f-7e8fc89e-7ed1-

With changes on the file system, you can also run the following command
to rescan and automatically mount those unmounted.

~ # esxcli storage filesystem rescan


~ # esxcli storage filesystem automount

To unmount a volume, use the unmount command with label or UUID.

~ # esxcli storage filesystem unmount --help


Usage: esxcli storage filesystem unmount [cmd options]

Description:
unmount Disconnect and unmount and existing VMFS or NAS volume. This wi
remove the volume from the list of mounted volumes.

Cmd options:
-n|--no-persist Unmount the volume non-peristently; the volume will be automoun
-l|--volume-label=
The label of the volume to unmount.
-p|--volume-path=

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 39 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

The path of the volume to unmount.


-u|--volume-uuid=
The uuid of the volume to unmount.

Managing VMFS System

~ # esxcli storage vmfs upgrade --volume-label=datastore1


In-place upgrade of VMFS5is not supported on this platform

~ # esxcli storage vmfs extent list


Volume Name VMFS UUID Extent Number Device Name
----------- ----------------------------------- ------------- ----------------------
datastore1 50cdcb68-6fc8e606-bb76-8c89a5d2b40f 0 t10.ATA_____Hitachi_HD

There are also snapshot feature that can be managed by a few commands.

~ # esxcli storage vmfs snapshot


Usage: esxcli storage vmfs snapshot {cmd} [cmd options]

Available Namespaces:
extent Manage VMFS snapshot extents.

Available Commands:
list List unresolved snapshots/replicas of VMFS volume.
mount Mount a snapshot/replica of a VMFS volume.
resignature Resignature a snapshot/replica of a VMFS volume.

Managing SAN Storage


As I don’t have SAN storage in my lab, I won’t go deeper on this, but show
the help of the command. You can drill down and give it try by yourself.

~ # esxcli storage san


Usage: esxcli storage san {cmd} [cmd options]

Available Namespaces:
fc IO Device Management operations to the FC adapters on the syste
fcoe IO Device Management operations to the FCoE adapters on the sys
iscsi IO Device Management operations to the Software iSCSI adapters
sas IO Device Management operations to the SAS adapters on the syst

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 40 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

Managing Native Multi-Path

~ # esxcli storage nmp path list


sata.vmhba35-sata.0:0-mpx.vmhba35:C0:T0:L0
Runtime Name: vmhba35:C0:T0:L0
Device: mpx.vmhba35:C0:T0:L0
Device Display Name: Local PLDS CD-ROM (mpx.vmhba35:C0:T0:L0)
Group State: active
Array Priority: 0
Storage Array Type Path Config: SATP VMW_SATP_LOCAL does not support path configurat
Path Selection Policy Path Config: {current: yes; preferred: yes}

sata.vmhba0-sata.0:0-t10.ATA_____Hitachi_HDS723020BLA642___________LENOVO______MN1240FA
Runtime Name: vmhba0:C0:T0:L0
Device: t10.ATA_____Hitachi_HDS723020BLA642___________LENOVO______MN1240FA09DU5D
Device Display Name: Local ATA Disk (t10.ATA_____Hitachi_HDS723020BLA642___________L
Group State: active
Array Priority: 0
Storage Array Type Path Config: SATP VMW_SATP_LOCAL does not support path configurat
Path Selection Policy Path Config: {current: yes; preferred: yes}

We can also list the devices involved in Native Multipath:

~ # esxcli storage nmp device list


t10.ATA_____Hitachi_HDS723020BLA642___________LENOVO______MN1240FA09DU5D
Device Display Name: Local ATA Disk (t10.ATA_____Hitachi_HDS723020BLA642___________L
Storage Array Type: VMW_SATP_LOCAL
Storage Array Type Device Config: SATP VMW_SATP_LOCAL does not support device config
Path Selection Policy: VMW_PSP_FIXED
Path Selection Policy Device Config: {preferred=vmhba0:C0:T0:L0;current=vmhba0:C0:T0
Path Selection Policy Device Custom Config:
Working Paths: vmhba0:C0:T0:L0
Is Local SAS Device: false
Is Boot USB Device: false

mpx.vmhba35:C0:T0:L0
Device Display Name: Local PLDS CD-ROM (mpx.vmhba35:C0:T0:L0)
Storage Array Type: VMW_SATP_LOCAL
Storage Array Type Device Config: SATP VMW_SATP_LOCAL does not support device config
Path Selection Policy: VMW_PSP_FIXED
Path Selection Policy Device Config: {preferred=vmhba35:C0:T0:L0;current=vmhba35:C0:
Path Selection Policy Device Custom Config:
Working Paths: vmhba35:C0:T0:L0
Is Local SAS Device: false
Is Boot USB Device: false

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 41 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

Multipath policy can also be configured using different plugins, which are
listed as follows:

~ # esxcli storage nmp psp list


Name Description
------------- ---------------------------------
VMW_PSP_MRU Most Recently Used Path Selection
VMW_PSP_RR Round Robin Path Selection
VMW_PSP_FIXED Fixed Path Selection

To list the configuration of a particular policy, we can use the following


command (The device value is a little bit long but you can copy and paste it
from the list command)

~ # esxcli storage nmp psp fixed deviceconfig get --device=mpx.vmhba35:C0:T0:L0


Configured Preferred Path:
Device: mpx.vmhba35:C0:T0:L0
Preferred Path: vmhba35:C0:T0:L0
~ # esxcli storage nmp psp generic deviceconfig get --device=mpx.vmhba35:C0:T0:L0
{preferred=vmhba35:C0:T0:L0;current=vmhba35:C0:T0:L0}
~ # esxcli storage nmp psp roundrobin deviceconfig get --device=mpx.vmhba35:C0:T0:L0
Device mpx.vmhba35:C0:T0:L0 Does not use the Round Robin path selection policy.

To list all the storage array plugin (SATP), the following command is
handy.

~ # esxcli storage nmp satp list


Name Default PSP Description
------------------- ------------- ------------------------------------------
VMW_SATP_MSA VMW_PSP_MRU Placeholder (plugin not loaded)
VMW_SATP_ALUA VMW_PSP_MRU Placeholder (plugin not loaded)
VMW_SATP_DEFAULT_AP VMW_PSP_MRU Placeholder (plugin not loaded)
VMW_SATP_SVC VMW_PSP_FIXED Placeholder (plugin not loaded)
VMW_SATP_EQL VMW_PSP_FIXED Placeholder (plugin not loaded)
VMW_SATP_INV VMW_PSP_FIXED Placeholder (plugin not loaded)
VMW_SATP_EVA VMW_PSP_FIXED Placeholder (plugin not loaded)
VMW_SATP_ALUA_CX VMW_PSP_RR Placeholder (plugin not loaded)
VMW_SATP_SYMM VMW_PSP_RR Placeholder (plugin not loaded)
VMW_SATP_CX VMW_PSP_MRU Placeholder (plugin not loaded)

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 42 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

VMW_SATP_LSI VMW_PSP_MRU Placeholder (plugin not loaded)


VMW_SATP_DEFAULT_AA VMW_PSP_FIXED Supports non-specific active/active arrays
VMW_SATP_LOCAL VMW_PSP_FIXED Supports direct attached devices

To change the SATP, the following options are needed.

~ # esxcli storage nmp satp set --help


Usage: esxcli storage nmp satp set [cmd options]

Description:
set Set the default Path Selection Policy for a given Storage Array

Cmd options:
-b|--boot This is a system default rule added at boot time. Do not modify
-P|--default-psp=
The default path selection policy to set for a given --satp
-s|--satp= The SATP name for the Storage Array Type Plugin on which this

Core Storage
The following command lists all the storage adapters on the host,

~ # esxcli storage core adapter list


HBA Name Driver Link State UID Description
-------- ------ ---------- ------------ -------------------------------------------
vmhba0 ahci link-n/a sata.vmhba0 (0:0:31.2) Intel Corporation Panther Point
vmhba33 ahci link-n/a sata.vmhba33 (0:0:31.2) Intel Corporation Panther Point
vmhba34 ahci link-n/a sata.vmhba34 (0:0:31.2) Intel Corporation Panther Point
vmhba35 ahci link-n/a sata.vmhba35 (0:0:31.2) Intel Corporation Panther Point
vmhba36 ahci link-n/a sata.vmhba36 (0:0:31.2) Intel Corporation Panther Point
vmhba37 ahci link-n/a sata.vmhba37 (0:0:31.2) Intel Corporation Panther Point

To make sure the adapters are found, run the rescan all command.

~ # esxcli storage core adapter rescan --all

IO statistics are also available with the following command. More lines are
actually there, but skipped here to save space.

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 43 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

~ # esxcli storage core adapter stats get


vmhba0
Successful Commands: 22831456
Blocks Read: 582070835
Blocks Written: 401568853
Read Operations: 12365270
Write Operations: 10407137
Reserve Operations: 710
Reservation Conflicts: 0
Failed Commands: 25975
Failed Blocks Read: 132581
Failed Blocks Written: 283880
Failed Read Operations: 4255
Failed Write Operations: 20791
Failed Reserve Operations: 0
Total Splits: 0
PAE Commands: 0

To list storage adapters, the following command works.

~ # esxcli storage core device list


t10.ATA_____Hitachi_HDS723020BLA642___________LENOVO______MN1240FA09DU5D
Display Name: Local ATA Disk (t10.ATA_____Hitachi_HDS723020BLA642___________LENOVO__
Has Settable Display Name: true
Size: 1907729
Device Type: Direct-Access
Multipath Plugin: NMP
Devfs Path: /vmfs/devices/disks/t10.ATA_____Hitachi_HDS723020BLA642___________LENOVO
Vendor: ATA
Model: Hitachi HDS72302
Revision: MN6O
SCSI Level: 5
Is Pseudo: false
Status: on
Is RDM Capable: false
Is Local: true
Is Removable: false
Is SSD: 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: unknown
Other UIDs: vml.01000000002020202020204d4e313234304641303944553544486974616368
Is Local SAS Device: false
Is Boot USB Device: false

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 44 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

~ # esxcli storage core device smart get --device-name=t10.ATA_____Hitachi_HDS723020BLA


Parameter Value Threshold Worst
---------------------------- ----- --------- -----
Health Status OK N/A N/A
Media Wearout Indicator N/A N/A N/A
Write Error Count N/A N/A N/A
Read Error Count 100 16 100
Power-on Hours 98 0 98
Power Cycle Count 100 0 100
Reallocated Sector Count 100 5 100
Raw Read Error Rate 100 16 100
Drive Temperature 181 0 181
Driver Rated Max Temperature N/A N/A N/A
Write Sectors TOT Count 200 0 200
Read Sectors TOT Count N/A N/A N/A
Initial Bad Block Count N/A N/A N/A

Get device statistics

~ # esxcli storage core device stats get


t10.ATA_____Hitachi_HDS723020BLA642___________LENOVO______MN1240FA09DU5D
Device: t10.ATA_____Hitachi_HDS723020BLA642___________LENOVO______MN1240FA09DU5D
Successful Commands: 24676085
Blocks Read: 624508799
Blocks Written: 434893836
Read Operations: 13214112
Write Operations: 11411077
Reserve Operations: 710
Reservation Conflicts: 0
Failed Commands: 27910
Failed Blocks Read: 39323
Failed Blocks Written: 311962
Failed Read Operations: 4481
Failed Write Operations: 23000
Failed Reserve Operations: 0

mpx.vmhba35:C0:T0:L0
Device: mpx.vmhba35:C0:T0:L0
Successful Commands: 0
Blocks Read: 0
Blocks Written: 0
Read Operations: 0
Write Operations: 0
Reserve Operations: 0
Reservation Conflicts: 0
Failed Commands: 17197
Failed Blocks Read: 0

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 45 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

Failed Blocks Written: 0


Failed Read Operations: 16
Failed Write Operations: 0
Failed Reserve Operations: 0

To get a list of the worlds that are currently using devices on the ESX host,
the following command is used:

~ # esxcli storage core device world list


Device World ID Ope
------------------------------------------------------------------------ --------
t10.ATA_____Hitachi_HDS723020BLA642___________LENOVO______MN1240FA09DU5D
t10.ATA_____Hitachi_HDS723020BLA642___________LENOVO______MN1240FA09DU5D 2056

~ # esxcli storage core device partition list


Device Partition St
------------------------------------------------------------------------ ---------
t10.ATA_____Hitachi_HDS723020BLA642___________LENOVO______MN1240FA09DU5D
t10.ATA_____Hitachi_HDS723020BLA642___________LENOVO______MN1240FA09DU5D
t10.ATA_____Hitachi_HDS723020BLA642___________LENOVO______MN1240FA09DU5D
t10.ATA_____Hitachi_HDS723020BLA642___________LENOVO______MN1240FA09DU5D
t10.ATA_____Hitachi_HDS723020BLA642___________LENOVO______MN1240FA09DU5D
t10.ATA_____Hitachi_HDS723020BLA642___________LENOVO______MN1240FA09DU5D
t10.ATA_____Hitachi_HDS723020BLA642___________LENOVO______MN1240FA09DU5D
t10.ATA_____Hitachi_HDS723020BLA642___________LENOVO______MN1240FA09DU5D

Optionally, we can list the partitions with their GUID as follows:

~ # esxcli storage core device partition showguid


Device Partition La
------------------------------------------------------------------------ ---------
t10.ATA_____Hitachi_HDS723020BLA642___________LENOVO______MN1240FA09DU5D
t10.ATA_____Hitachi_HDS723020BLA642___________LENOVO______MN1240FA09DU5D
t10.ATA_____Hitachi_HDS723020BLA642___________LENOVO______MN1240FA09DU5D
t10.ATA_____Hitachi_HDS723020BLA642___________LENOVO______MN1240FA09DU5D
t10.ATA_____Hitachi_HDS723020BLA642___________LENOVO______MN1240FA09DU5D
t10.ATA_____Hitachi_HDS723020BLA642___________LENOVO______MN1240FA09DU5D
t10.ATA_____Hitachi_HDS723020BLA642___________LENOVO______MN1240FA09DU5D
t10.ATA_____Hitachi_HDS723020BLA642___________LENOVO______MN1240FA09DU5D

To list all devices that were detached manually by changing their state on
the system, run the following command. This is related to the ESXi feature

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 46 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

of pluggable storage architectures (PSA).

~ # esxcli storage core device detached list

For the VAAI feature, we can get their status. In my case, it’s not used at all
therefore no much to show.

~ # esxcli storage core device vaai status get


t10.ATA_____Hitachi_HDS723020BLA642___________LENOVO______MN1240FA09DU5D
VAAI Plugin Name:
ATS Status: unsupported
Clone Status: unsupported
Zero Status: supported
Delete Status: unsupported

mpx.vmhba35:C0:T0:L0
VAAI Plugin Name:
ATS Status: unsupported
Clone Status: unsupported
Zero Status: unsupported
Delete Status: unsupported

To list all the SCSI paths on the system, use the following command:

~ # esxcli storage core path list


sata.vmhba35-sata.0:0-mpx.vmhba35:C0:T0:L0
UID: sata.vmhba35-sata.0:0-mpx.vmhba35:C0:T0:L0
Runtime Name: vmhba35:C0:T0:L0
Device: mpx.vmhba35:C0:T0:L0
Device Display Name: Local PLDS CD-ROM (mpx.vmhba35:C0:T0:L0)
Adapter: vmhba35
Channel: 0
Target: 0
LUN: 0
Plugin: NMP
State: active
Transport: sata
Adapter Identifier: sata.vmhba35
Target Identifier: sata.0:0
Adapter Transport Details: Unavailable or path is unclaimed
Target Transport Details: Unavailable or path is unclaimed
Maximum IO Size: 131072

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 47 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

For each path, it can be set active, or off using the set command.

~ # esxcli storage core path set --help


Usage: esxcli storage core path set [cmd options]

Description:
set Provide control to allow a user to modify a single path's state
enable or disable SCSI paths. The user is not able to change th
toggle between 'active' and 'off'. Please NOTE changing the Pat
to a given device is likely to fail. The VMkernel will not chan
would cause an 'All paths down' state or the device is currentl

Cmd options:
-p|--path= Select the path to set path state on. This can be a Runtime Name or
--state= Set the SCSI path state for a the specific path given. Valid values
state to active. This may be immediately changed by the system
not appropriate. off: Administratively disable this path.

For path level stats, the following command can be used:

~ # esxcli storage core path stats get


sata.vmhba35-sata.0:0-mpx.vmhba35:C0:T0:L0
UID: sata.vmhba35-sata.0:0-mpx.vmhba35:C0:T0:L0
Runtime Name: vmhba35:C0:T0:L0
Successful Commands: 4
Blocks Read: 0
Blocks Written: 0
Read Operations: 0
Write Operations: 0
Reserve Operations: 0
Reservation Conflicts: 0
Failed Commands: 29658
Failed Blocks Read: 0
Failed Blocks Written: 0
Failed Read Operations: 17
Failed Write Operations: 0
Failed Reserve Operations: 0
Total Splits: 17247
PAE Commands: 0

To list plugins in the system, the following command is used:

~ # esxcli storage core plugin list


Plugin name Plugin class

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 48 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

----------- ------------
NMP MP

To allow automatic claiming process of PSA, the autoclaim can be used. By


default, it’s enabled and should not be turned off.

~ # esxcli storage core claiming autoclaim --enabled true

For the automatic claiming, rules can be used. The following command lists all the rule
~ # esxcli storage core claimrule list
Rule Class Rule Class Type Plugin Matches
---------- ----- ------- --------- --------- ---------------------------------
MP 0 runtime transport NMP transport=usb
MP 1 runtime transport NMP transport=sata
MP 2 runtime transport NMP transport=ide
MP 3 runtime transport NMP transport=block
MP 4 runtime transport NMP transport=unknown
MP 101 runtime vendor MASK_PATH vendor=DELL model=Universal Xport
MP 101 file vendor MASK_PATH vendor=DELL model=Universal Xport
MP 65535 runtime vendor NMP vendor=* model=*

New rules can also be added into the rule set. The command expects a few
parameters, but the help is probably the best – it comes with a few
examples.

~ # esxcli storage core claimrule add --help


Usage: esxcli storage core claimrule add [cmd options]

Description:
add Add a claimrule to the set of claimrules on the system.

Cmd options:
-A|--adapter= Indicate the adapter of the paths to use in this operation.
-u|--autoassign The system will auto assign a rule id.
-C|--channel= Indicate the channel of the paths to use in this operation.
-c|--claimrule-class=
Indicate the claim rule class to use in this operation [
-d|--device= Indicate the Device Uid to use for this operation.
-D|--driver= Indicate the driver of the paths to use in this operation.
-f|--force Force claim rules to ignore validity checks and install the rul
--if-unset= Execute this command if this advanced user variable is not set
-i|--iqn= Indicate the iSCSI Qualified Name for the target to use in this oper
-L|--lun= Indicate the LUN of the paths to use in this operation.

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 49 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

-M|--model= Indicate the model of the paths to use in this operation.


-P|--plugin= Indicate which PSA plugin to use for this operation. (required
-r|--rule= Indicate the rule ID to use for this operation.
-T|--target= Indicate the target of the paths to use in this operation.
-R|--transport= Indicate the transport of the paths to use in this operation. Valid
iscsivendor, ide, sas, sata, usb, parallel, unknown]
-t|--type= Indicate which type of matching used for claim/unclaim or claimrule.
location, driver, transport, device, target] (required)
-V|--vendor= Indicate the vendor of the paths to user in this operation.
--wwnn= Indicate the World-Wide Node Number for the target to use in this op
--wwpn= Indicate the World-Wide Port Number for the target to use in this op

Examples:

Add rule #321 for the Filter plugin type that will claim the given device for the VAA
# esxcli storage core claimrule add -r 321 -t device -P VAAI_FILTER --claimrule-class=F

Add rule #321 for the VAAI plugin type that will claim the given device for the VMW_V
# esxcli storage core claimrule add -r 321 -t device -P VMW_VAAIP_SYMM --claimrule-clas

Add rule #321 that will claim the path on adapter vmhba0, channel 0, target 0, LUN 0
# esxcli storage core claimrule add -r 321 -t location -A vmhba0 -C 0 -T 0 -L 0 -P NMP

Add rule #429 for the MP claim rule type that will claim all paths provided by an ada
# esxcli storage core claimrule add -r 429 -t driver -D mptscsi -P MASK_PATH --claimrul

Add rule #914 to claim all paths with a vendor string matching "VMWARE" and a model s
# esxcli storage core claimrule add -r 914 -t vendor -V VMWARE -M Virtual -P NMP

Add rule #1015 to claim all paths provided by Fibre Channel type adapters for the NMP
# esxcli storage core claimrule add -r 1015 -t transport -R fc -P NMP

Add rule #429 to claim all paths provided by Fibre Channel Target on given WWNN and W
# esxcli storage core claimrule add -r 429 -P NMP -t target -R fc --wwnn 50:06:01:60:ba

Add rule #429 to claim paths to LUN 5 provided by iSCSI Target on given IQN.
# esxcli storage core claimrule add -r 429 -P NMP -t target -R iscsi --iqn iqn.2001-04.

Add a rule with a system assigned rule id to claim all paths provided by Fibre Channe
# esxcli storage core claimrule add --autoassign -t transport -R fc -P NMP

Managing System Wide Settings


This section involves global setting for the ESXi management.

Get ESXi Boot Device


http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 50 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

~ # esxcli system boot device get


Boot Filesystem UUID: ce5db771-45edfd5c-a23e-edcce43edff3
Boot NIC:
Stateless Boot NIC:

Managing Core Dump


The ESXi core can be dumped to a network server if you configure it as
follows:

~ # esxcli system coredump network set --interface-name=vmk0 --server-ipv4=192.168.0.3


~ # esxcli system coredump network set --enable true

~ # esxcli system coredump network get


Enabled: true
Host VNic: vmk0
Network Server IP: 192.168.0.3
Network Server Port: 6500

Core can aso be dumped into local partition and that involves another sub
namespace – partition.

To get the configuration, use the get command.

~ # esxcli system coredump partition get


Active: t10.ATA_____Hitachi_HDS723020BLA642___________LENOVO______MN1240FA09DU5D:
Configured: t10.ATA_____Hitachi_HDS723020BLA642___________LENOVO______MN1240FA09DU5D

To set the configuration, the set command is handy.

~ # esxcli system coredump partition list


Name Path
-------------------------------------------------------------------------- -----------
t10.ATA_____Hitachi_HDS723020BLA642___________LENOVO______MN1240FA09DU5D:7 /vmfs

You can also change the configuration with the set command.

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 51 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

~ # esxcli system coredump partition set --help


Usage: esxcli system coredump partition set [cmd options]

Description:
set Set the specific VMkernel dump partition for this system. This
partition for the next boot. This command will change the activ
partition specified.

Cmd options:
-e|--enable Enable or disable the VMkernel dump partition. This option cann
setting or unconfiguring the dump partition.
-p|--partition= The name of the partition to use. This should be a device name with
at the end. Example: naa.xxxxx:1
-s|--smart This flag can be used only with --enable=true. It will cause th
partition to be selected using the smart selection algorithm.
-u|--unconfigure Set the dump partition into an unconfigured state. This will re
configured dump partition for the next boot. This will result
algorithm being used at the next boot.

Module Management
To list the modules in ESXi server, you can use the module sub namespace
with list command. There are many lines of output not listed here.

~ # esxcli system module list


Name Is Loaded Is Enabled
----------------------------- --------- ----------
vmkernel true true
chardevs true true
user true true
vprobe true true
vmkapi_socket true true
...

To get details about a module, you can use the get command

~ # esxcli system module get --module=nmp


Module: nmp
Module File: /usr/lib/vmware/vmkmod/nmp
License: VMware
Version: Version 1.0.0-0, Built on: Aug 1 2012
Signed Status: VMware Signed
Signature Issuer: VMware, Inc.
Signature Digest: c99a 0c21 a220 c1b4 c0e7 202b c7f8 e916 6220 391f fe76 9612

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 52 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

Signature FingerPrint: cb44 247a 1614 cea1 2079 362d ec86 9d0e
Provided Namespaces: com.vmware.vmkapi@v2_1_0_0
Required Namespaces: com.vmware.vmkapi@v2_1_0_0, vmkernel@nover

~ # esxcli system module set --module=nmp --enabled true

To load a module, run the following command:

~ # esxcli system module load --module=nmp --force

You can also list parameters of a module as follows. There are actually
more lines but omitted. It’s also highly possible that there is no line at all
because there is no parameter to change for that module.

~ # esxcli system module parameters list --module=dvfilter


Name Type Value Description
---------------------------------- ----- ----- -------------------------------------
DVFILTERCOMM_HEAP_MAX_SIZE int Default DVFilterComm max heap
DVFILTERCOMM_HEAP_MIN_SIZE int Default DVFilterComm min heap
DVFILTERCOMM_MAXWRITEQUEUE_LEN_CTL int Default DVFilterComm max control mess
DVFILTERCOMM_MAXWRITEQUEUE_LEN_PKT int Default DVFilterComm max packet messa

Userworld Process
To list these processes, you can use the following command. Again, it’s not
fully list due to space limit.

~ # esxcli system process list


Id Cartel Id Name Security Domain Command
------- --------- ------------------------------------- ------------------ --------
2049 0 idle1 superDom
2050 0 idle2 superDom

To find how many userworld processes running, try the following


command:

~ # esxcli system process stats running get

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 53 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

Running Processes: 350

To get the system workload, run the following command and get the load
in 1, 5, and 15 minute period. You will get more from esxtop command
anyway.

~ # esxcli system process stats load get


Load1Minute: 0.04
Load15Minutes: 0.04
Load5Minutes: 0.04

Security Policy
As usual, you can list all the security policies using the list command. With
each policy, you can see its enforcement level.

~ # esxcli system secpolicy domain list


Domain Name Enforcement Level
------------------ -----------------
appDom enforcing
pluginDom enforcing
pluginFrameworkDom enforcing
regularVMDom enforcing
superDom enforcing
swMgmtDom enforcing

To change the level of enforcement, use the set command. Other than the
enforcing level, I haven’t seen other level and I even tried none and a few
others with no luck. The help doesn’t help neither – something for VMware
to improve.

~ # esxcli system secpolicy domain set --name=appDom --level=enforcing


~ # esxcli system secpolicy domain set --help
Usage: esxcli system secpolicy domain set [cmd options]

Description:
set Set the enforcement level for a domain in the system. Any optio
persistent and will not survive a reboot of the system.

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 54 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

Cmd options:
-a|--all-domains All domains.
-l|--level= The enforcement level. (required)
-n|--name= The domain name.

Kernel Settings

There are many parameters with which you can tune the ESXi. For a
complete list of these parameters, you can use the list command as follows.
As you expect, there are so many of them, I just show first two. The name
of the setting is self explanatory with the description field.

~ # esxcli system settings kernel list


Name Type Description
------------------------------- ------ ----------------------------------------------
acpiDbgLevel uint32 ACPI debug level
allowNonNX Bool Allow booting with NX feature disabled or non

~ # esxcli system settings kernel set --setting=acpiDbgLevel --value=0

ESXi Advanced Settings

There are many parameters you can fine tune the ESXi. The following
shows the commands you can list them, change them.

~ # esxcli system settings advanced list


Path: /Irq/BestVcpuRouting
Type: integer
Int Value: 0
Default Int Value: 0
Min Value: 0
Max Value: 1
String Value:
Default String Value:
Valid Characters:
Description: 1: try to route the virtual interrupt to the best vcpu; 0 to disable

Path: /Irq/IRQRebalancePeriod
Type: integer
Int Value: 50

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 55 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

Default Int Value: 50


Min Value: 10
Max Value: 20000
String Value:
Default String Value:
Valid Characters:
Description: time in ms between attempts to rebalance interrupts
...

~ # esxcli system settings advanced set --help


Usage: esxcli system settings advanced set [cmd options]

Description:
set Set the value of an advanced option.

Cmd options:
-d|--default Reset the option to its default value.
-i|--int-value= If the option is an integer value use this option.
-o|--option= The name of the option to set the value of. Example: "/Misc/HostName
-s|--string-value=
If the option is a string use this option.

Setting Keyboard Configurations

ESXi is like an operating system which can interactive with users. One way
of interaction is via keyboard. The esxcli command allows changing the
keyboard configuration.

~ # esxcli system settings keyboard layout list


Layout
---------------
Belgian
Brazilian
Croatian
Czechoslovakian
Danish
Estonian
Finnish
French
German
Greek
Icelandic
Italian
Japanese
Latin American
Norwegian

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 56 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

Polish
Portuguese
Russian
Slovenian
Spanish
Swedish
Swiss French
Swiss German
Turkish
US Default
US Dvorak
Ukrainian
United Kingdom
~ # esxcli system settings keyboard layout get
US Default

To change the keyboard layout, the following command can be used. It’s
not persisted across reboot with the no-persist option.

~ # esxcli system settings keyboard layout set --layout="United Kingdom" --no-persist

Getting Uptime of the ESXi server


The first command is not that readable because the unit is microseconds.
You can try the second one for days of up time.

~ # esxcli system stats uptime get


3118666003442

~ # echo $(($(esxcli system stats uptime get)/86400000000))


36

Syslog management
You can mark the syslog by adding a unique message in the log. Why is it
needed? You can use it to mark start of new period for testing something,
so that you can later easily locate the start point.

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 57 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

~ # esxcli system syslog mark --message="DoubleCloud Inc."


~ # tail /var/log/syslog.log
2015-04-21T09:05:01Z syslog[2342114]: starting hostd probing.
2015-04-21T09:05:16Z syslog[2342114]: hostd probing is done.
2015-04-21T09:09:56Z smartd: [warn] t10.ATA_____Hitachi_HDS723020BLA642___________LENOV
2015-04-21T09:10:01Z crond[2488]: crond: USER root pid 2342297 cmd /sbin/hostd-probe
2015-04-21T09:10:01Z syslog[2340250]: starting hostd probing.
2015-04-21T09:10:16Z syslog[2340250]: hostd probing is done.
2015-04-21T09:15:01Z crond[2488]: crond: USER root pid 2342557 cmd /sbin/hostd-probe
2015-04-21T09:15:01Z syslog[2342558]: starting hostd probing.
2015-04-21T09:15:16Z syslog[2342558]: hostd probing is done.
2016-04-21T09:16:49Z mark: DoubleCloud Inc.

You can reload the log daemon to apply any new configuration options as
follows:

~ # esxcli system syslog reload

To retrieve syslog configuration, get command can be used:

~ # esxcli system syslog config get


Local Log Output:
Local Logging Default Rotation Size: 1024
Local Logging Default Rotations: 8
Log To Unique Subdirectory: false
Remote Host:

If you want to export the syslog to a remote syslog server, you can use the
set command as follows. You want to make sure the FQDN is resolvable,
which may involve the configuration of DNS as described earlier.

~ # esxcli system syslog config set --loghost=syslog.doublecloud.net


Failed to resolve remote host: syslog.doublecloud.net
~ # esxcli system syslog config set --loghost=192.168.0.1

To list all the loggers, run the following command. There are many other
loggers not listed due to limit of space.

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 58 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

~ # esxcli system syslog config logger list


Description: Default syslog catch-all
Destination: syslog.log
ID: syslog
Rotation Size: 1024
Rotations: 8

Description: VMware AMQP daemon log


Destination: vmamqpd.log
ID: vmamqpd
Rotation Size: 1024
Rotations: 8

Description: Host Agent Probe


Destination: hostd-probe.log
ID: hostd-probe
Rotation Size: 1024
Rotations: 8

To change a specific logger configuration like the rotation size and how
many rotations to keep, you can run the following command. The id must
be one in the above list output. The unit for the size is KiB.

~ # esxcli system syslog config logger set --id=vmamqpd --size=2048

To reset a specific value for a logger, run the following command:

~ # esxcli system syslog config logger set --id=vmamqpd --reset=size

Hypervisor File System


The following command shows a quick summary of the file system. You can
also drill down to the ramdisk and tardisk with the next two commands.

~ # esxcli system visorfs get


Total Inodes: 524288
Used Inodes: 2865
Unlinked Inodes: 0
Reserved Inodes: 0
Peak Used Inodes: 2933

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 59 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

Peak Unlinked Inodes: 1


Peak Reserved Inodes: 1
Free Inode Percent: 99
Lowest Free Inode Percent: 99

~ # esxcli system visorfs ramdisk list


Ramdisk Name System Reserved Maximum Used Peak Used Free Reserved Free
------------ ------ --------- ---------- -------- --------- ---- -------------
root true 32768 KiB 32768 KiB 460 KiB 480 KiB 98 %
etc true 28672 KiB 28672 KiB 224 KiB 252 KiB 99 %
tmp false 2048 KiB 196608 KiB 300 KiB 4236 KiB 99 %
hostdstats false 0 KiB 180224 KiB 3072 KiB 3072 KiB 98 %

~ # esxcli system visorfs tardisk list


Tardisk Name System Size
------------ ------ -----------
s.v00 true 364138000 B
ata_pata.v00 true 43996 B
ata_pata.v01 true 28828 B
ata_pata.v02 true 31544 B
ata_pata.v03 true 32651 B
ata_pata.v04 true 36912 B

Retrieving and Setting Hostname and


Domains
You can change the default hostname for esxi from the default localhost to
more meaningful domain and host name.

~ # esxcli system hostname set --fqdn esxi01.doublecloud.net


~ # esxcli system hostname get
Domain Name: doublecloud.net
Fully Qualified Domain Name: esxi01.doublecloud.net
Host Name: esxi01

When you set the hostname, you can use fqdn option or domain plus host.
They are mutually exclusive. I find fqdn is easy and straightforward.

Managing Maintenance Mode


You can place the ESXi into maintenance mode assuming you have

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 60 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

evacuated all the virutal machines.

~ # esxcli system maintenanceMode get


Disabled
~ # esxcli system maintenanceMode set --enable true --timeout=60

The default timeout for the set command is 60 seconds so the timeout can
be omitted in above command.

Power Management
You can either power off or reboot ESXi from the esxcli command. But
wait, why isn’t there a power on command? You will need a IPMI interface
for that.

Both reboot and power off operation requires the same parameters.

~ # esxcli system shutdown reboot --delay 10 --reason="Installing a new VIB"


~ # esxcli system shutdown poweroff --delay 10 --reason="Scheduled maintenance"

~ # esxcli system shutdown poweroff --help


Usage: esxcli system shutdown poweroff [cmd options]

Description:
poweroff Power off the system. The host must be in maintenance mode.

Cmd options:
-d|--delay= Delay interval in seconds
-r|--reason= Reason for performing the operation (required)

Configuring SNMP
There are a few parameters you can configure on ESXi. The following help
shows these parameters with some descriptions.

~ # esxcli system snmp set --help


Usage: esxcli system snmp set [cmd options]

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 61 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

Description:
set This command allows the user to set up ESX SNMP agent.

Cmd options:
-a|--authentication=
Set default authentication protocol. Values: none, MD5, SHA1
-c|--communities=
Set up to ten communities each no more than 64 characters. Form
community1[,community2,...] (this overwrites previous settings
-e|--enable Start or stop SNMP service. Values: [yes|no, true|false,
-E|--engineid= Set SNMPv3 engine id. Must be at least 5 to 32 hexadecimal character
if found as well as colons (:)
-y|--hwsrc= Where to source hardware events from IPMI sensors or CIM Indications
indications|sensors
-l|--loglevel= System Agent syslog logging level: debug|info|warning|error
-n|--notraps= Comma separated list of trap oids for traps not to be sent by agent.
to clear setting
-p|--port= Set UDP port to poll snmp agent on. The default is udp/161
-x|--privacy= Set default privacy protocol. Values: none, AES128
-R|--remote-users=
Set up to five inform user ids. Format is: user/auth-proto
/-|priv-hash/engine-id[,...] Where user is 32 chars max. auth-p
priv-proto is none|AES. '-' indicates no hash. engine-id is hex
to 32 chars max.
-r|--reset Return agent configuration to factory defaults
-C|--syscontact= System contact string as presented in sysContact.0. Up to 255
-L|--syslocation=
System location string as presented in sysLocation.0. Up to
-t|--targets= Set up to three targets to send SNMPv1 traps to. Format is: ip-or-
hostname[@port]/community[,...] The default port is udp/
settings)
-u|--users= Set up to five local users. Format is: user/-|auth-hash/-|priv-hash
user is 32 chars max. '-' indicates no hash. Model is one of
-i|--v3targets= Set up to three SNMPv3 notification targets. Format is: ip-or-hostna
user/security-level/trap|inform[,...].
~ # esxcli system snmp set --communities=system-monitor
~ # esxcli system snmp get
Authentication:
Communities: system-monitor
Enable: false
Engineid:
Hwsrc: indications
Loglevel: info
Notraps:
Port: 161
Privacy:
Remoteusers:
Syscontact:
Syslocation:
Targets:
Users:

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 62 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

V3targets:

Retrieving UUID
The following command retrieves the UUID for the host.
~ # esxcli system uuid get
50cdca40-8c57-2ee2-af75-8c89a5d2b40f

Reading and Setting System Time


ESXi keeps its own system clock. To read the time and set the time, you can
use the following commands:

~ # esxcli system time get


2015-04-21T07:22:21Z
~ # esxcli system time set --year 2016
~ # esxcli system time set --help
Usage: esxcli system time set [cmd options]

Description:
set Set the system clock time. Any missing parameters will default

Cmd options:
-d|--day= Day
-H|--hour= Hour
-m|--min= Minute
-M|--month= Month
-s|--sec= Second
-y|--year= Year

Getting ESXi Version and Build Number


The following simple command shows the version and build number of the
ESXi product.

~ # esxcli system version get


Product: VMware ESXi
Version: 5.1.0
Build: Releasebuild-799733

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 63 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

Update: 0

Change the ESXi welcome message


The following command changes the welcome message users see upon
login. It’s not necessary to change it, but if your IT has important policy to
information users upon login it’s a good way to do it.

~ # esxcli system welcomemsg set --message="DoubleCloud Welcomes You!"


~ # esxcli system welcomemsg get
DoubleCloud Welcomes You!

Managing Virtual Machines


Most virtual machine related operations can be done with vim-cmd
command. The esxcli command touches lower part of the virtual machine.
For the hypervisor, each running virtual machine acts like a process.

You can use the following command to list all the running virtual machine.
Instead of process id, each VM is identified by its world ID.

~ # esxcli vm process list


CentOS64Web
World ID: 879855
Process ID: 0
VMX Cartel ID: 924902
UUID: 42 0a d4 99 f0 17 25 bf-c4 35 e3 fd d1 19 0b 7f
Display Name: CentOS64Web
Config File: /vmfs/volumes/50cdcb68-6fc8e606-bb76-8c89a5d2b40f/CentOS64Web/CentOS64W

You can kill a virtual machine by its world ID as follows:

~ #esxcli vm process kill -t force -w 879855

There are other options as listed below, for example, soft type, hard type,

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 64 of 65
VMware ESXi esxcli Command: A Quick Tutorial | DoubleCloud => Private Cloud + Public Cloud 31/03/19, 1(47 PM

and the ultimate force type. With the force option, you can almost stop any
virtual machine.

~ # esxcli vm process kill --help


Usage: esxcli vm process kill [cmd options]

Description:
kill Used to forcibly kill Virtual Machines that are stuck and not responding to normal
stop operations.

Cmd options:
-t|--type= The type of kill operation to attempt. There are three types of VM kills tha
attempted: [soft, hard, force]. Users should always attempt 'soft' kills first,
which will give the VMX process a chance to shutdown cleanly (like kill or kill
-SIGTERM). If that does not work move to 'hard' kills which will shutdown the process
immediately (like kill -9 or kill -SIGKILL). 'force' should be used as a last resort
attempt to kill the VM. If all three fail then a reboot is required. (required)
-w|--world-id= The World ID of the Virtual Machine to kill. This can be obtained from t
list' command (required)

http://www.doublecloud.org/2015/05/vmware-esxi-esxcli-command-a-quick-tutorial/ Page 65 of 65