Archives For vSphere CLI

After my previous post about getting the iqn of an ESXi using esxcli Andy Banta (@andybanta) commented on Twitter that you can also change the iqn of the host with esxcli.

As he said it would be tremendously useful if you need to physically replace the server and don’t want to modify all your storage infrastructure, it’s easier to just modify the iqn of the new server and set it to the old name.

The task is as easier as the one described in last post. Using esxcli command with the iscsi namespace you can change the name and the alias of the adapter.

Screenshot from 2012-08-02 21_15_52

As a precaution first retrieve the current iqn to check that it’s the correct server.

Screenshot from 2012-08-02 21_20_08

To change the name you have to provide the adapter and the new name.

Screenshot from 2012-08-02 21_22_03

Hope you find this useful, any comments and suggestions are welcome as always.

Juanma.

Back in 2010 I wrote a post about how to get the iSCSI iqn of an ESXi 4.x server using vSphere CLI from the vMA or any other system with the vCLI installed on it.

The method described in that article is still valid for ESXi 5.0 since the old vicfg and esxcfg commands are still available, however with 5.0 version you can get a similar result using the new esxcli namespaces, following is how to do it.

First task is to get a list of the iSCSI HBAs in order to know the name of the software iSCSI initiator.

image

Next we get the info of the adapter.

image

Look at the Name field to get the iqn and we are done.

Juanma.

This a quick follow-up post to the How to check the driver version of a network interface in ESX(i) one. That post covered ESX(i) 4.x so I decided to write a small update for ESXi 5.0.

First I have to say that the two methods described in my first post still work in ESXi 5.0 Shell.

~ # vmware -l
VMware ESXi 5.0.0 GA
~ #
~ # vmkload_mod -s e1000 | grep Version
Version: Version 8.0.3.1-NAPI, Build: 456551, Interface: 9.2 Built on: Jul 29 2011
~ #
~ # ethtool -i vmnic0
driver: e1000
version: 8.0.3.1-NAPI
firmware-version: N/A
bus-info: 0000:02:00.0
~ #

Thanks to the new changes made by VMware in ESXi 5.0 we can now use esxcli to get the same result.

~ # esxcli system module get -m e1000
   Module: e1000
   Module File: /usr/lib/vmware/vmkmod/e1000
   License: GPL
   Version: Version 8.0.3.1-NAPI, Build: 456551, Interface: 9.2 Built on: Jul 29 2011
   Signed Status: VMware Signed
   Signature Issuer: VMware, Inc.
   Signature Digest: 1049 0611 a944 efc3 b683 341d 34b1 bebc 552d cb81 a874 ef4c 0562 8f25 2775 8c8d
   Signature FingerPrint: cb44 247a 1614 cea1 2079 362d ec86 9d0e
   Provided Namespaces:
   Required Namespaces: com.vmware.driverAPI@9.2.0.0, com.vmware.vmkapi@v2_0_0_0
~ #
~ # esxcli system module get -m e1000 | grep Version
   Version: Version 8.0.3.1-NAPI, Build: 456551, Interface: 9.2 Built on: Jul 29 2011
~ #

There is a big advantage on using esxcli over the other methods. In ESX(i) 4.x and ESXi 5.0 with the old procedure you had to be logged into the host but with esxcli it can be performed remotely using vSphere CLI.

vi-admin@vma:~[esxi5.vjlab.local]> esxcli system module get -m e1000
   Module: e1000
   Module File: /usr/lib/vmware/vmkmod/e1000
   License: GPL
   Version: Version 8.0.3.1-NAPI, Build: 456551, Interface: 9.2 Built on: Jul 29 2011
   Signed Status: VMware Signed
   Signature Issuer: VMware, Inc.
   Signature Digest: 1049 0611 a944 efc3 b683 341d 34b1 bebc 552d cb81 a874 ef4c 0562 8f25 2775 8c8d
   Signature FingerPrint: cb44 247a 1614 cea1 2079 362d ec86 9d0e
   Provided Namespaces:
   Required Namespaces: com.vmware.driverAPI@9.2.0.0, com.vmware.vmkapi@v2_0_0_0
vi-admin@vma:~[esxi5.vjlab.local]>
vi-admin@vma:~[esxi5.vjlab.local]> esxcli system module get -m e1000 | grep Version
   Version: Version 8.0.3.1-NAPI, Build: 456551, Interface: 9.2 Built on: Jul 29 2011
vi-admin@vma:~[esxi5.vjlab.local]>

But there is more, thanks to Get-EsxCli cmdleet the same operation can be done using PowerCLI, here it is how.

First we need to setup the esxcli instance.

image

And now we issue the command using the name of the module as the argument, please pay attention to the syntax.

image

As you should have imagined this procedure can be used to get info about any VMkernel module in the host, not just the network interface one,.

Juanma.

Like we found before for netstat there is no arp command available from within ESXi Tech Support Mode, so how can you list the ARP table entries if you need to? Or how can you do it remotely either with vCLI or PowerCLI?

In this quick post I’ll show you the different ways to list the ARP table entries of an ESXi server, as always both for ESXi4 and ESXi5.

Tech Support Mode

From ESXi Tech Support Mode we need to relay in esxcli.

ESXi4:

ESXi5:

vCLI

Again we need esxcli in order to get the ARP table.

PowerCLI

In this case we are going to use esxcli but trough the Get-EsxCli cmdlet. First we retrieve the esxcli instance and then we get the ARP table list.

ESXi4:

ESXi5:

Juanma.

We are going to suppose that you are trying to troubleshoot your ESXi network problems and as an experienced sysadmin one of the first things to do is getting the network connections of the host. But you are in ESXi and that means there is no netstat command, that handy Unix command that saved your life so many times in the past.

Please don’t panic yet, because as always in VMware there is a solution for that: esxcli to the rescue. Here it is the way to list the network connections of your ESXi host, both for ESXi 4.1 and ESXi 5 :-)

ESXi 4.1

I tested it in ESXi 4.1 and ESXi 4.1 Update 1. The network namespace is not available in ESXi 4.0.

ESXi 5

I used Remote Tech Support (SSH), simply known as SSH in ESXi5, in both examples but you can also launch the command from the vMA or using vSphere CLI from a Windows or a Linux machine.

vMA 4.1

[vi-admin@vma ~]$ esxcli --server=arrakis.jreypo.local --username=root network connection list

vMA 5

vi-admin@vma5:~> esxcli --server=esxi5.jreypo.local --username=root network ip connection list

Juanma.

One of features I like the most of esxtop/resxtop is the ability to create customized configurations. This feature gives you the ability to have several pre-defined configuration files to be used under certain circumstances, for example you can have one only to check if there are virtual machines swapping during a heavy workload period.

The post will cover esxtop 4.x, the version that comes with vSphere 4.x, however it can be applicable to previous versions as well. First it’s important to know that by default esxtop/resxtop stores its configuration in the file .esxtop4rc, in the vMA this file is stored in the vi-admin user home directory and in the root home directory in the ESX(i) servers.

Now lets create one as an example. I’m using resxtop from the vMA so first launch it against the vCenter Server and select one of the ESX(i) hosts.

Now you should see the default esxtop screen. We are going to create a configuration that show only some of the memory related counters.

Show the memory screen by pressing m and from there press f to edit the fields to display.

Press the corresponding keys to enable/disable the fields and a or o keys to toggle its order, then press the space bar to finish. Next esxtop returns the memory view and show the newly selected counters.

At this point you can customized the field to display in the other views (CPU, network, etc). When you are done press W to save the config and enter the file name to save the new config in. If you don’t enter a file name esxtop will save the changes in its default config file, /home/vi-admin/.esxtop4rc in the example.

Exit esxtop and run it again but loading the saved config file, instead of the default one, by using -c <config_file>.

Finally my advise is to read carefully the Interpreting esxtop 4.1 Statistics document and use the counters that better suits your needs.

Juanma.

When you are trying to configure iSCSI of and ESX(i) server from the command line is clear that at some point you are going to need the iqn. Of course you can  use the vSphere Client to get the iqn but the Unix Geek inside me really wants to do it from the shell.

After a small research through the vSphere CLI documentation and several blogs I found this post by Jon Owings (@2vcps).

First list the SCSI devices available in the system to get the iSCSI hba.

[root@esx02 ~]# esxcfg-scsidevs -a
vmhba0  mptspi            link-n/a  pscsi.vmhba0                            (0:0:16.0) LSI Logic / Symbios Logic LSI Logic Parallel SCSI Controller
vmhba1  ata_piix          link-n/a  ide.vmhba1                              (0:0:7.1) Intel Corporation Virtual Machine Chipset
vmhba32 ata_piix          link-n/a  ide.vmhba32                             (0:0:7.1) Intel Corporation Virtual Machine Chipset
vmhba33 iscsi_vmk         online    iscsi.vmhba33                           iSCSI Software Adapter         
[root@esx02 ~]#

After that Jon uses the command vmkiscsi-tool to get the iqn.

[root@esx02 ~]# vmkiscsi-tool -I -l vmhba33
iSCSI Node Name: iqn.1998-01.com.vmware:esx02-42b0f47e
[root@esx02 ~]#

Beauty, isn’t it? But I found one glitch. This method is done from the ESX root shell but how do I get the iqn from the vMA? Some of my hosts are ESXi and even for the ESX I use the vMA to perform my everyday administration tasks.

There is no vmkiscsi-tool command in the vMA, instead we are going to use the vicfg-iscsi or the vicfg-scsidevs command.

With vicfg-scsidevs we can obtain the iqn listed in the UID colum.

[vi-admin@vma ~][esx02.mlab.local]$ vicfg-scsidevs -a             
Adapter_ID  Driver      UID                                     PCI      Vendor & Model
vmhba0      mptspi      pscsi.vmhba0                            (0:16.0) LSI Logic Parallel SCSI Controller
vmhba1      ata_piix    unknown.vmhba1                          (0:7.1)  Virtual Machine Chipset
vmhba32     ata_piix    ide.vmhba32                             (0:7.1)  Virtual Machine Chipset
vmhba33     iscsi_vmk   iqn.1998-01.com.vmware:esx02-42b0f47e   ()       iSCSI Software Adapter
[vi-admin@vma ~][esx02.mlab.local]$

And with vicfg-iscsi we can get the iqn providing the vmhba device.

[vi-admin@vma ~][esx02.mlab.local]$ vicfg-iscsi --iscsiname --list vmhba33
iSCSI Node Name   : iqn.1998-01.com.vmware:esx02-42b0f47e
iSCSI Node Alias  :
[vi-admin@vma ~][esx02.mlab.local]$

The next logical step is to use PowerCLI to retrive the iqn, but I’ll leave that for a future post.

Juanma.