Monday, January 19, 2015

www_section

http://www.tomsitpro.com/articles/vmware-esx-esxi-troubleshooting,2-810.html

Using the esxcfg Utilities

On ESXi 4.1 update 3 hosts, there are 20 utilities that all share the common esxcfg- prefix. To look at usage syntax for these commands, enter the following at a host prompt:
# esxcfg-<utility> - - help
The <utility> is one of the 20 unique utility identifiers. The esxcfg utilities include:
  1. esxcfg-advcfg
  2. esxcfg-dumppart
  3. esxcfg-hwiscsi
  4. esxcfg-info
  5. esxcfg-init
  6. esxcfg-ipsec
  7. esxcfg-module
  8. esxcfg-mpath
  9. esxcfg-nas
  10. esxcfg-nics
  11. esxcfg-pciid
  12. esxcfg-rescan
  13. esxcfg-resgrp
  14. esxcfg-route
  15. esxcfg-scsidevs
  16. esxcfg-secpolicy
  17. esxcfg-swiscsi
  18. esxcfg-vmknic
  19. esxcfg-volume
  20. esxcfg-vswitch
Most of these utilities can be used with the –l switch, which lists information about your host system. Gathering a baseline can help you troubleshoot your system when future problems arise. To that end, once you've installed your ESX or ESXi system and have established your datastores, networks, and switches; you should capture your system information to files and then transfer them to a central repository.

For example, execute the following three commands on your system to gather route and NIC information.
# esxcfg-route –l > balvenie-route.txt
Figure 1: Checking the default route configuration on an ESXi host.
 # esxcfg-nics –l > balvenie-nics.txt
Figure 2: Displaying physical NIC information.
# esxcfg-vmknic –l > balvenie-vmknic.txt
Figure 3: Displaying ESXi host virtual network adapter information.
#esxcfg-vswitch –l > balvenie-vswitch.txt
Figure 4: Gathering virtual switch information.

Collect all the information from your host and transfer it to your workstation or network drive for future reference. If you experience a failure or have to reinstall a host system, you can refer to these documents to rebuild the new system with the same configuration as the old one.

Once you've gathered all of your host system's information, you find that you want to change a particular parameter. For example, you find from running the esxcfg-info utility that the NFS MaxVolumes setting currently configured on your system is eight, which is the default. The maximum possible setting is 64. See Figure 5.
Figure 5: Examining esxcfg-info NFS MaxVolumes configuration information.

You want to change this host's setting to 16. To change values observed from esxcfg-info, you must use the esxcfg-advcfg utility.
# esxcfg-advcfg -s 16 /NFS/MaxVolumes
Value of MaxVolumes is 16
This command sets the MaxVolumes setting to 16.

The esxcfg-info command gives you the setting value and the parameter name that you'll need in order to make changes to your system using the esxcfg-advcfg utility. If you know the parameter name, you can query it directly using the esxcfg-advcfg utility.
# esxcfg-advcfg –g /NFS/MaxVolumes
Value of MaxVolumes is 16
You can issue the esxcfg-advcfg –g (get) command at any time to have a look at the current value of a setting.
One word of caution before we leave the discussion of the esxcfg utilities: Use extreme discretion when issuing esxcfg-init commands. Generally speaking, you should only issue these commands under direction either of an advanced VMware Administrator or of a VMware Support Technician.

Using the esxcli Utility

The general syntax of the esxcli utility is:
esxcli [dispatcher options] <namesspace> <object> <command> [options]
The esxcli utility might remind you of the very powerful Windows utility "netsh" in that they both use namespaces or contexts within you can view or alter various settings and configurations. The six namespaces that you can use with esxcli are:
  • corestorage -- VMware core storage commands
  • network -- Networking commands
  • nmp -- Native Multipath Plugin (NMP)
  • swiscsi -- iSCSI commands
  • vaai -- VAAI Namespace containing vaai code
  • vms -- Limited virtual machine operations
As I stated earlier, there are a few missing native utilities from a basic Linux installation in BusyBox. One of those missing utilities is "netstat." The netstat utility can diagnose a number of network problems including "hung" daemons, network connectivity issues, and ports that aren't listening. You can also detect certain network "attacks" using netstat. However, the esxcli utility replaces netstat.

To understand the statement that esxcli replaces netstat issue the following command:
# esxcli network connection list
You will see a list of tcp and udp listening ports, established ports, some TIME_WAIT, CLOSE_WAIT, and FIN_WAIT statuses.

Another interesting use of esxcli is to kill virtual machines that are "stuck" and not responding to normal stop operations. This situation occurs when a host has experienced some fault and can't be placed into maintenance mode without some intervention. It's not recommended to use the "kill" functionality under normal circumstances.
To use esxcli kill, first list the host's virtual machines that are still powered on:
# esxcli vms vm list
Figure 6: Listing the powered on virtual machines.

To kill a virtual machine, you have to supply the type of kill: soft, hard, or force. You also have to supply the virtual machine's World ID. Requiring these explicit parameters avoids accidentally killing virtual machines by using the virtual machine name only.
# esxcli vms vm kill –t soft –w 29156592
You should attempt to kill an errant virtual machine with soft, hard, and force in that order so that critical data isn't lost in the process.

If the "kill" command is successful, another "esxcli vms vm list" will return no data.

Exploring the 'vm' Commands

Of the list of 25 "vm" commands under /sbin, you'll find a few useful utilities that you can use for troubleshooting. Three of the utilities are extended variants of the "lite" versions contained in BusyBox. They are: vmkping, vmtar, and vmcp. These versions function like the open source versions that you're used to having access to on your Linux systems. Use them instead of the standard system ping, tar, and cp. Note that the system ping command is a symbolic link to the /sbin/vmkping executable.

The "vmware" utility displays your version information. Have this information ready to give to a VMware support technician or to add to your incident ticket on the VMware incident support website.
# vmware –l
VMware ESXi 4.1.0 Update 3
# vmware –v
VMware ESXi 4.1.0 build-800380

For major troubleshooting, VMware support will likely prompt you to run the "vm-support" utility. This utility thoroughly checks your system and may take several minutes to complete. While running, you'll see a status checker and updates:
# vm-support –l

Preparing files: /

When complete, the system gives you instructions that include:
  • The name of the collected support file.
  • The incident support website.
  • How to view the collected files.
Your VMware support professional might ask you to use different switches when gathering system information. You'll have to transfer the collected files and send them to the VMware support tech via email or upload to a support site via FTP.

The vmdumper utility is a unique one for troubleshooting. Using it, you can successfully BSOD a Windows system or kernel panic a Linux system. To do so, issue the following command to list any running virtual machines:
#vmdumper –l

wid=31885225  pid=-1  cfgFile="/vmfs/volumes/531f2d35-24323028-8423-0019b9b8fe1b/Automat/Automat.vmx" uuid="42 11 ad 85 88 38 ab d7-b4 d1 0d 35 ce 6c c0 b0"  displayName="Automat" vmxCartelID=31881128
The important pieces of information from this response are the displayName and the World ID (wid). You need the displayName to verify that you are crashing the correct system and the World ID is required for the vmdumper command.
# vmdumper [World ID] nmi

# vmdumper 31885225 nmi

Sending NMI to guest...

Figure 7 below shows the screen of a Linux virtual machine (CentOS 6.5). The system received the NMI, but didn't fail.
Figure 7: A Linux VM displaying the results of an NMI.

Unfortunately, a fully patched Windows 2008 R2 Server virtual machine wasn't as resilient. See Figure 8.Figure 8: Crashing a Windows virtual machine with an NMI signal.

VMware ESXi hosts provide the savvy administrator with 50 or so command line utilities for advanced data gathering and troubleshooting. ESX hosts and virtual management appliances (vMAs) boast a few more plus the full array of system utilities. You should familiarize yourself with connecting directly to your host systems via SSH in case you ever have to contact VMware Technical Support.

---------------
http://www.unixarena.com/2014/02/unable-power-virtual-machine-esxi-5-5-host.html

Unable to Power off Virtual Machine on ESXi 5.5 host
In some rare scenarios where you can’t even power off the virtual machine on VMware ESXi. This happens if the virtual host lost the I/O path  or some issues related to I/O subsystems.In this situation,when you tried to power off the virtual machine,you will get error messages like “The operation can’t be allowed at the current time because the virtual machine has  a question pending”.
In my case what i have done is that , attached the ISO file to virtual machine from one of the datastore and unfortunately lost the SAN path to that. So the virtual machine which i connected to ISO datastore went to “question pending” state and i am not able to reset or power off the host after that.
Here we will see how we can fix this issue on VMware ESXi 5.5.
1.Open the browser and connect to VCenter web-client.
Question Pending - VM guest state
Question Pending – VM guest state
2.I tired to power off the virtual guest but getting below error.
Question Pending -  Error Log
Question Pending – Error Log
3. Login to ESXi host where the virtual machine is running using ssh. In my case its 192.168.2.50
login as: root
Using keyboard-interactive authentication.
Password:
The time and date of this login have been sent to the system logs.

VMware offers supported, powerful system administration tools.  Please
see www.vmware.com/go/sysadmintools for details.

The ESXi Shell can be disabled by an administrative user. See the
vSphere Security documentation for more information.
~ #
4.List the specific virtual machine process using ps command.
~ # ps -s |grep vmx |grep Solaris11
44991 44991 vmx                  WAIT   UPOL   0,1  /bin/vmx
44998 44991 vmx-vthread-4:Oracle Solaris11 WAIT   UFUTEX 0,1  /bin/vmx
44999 44991 vmx-vthread-5:Oracle Solaris11 WAIT   UFUTEX 0,1  /bin/vmx
45000 44991 vmx-mks:Oracle Solaris11 WAIT   SEMA   0,1  /bin/vmx
45001 44991 vmx-svga:Oracle Solaris11 WAIT   SEMA   0,1  /bin/vmx
45002 44991 vmx-vcpu-0:Oracle Solaris11 WAIT   IDLE   0,1  /bin/vmx
~ #
5.Try to kill the vpcu process of the guest using kill command.
~ # kill 45002
~ #
Still if the process is live ,use -9 signal to kill it.
~ # kill -9 45002
6.Check whether vmx process is running for that impacted virtual guest.If there is no process ,we are good to proceed to next step.If any process is running for that guest,kill those process as well.
~ # ps -s |grep vmx |grep Solaris11
~ #
7.Go back to web-client and try to power of the virtual machine now.
Power of the virtual guest
Power of the virtual guest
You may get the below notification.Just ignore it.
Power of Notification-VMware
Power of Notification-VMware
8.Edit the virtual machine and remove if you attached any file from non-existing datastore. (Ex:ISO files)
9.Tradition VSphere Client can’t edit the virtual machine since newer version(10) of virtual machines are  only supported by VSphere web-client.You will get error like below one if you tried to edit from VSphere Client.
Unable to edit virtual machine -VMware
Unable to edit virtual machine -VMware
10.Now you can power on the virtual machine.
power on virtual machine -VMware
power on virtual machine -VMware
11.You can see virtual machine is powered on and its booting solaris11.
Solaris virtual guest on ESXi
Solaris virtual guest on ESXi
Hope this article may help you to fix the issue.Please add in the comment if you have anything to share about this issue.


http://www.unixarena.com/2014/02/get-vmware-esxi-vcenter-license-keys.html

Managing the license on VMware ESxi and VCenter is one of main job for system administrator.After the installation of the product, you may need to add the new license to increase the capacity and you may need to remove the old license keys from the those products. Sometimes you may need to pull out the existing  license keys for inventory purpose. Here we will see how we can manage the ESXi and VCenter server licence using VSphere Client .
How we can get the installed license keys of VMware ESXI servers and VCenter Server ?
1. Login to VSphere Client and navigate it home.
VMware Esxi & VCenter License
VMware Esxi & VCenter License
2.Navigate to Administration and Licensing .Here you can see the existing license of Vmware ESXI nodes and VCenter Server.
License Keys of VMware Esxi and Vcenter Server
License Keys of VMware Esxi and Vcenter Server
3.In order to install or remove the existing License keys , you need to click on “Manage VSphere Licenses” (Step:2). This will popup the below window to manage the VSphere License keys.If you want to add any new license keys , you can just copy & paste one by one.
Managing the License Keys of VSphere
Managing the License Keys of VSphere
4.The next step will be assigning the specific license keys to the products.In some cases, license may be purchased to run some limited VM’s and that needs to assigned to specific host.In this case ,you need to assign the license keys manually.For ESXi , you need to click on the first tab. The below window shows vCenter Server licenses(Second tab).If you want to remove any existing license keys ,you can remove it using the next step. Once you have done,you click on the confirm changes.
Assigning the License keys
Assigning the License keys
5.You can also extract the reports from the reporting tab. (Refer Image Step:2). Once you click on the reporting tab , you will get window like the below one.You can just click export to get the details in Excel sheet.It provides complete usage details of the installed license details.
VSphere Licenses Reports
VSphere Licenses Reports
when we are talking about VSphere licensing , i just want to let you know about the free license of ESXi and vCenter Server. VMware offers 60 evaluation period for vCenter Server and ESXi .So you need to search for free license keys of Vmware ESXi and vCenter server . You can install and test these products with complete features for 60 days. After 60 days ,you may need to install the license keys to keep working on these products. vCenter will not allow to administrate the ESXi nodes after 60 days without valid license keys.
The below tables provides the licensing requirements of newer version of VMware ESXi and vCenter Server.
ata Center Virtualization and Cloud Infrastructure
Existing product versionVersion to be upgraded toIs a new key required?The SnS Contract for the product is active, can the license key be upgraded in My VMware Portal?
vCloud Suite (Standard, Advanced and Enterprise)5.15.5NoThe existing license key also unlocks version 5.5
5.5-NoThis is the latest version
vSphere or ESXi (Essentials, Essentials Plus, Standard, Enterprise and Enterprise Plus)4.x5.0 or 5.1 or 5.5Yes
Yes.
55.1 or 5.5NoThe existing license key also unlocks version 5.1 and 5.5
5.15.5NoThe existing license key also unlocks version 5.1 and 5.5
5.5-NoThis is the latest version
vSOM – vSphere with Operations Management (Standard, Enterprise and Enterprise Plus)5.15.5Yes
Yes.
5.5-NoThis is the latest version
vCenter Server (Standard and Foundation)4.x4.x or 5.0 or 5.1 or 5.5Yes
Yes.
55.1 or 5.5NoThe existing license key also unlocks version 5.0, 5.1 and 5.5
5.15.5NoThe existing license key also unlocks version 5.1 and 5.5
5.5-NoThis is the latest version
Thanks to VMware.

 http://www.v-front.de/2013/09/how-to-update-your-standalone-host-to.html
http://www.v-front.de/2014/03/how-to-update-your-standalone-host-to.html
http://www.vladan.fr/easily-upgrade-esxi-5-x-to-the-latest-esxi-5-5-update-1-via-cli/
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2008939
http://www.vladan.fr/esxi-5-unresponsive-vm-h/
http://www.yellow-bricks.com/2009/04/15/the-basics-how-to-kill-a-vm-thats-stuck-during-shutdown/
http://www.virtualizationadmin.com/articles-tutorials/vmware-esx-and-vsphere-articles/general/how-to-access-the-vmware-esxi-hidden-console.html

MonitorEsxiVMS

http://blogs.vmware.com/smb/2013/12/back-to-basics-managing-vmware-esxi-5-5-direct-user-interface-dcui.html


Managing VMware ESXi 5.5 Direct Console User Interface (DCUI)

Post By Mike Laverick, VMware, Senior Cloud Infrastructure Evangelist
This is a repost from Mike Laverick’s blog, mikelaverick.com
Well, it’s time for another post in my all-new “back to basics” series. That’s my term for wiping down my lab environment and deploying vSphere5.5 – and trying to reacquaint myself with all that vSphere knowledge that was once at my finger tips. This time its the turn of the DCUI.
The Direct Console User Interface (DCUI) is the front-end management system that allows for some basic configuration changes and troubleshooting options should the VMware ESXi host become unmanageable via conventional tools such as the vSphere Client or vCenter.
Screen Shot 2013-10-21 at 13.24.32.png
Typical administration tasks include:
  • Reset ‘root’ password
  • Configure Lockdown mode
  • Configure, Restart, Test and Restore the VMware ESX Management Network
  • Restart Management Agents
  • Configure Keyboard
  • Troubleshoot
  • View System Logs
  • Reset System Configuration (Factory Reset)
  • Shutdown/Restart the VMware ESX Host
Most actions are carried out by using [F2] on the keyboard or [F11] confirm changes, along with typical options such as [Y] and [N] to various system prompts. Before carrying out any task you will be required to supply the ‘root’ password. However, the first law of security is to secure the physical server – so take care to ensure your access to ILO/RAC/BMC interfaces are properly secured. Although the VMware ESX host can be rebooted from the DCUI this is regarded as an action of last resort. If the VMware ESX hosts has running VMs these will crash, and may or may not be restarted on other hosts depending on whether they are part of a cluster.

Back To Basics: Managing VMware ESX Direct User Interface (DCUI)


I’ve put together a demo video that guides you through the main functionality of the DCUI. There’s two version a youtube version – which if you make go full-screen and set the resolution quality to the max, and should display without a problem. There’s also “native quality” mp4 that streams directly from my site.
Show Me How: Installing VMware ESX Video – Native Quality

Reset ‘root’ password

You may need to reset the ‘root’ password because an inappropriate one was initially assigned, or it has become disclosed to individuals who should be denied access. There are easier ways to change the root password using the vSphere Client, and if you need to change the ‘root’ account password for many hosts (say on a quarterly basis) you might find VMware’s PowerCLI and other scripting automation tools are a better approach.
Whilst special characters are supported with the ‘root’ passwords there have been reported cases of certain character types causing a problem. Generally, if you stick with alphanumerics and common characters such as !@%&*()}{|”:?><,./\’;][ then you should have no problem. Aviod special characters which are region or culturally specific.
Update: According to recent reports the VMware ESX 5.5 host appears have a problem with the $ symbol. This is something I've seen in other password environment where the UK pound symbol £ is not supported.
1. Open a console window to the physical VMware ESX hosts
2. Press [F2] on the keyboard, and supply your current ‘root’ logon password and press [ENTER]
Screen Shot 2013-10-21 at 13.44.10.png
3. Select “Configure Password” and press [ENTER]
4. Supply the old password together with two copies of the new password, and press [ENTER]
Screen Shot 2013-10-21 at 13.46.41.png
NOTE: To carry out this same task in VMware PowerShell first authenticate to the VMware ESX host, and use the “Set-VMHostAccount” cmdlet.
Screen Shot 2013-10-21 at 14.01.16.png
Set-VMHostAccount -UserAccount root -password Password1

Configure, Restart, Test and Restore the VMware ESX Management Network

The installation of VMware ESX defaults to assigning the first network card discovered to the management network, and configuring the host for a DHCP assigned address. This might be unsuccessful depending on how the physical server is patched to the switch, and whether a DHCP server is present on the network. Additionally, the physical switch maybe configured for VLANs. The default installation of VMware ESX does not allow for the setting of VLAN Tags until after the vmkernel has been loaded, and the DCUI enabled.
Almost all of the changes made in the “Configure Management Network” require a restart of the networking for the management of the ESX host. This is something you will prompted to do when ever you exit these pages.
Screen Shot 2013-10-21 at 16.35.33.png
The following instructions are illustration of changing the default physical NIC, setting the VLAN value and configuring a static IP options.

Network Card Assignment

1. Open a console window to the physical VMware ESX hosts
2. Press [F2] on the keyboard, and supply your current ‘root’ logon password and press [ENTER]
Screen Shot 2013-10-21 at 13.44.10.png
3. Use the cursor keys to scroll down and select “Configure Management Network” and press [ENTER]
4. Select “Network Adapters” and press [ENTER]
5. Using the [SPACEBAR] and cursor keys you can select network interfaces. In the screen grab below two physical NICs (vmnic0 and vmnic1) have been allocated to the VMware ESX host. This will automatically offer out of the box load-balancing and redundancy.
Screen Shot 2013-10-21 at 15.31.36.png

VLAN Configuration

1. Open a console window to the physical VMware ESX hosts
2. Press [F2] on the keyboard, and supply your current ‘root’ logon password and press [ENTER]
Screen Shot 2013-10-21 at 13.44.10.png
3. Use the cursor keys to scroll down and select “Configure Management Network” and press [ENTER]
4. Select “VLAN (Optional)” and press [ENTER]
5. Type in the VLAN ID value, and press [ENTER]
Screen Shot 2013-10-21 at 15.43.16.png

IP Configuration

1. Open a console window to the physical VMware ESX hosts
2. Press [F2] on the keyboard, and supply your current ‘root’ logon password and press [ENTER]
Screen Shot 2013-10-21 at 13.44.10.png
3. Use the cursor keys to scroll down and select “Configure Management Network” and press [ENTER]
4. Scroll down and select “IP Configuration” and press [ENTER]
Screen Shot 2013-10-21 at 16.20.11.png
5. Complete the IP configuration as it befits your local network requirements:
Screen Shot 2013-10-21 at 16.20.11.png
6. The DNS settings can be modified by selecting “DNS Configuration” and press [ENTER]. The DNS Configuration allows for the setting of a primary and secondary DNS server, together with the short “hostname”. The fully-qualified domain name (FQDN) is completed by configuring the “DNS Suffix” options
Screen Shot 2013-10-21 at 16.34.22.png
Screen Shot 2013-10-21 at 16.35.09.png
7. The IP Configuration can be tested using the “Test Management Network” options. This allows the SysAdmin to test communication to the router (if present) and the DNS servers on the network – as well as confirming the hostname is resolvable to via DNS.
Screen Shot 2013-10-21 at 17.12.41.png
Screen Shot 2013-10-21 at 17.13.00.png
IMPORTANT: Although the test here passed on the hostname, the test merely checks to see if the hostname is present on the DNS server. It does not verify if the hostname (or ANAME record) is valid or pointing at the correct address. As such this means you could still have incorrect entries in the DNS database. It’s recommend to use a utility like nslookup to confirm that both forward and reverse DNS looks resolve to the correct name.
Screen Shot 2013-10-21 at 19.52.01.png

Restore Network Configuration

Restoring the network configuration is quite a dangerous option if not used correctly. It has the potential to reset the network to such a state that you will not be able to communicate to the VMware ESX host without resorting to the DCUI to resume communication. It also has the possibility of disconnecting virtual machines (VMs) that are running on the VMware ESX host. Additionally, it has the ability to remove standard and distributed virtual switches (vSwitch) from the host in event that these have become broken on the host beyond repair.
CAUTION: As such you should approach these options with extreme care.
1. Open a console window to the physical VMware ESX hosts
2. Press [F2] on the keyboard, and supply your current ‘root’ logon password and press [ENTER]
Screen Shot 2013-10-21 at 13.44.10.png
3. Use the cursor keys to scroll down and select “Network Restore Options” and press [ENTER]
4. Select the Restore option required, and press [ENTER]. In the following case the option “Restore Network Settings” was selected.
Screen Shot 2013-10-21 at 17.24.49.png

Configure Keyboard

Whilst the VMware ESX host keyboard settings can be configured during installation, it possible to modify this after the installation itself.
1. Open a console window to the physical VMware ESX host
2. Press [F2] on the keyboard, and supply your current ‘root’ logon password and press [ENTER]
Screen Shot 2013-10-21 at 13.44.10.png
3. Use the cursor keys to scroll down and select “Configure Keyboard” and press [ENTER]
4. Use the cursor keys to highlight the preferred language, and then spacebar to select the new keyboard type. Press [ENTER] to make the change.
Screen Shot 2013-10-21 at 19.02.41.png

Troubleshooting Options

Restart Management Agents

In the early days of VMware ESX occasionally the host would appear as being “disconnected” in the management system of vCenter. Although the host has a “WatchDog” service designed to restart the core management agent, this would be unsuccessful. In recent years these random disconnections have been resolved – and its now highly unusual for an VMware ESX host to enter a disconnected state. Nowadays, if this happens its is more normally another cause such as an IP conflict, or the host being rebooted in non-authorised manner or some type of hardware failure. Nonetheless, the option to restart management agents does exist in the DCUI. If you do use this option you will need to be patient as it can take time for other systems to “retry” the connection and reconnect to the host.
1. Open a console window to the physical VMware ESX host
2. Press [F2] on the keyboard, and supply your current ‘root’ logon password and press [ENTER]
Screen Shot 2013-10-21 at 13.44.10.png
3. Use the cursor keys to scroll down and select “Troubleshoot Options” and press [ENTER]
4. Use the cursor keys to scroll down to “Restart Management Agents” and press [ENTER]. In the following page not only do you have the option to simply restart the management agents, but also collect extra troubleshooting information. Notice the warning about this disconnects all existing remote management software.
Screen Shot 2013-10-21 at 17.42.29.png

Enabling ESXi Shell and SSH together with Timeout Values

It is possible to get true command-line access to the VMware ESX host. This can be either by the “ESXi Shell” normally access via the ILO/RAC/BMC card or using the Secure Shell protocol (SSH) commonly access on TCP port 22 using a SSH client like PuTTy. In addition to these options being enabled they can be enabled for a designated period as well, to allow temporary console access. This is prevents the need to have protocols like SSH enabled all the time, which could be regarded by some as a security weakness. If you do have a require to permanently enabled SSH access this can be done from the “Security Profile” on the VMware ESX host either with the vSphere Client or using vCenter with the Web-Client.
Important: If you intend to set timeout values you must set these before enabling the ESXi Shell and/or SSH.
1. Open a console window to the physical VMware ESX host
2. Press [F2] on the keyboard, and supply your current ‘root’ logon password and press [ENTER]
Screen Shot 2013-10-21 at 13.44.10.png
3. Use the cursor keys to scroll down and select “Troubleshoot Options” and press [ENTER]
4. Use the cursor keys to select “Modify ESXi Shell and SSH Timeouts”, and press [ENTER]. Configure the durations for the “Availability Timeout” and “Idle Timeout”. A zero value can be specified which indicates that sessions never expire.
Screen Shot 2013-10-21 at 18.34.07.png
5. Next we can Enable the ESXi Shell and SSH. These a toggle options where pressing [ENTER] switches the option from “Enable…” to “Disable…”
Screen Shot 2013-10-21 at 18.38.06.png
6. Accessing the ESXi Shell requires exiting the DCUI back to the main screen and then pressing [ALT+F1] on the keyboard. The keystroke [ALT+F2] will toggle the SysAdmin back to the DCUI. Typing the command ‘exit’ at the ESXi Shell prompt logs the SysAdmin out of the environment.
Screen Shot 2013-10-21 at 18.44.31.png
7. Accessing the ESXi SSH Service requires a SSH Client. For Windows systems the most popular is the free PuTTy tool. Linux and Apple support their own native SSH command-line utilities.
Screen Shot 2013-10-21 at 18.53.19.png
Unsupported Tip: The DCUI is a process like any other on the VMware ESXi host. It is possible to access the DCUI from a SSH session using PuTTy. This is not a support usage, and it runs the risk of disconnecting the very SSH session that allows it work. The DCUI is accessed from the SSH session by typing the command “dcui” and the SysAdmin can exit the shell using the keystroke [CTRL+C]
Screen Shot 2013-10-21 at 18.56.06.png

View System Logs

There many ways of viewing and gathering the system logs from a VMware ESX host. Viewing them via the DCUI is perhaps least friendly method but it is possible.
1. Open a console window to the physical VMware ESX host
2. Press [F2] on the keyboard, and supply your current ‘root’ logon password and press [ENTER]
Screen Shot 2013-10-21 at 13.44.10.png
3. Use the cursor keys to scroll down and select “View System Logs” and press [ENTER]
4. Pressing a number on the keyboard from 1-6 will allow you to view the system logs, and [Q] on the keyboard will quit the log view, and return the SysAdmin back to the DCUI screen.
Screen Shot 2013-10-21 at 19.18.40.png
Screen Shot 2013-10-21 at 19.19.13.png

Reset System Configuration (Factory Reset)

A “Reset System Configuration” (or more commonly referred to as a ‘factory reset’) reconfigures the ESX host back to its initial installation. This achieve by maintain various system states between reboots. Before issuing a “Reset System Configuration” its is recommended to carry out a manual backup of the VMware ESX host. This can be done using the command vicfg-cfgbackup or PowerCLI.
IMPORTANT: A reset of the VMware ESX host also resets the root password back to being blank. As consequence all previous passwords including the one configured at the installation are lost.
1. Open a console window to the physical VMware ESX host
2. Press [F2] on the keyboard, and supply your current ‘root’ logon password and press [ENTER]
Screen Shot 2013-10-21 at 13.44.10.png
3. Use the cursor keys to scroll down and select “Reset System Configuration” and press [ENTER]. Next press [F11] to confirm you wish to carry-out the reset, followed by [ENTER] to confirm a reboot of the system.
Screen Shot 2013-10-21 at 19.30.00.png
Screen Shot 2013-10-21 at 14.01.16.png
Get-VMHostFirmware -VMHost esx01nyc.corp.com -BackupConfiguration -DestinationPath C:\
Set-VMHostFirmware -ResetToDefaults
Note: This will back up the VMware ESX host called “esx01nyc.corp.com”. After the backup has completed a zip file in the .tgz format will be created called C:\configBundle-esx01nyc.corp.com.tgz. The cmdlet “Set-VMHostFirmware” has the capacity to send the reset process to the host as well.

Shutdown/Restart the VMware ESX Host

There are many ways to shutdown or reboot the VMware ESX host. By far the most appropriate method would be use vCenter “maintenance mode” which in conjunction with the VMotion and the Distributed Resource Schedule (DRS) feature successfully evacuate all the VMs from the host, before a shutdown or reboot instruction is given. You should exhaust all reasonable efforts to gain control over the the VMware ESX host to carry out a graceful outage of the host. Only use the power button or the shutdown/restart functionality of the DCUI if you have no other option.
1. Open a console window to the physical VMware ESX host
2. Press [F12] on the keyboard, and supply your current ‘root’ logon password and press [ENTER]
Screen Shot 2013-10-21 at 20.08.11.png
3. Pressing [F2] on the keyboard will trigger a shutdown, whereas pressing [F11] will trigger a reboot. Before using the [F2] ensure you have suitable access to trigger a power on of the physical server!
Screen Shot 2013-10-21 at 14.01.16.png
Set-VMHost esx01nyc.corp.com -State maintenance
Restart-VMHost -vmhost esx01nyc.corp.com



http://blogs.vmware.com/smb/2013/12/back-to-basics-managing-vmware-esxi-5-5-direct-user-interface-dcui.html
http://www.virtualizationadmin.com/articles-tutorials/vmware-esx-and-vsphere-articles/general/how-to-access-the-vmware-esxi-hidden-console.html
http://www.yellow-bricks.com/2009/04/15/the-basics-how-to-kill-a-vm-thats-stuck-during-shutdown/


    List all VMs registered to this host (This reveals the Vmid needed for other commands)
    vim-cmd /vmsvc/getallvms
    Unregister a VM
    vim-cmd /vmsvc/unregister <Vmid>
    Register a VM
    vim-cmd /solo/register /path/to/file.vmx
    Get power state of a VM
    vim-cmd /vmsvc/power.getstate <Vimid>
    Power off a VM
    vim-cmd /vmsvc/power.off <Vmid>
    Power on a VM
    vim-cmd /vmsvc/power.on <Vmid>





    vmware-cmd -l
    vmware-cmd <config> stop trysoft
    vm-support -x
    vm-support -X <vmid>
    vmware-vim-cmd vmsvc/getallvms
    vmware-vim-cmd vmsvc/poweroff <vm id>
    ps -auxwww | grep <vm name>
    kill <process id>
    if option three isn’t successful do the following:
    kill -9 <process id>
http://kb.vmware.com/kb/1004340
 http://www.yellow-bricks.com/2009/04/15/the-basics-how-to-kill-a-vm-thats-stuck-during-shutdown/
http://www.vladan.fr/esxi-5-unresponsive-vm-h/


To monitor esxi vm's health
https://mathias-kettner.de/checkmk_vsphere.html

For patching an installation
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2008939
http://blogs.vmware.com/vsphere/2011/09/patching-esxi-from-the-command-line.html
Backup the host configuration:
# vicfg-cfgbackup –server esx18a.vmworld.com –save –username root esx18a-09162011.tgz

List image profiles in the patch:
# esxcli -s 10.91.243.171 –username root software sources profile list –depot=<path-to-zip>/ESXi500-201109001.zip

Place host into maintenance mode:
# vicfg-hostops –server 10.91.243.171 –username root –operation enter

Install with dry-run option:
# esxcli -s 10.91.243.171 –username root software profile install –depot=<path-to-zip>/ESXi500-201109001.zip –dry-run –profile=ESXi-5.0.0-20110904001-standard

Update with dry-run option:
# esxcli -s 10.91.243.171 –username root  software profile update –depot=<path-to-zip>/ESXi500-201109001.zip –dry-run –profile=ESXi-5.0.0-20110904001-standard

Perform the update:
# esxcli -s 10.91.243.171 –username root  software profile update –depot=<path-to-zip>/ESXi500-201109001.zip –profile=ESXi-5.0.0-20110904001-standard

Reboot the host:
# vicfg-hostops –server 10.91.243.171 –operation reboot

Take host out of maintenance mode:
# vicfg-hostops –server 10.91.243.171 –operation exit


To shutdown the esxi host
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1013193
You can shut down or reboot ESXi/ESX 4.x or ESXi 5.x hosts using any of the following methods:

Warning: Although these methods will gracefully shut down or reboot an ESXi/ESX host, they will not safely stop running virtual machines on the host. You should always ensure that virtual machines are migrated off the host and that the host is in maintenance mode before attempting to reboot or shut down a host using any method.

ESX 4.x

Log in to the ESX service console and perform one of these steps from the service console to shut down or reboot ESX 4.x hosts:
  1. Run the shutdown –r now command to reboot the system.

    Note: This command shuts down the virtual machines running on the ESX 4.0 hosts.
  2. Run the reboot command to reboot the system.
  3. Run the poweroff command to shut down ESX. After the shutdown, a message indicates that it is safe to power off your system. Press the power button until the machine powers off. You can then manually reboot the system.

ESXi 4.x/5.x

  1. From the Direct Console User Interface (DCUI) screen, press F12 to view the shutdown-related options for the ESXi host.
    • Press F2 to shut down.
    • Press F11 to reboot.
  2. From Local or Remote Tech Support Mode, or from an SSH session, run one of these commands:
    • Run the reboot command to restart the host.
    • Run the poweroff command to shut down the host.

    Note: In ESXi 5.x, no console output will be displayed on the screen when using the reboot or poweroff commands. After a short period of time, the host will reboot or shut down.

ESXi/ESX 4.x or ESXi 5.0

From the vSphere Client

Before shutting down or rebooting the ESXi/ESX 4.x or ESXi 5.0 hosts, ensure that the hosts are put into maintenance mode. Powering off a managed host disconnects it from vCenter Server, but does not remove it from the inventory.
  1. Shut down or use vMotion to migrate all virtual machines running on the ESXi/ESX hosts.
  2. Put the ESXi/ESX hosts into maintenance mode.
  3. Right-click the ESXi/ESX host that you want to shut down, and click Reboot or Shut Down.

    • If you select Reboot, the ESXi/ESX host shuts down and reboots.
    • If you select Shut Down, the ESXi/ESX host shuts down. You must manually power the system back on.
  4. Provide a reason for the shutdown or reboot. This information is added to the log.

ESXi 5.1/5.5

From the vSphere Web Client

Before shutting down or rebooting the ESXi 5.1 hosts, ensure that the hosts are put into maintenance mode.

To enter maintenance mode from the vSphere Web Client:
  1. Browse to the host in the vSphere Web Client navigator.
  2. Right-click the host and click Enter Maintenance Mode.
  3. Click Yes to enter maintenance mode.
Note: The host remains in maintenance mode until you select Exit Maintenance Mode.

To reboot or shut down the host using the vSphere Web Client:
  1. From the vSphere Web client, navigate to the host you want to shut down.
  2. Right-click the host and click Reboot or Shutdown.

From vCLI or vMA (vCLI 4.x)

Note: By default, the hostops.pl file in VMware vSphere CLI 4.0 U1 installations is located at C:\Program Files\VMware\VMware vSphere CLI\Perl\apps\host.
  • To put ESXi/ESX 4.x or ESXi 5.0 hosts into maintenance mode, run this command from the vMA (vSphere Management Assistant) or vCLI (vSphere Command-Line Interface) console screen:

    /usr/lib/vmware-vcli/apps/host/hostops.pl --target_host ESX-Host-FQDN --operation enter_maintenance --url https://vCenter-Host/sdk/vimService.wsdl
  • To reboot ESXi/ESX 4.x or ESXi 5.0 hosts, run this command from the vMA or vCLI console screen:

    /usr/lib/vmware-vcli/apps/host/hostops.pl --target_host ESX-Host-FQDN --operation reboot --url https://vCenter-Host/sdk/vimService.wsdl
  • To shut down ESXi/ESX 4.x or ESXi 5.0 hosts, run this command from the vMA or vCLI console screen:

    /usr/lib/vmware-vcli/apps/host/hostops.pl --target_host ESX-Host-FQDN --operation shutdown --url https://vCenter-Host/sdk/vimService.wsdl

From vCLI or vMA (vCLI 5.x)

Note: For more information on the vicfg-hostops command, see the vSphere Command-Line Interface Reference documentation.
  • To put ESXi/ESX 4.x or ESXi 5.x hosts into maintenance mode, run this command from the vCLI (vSphere Command-Line Interface) console screen:

    vicfg-hostops.pl --server ip_address --username root --password password --operation enter
  • To reboot ESXi/ESX 4.x or ESXi 5.x hosts, run this command from the vCLI console screen:

    vicfg-hostops.pl --server ip_address --username root --password password --operation reboot
  • To take ESXi/ESX 4.x or ESXi 5.x hosts out of maintenance mode, run this command from the vCLI console screen:

    vicfg-hostops.pl --server ip_address --username root --password password --operation exit
  • To shut down ESXi/ESX 4.x or ESXi 5.0 hosts, run this command from the vCLI console screen:

    vicfg-hostops.pl --server ip_address --username root --password password --operation shutdown
Note: For more information, see Running VMware CLI 4.x commands on ESXi 5.0 hosts (2004291).



VMware CLI 4.x commands on ESXi 5.0 hosts
As ESXi 5.0 is a new architecture with new features, VMware strongly recommends that you use vSphere CLI 5.0 to manage ESXi 5.0 hosts.
 
If you have to use vSphere CLI 4.x, this table outlines support for the commands:
 
Command Support 
svmotion.pl Not Supported
vicfg-advcfg.pl  Supported
vicfg-cfgbackup.pl Supported
vicfg-dns.pl Supported
vicfg-dumppart.pl Supported
vicfg-hostops.pl Supported
vicfg-ipsec.pl Supported
vicfg-iscsi.pl
Not Supported
vicfg-module.pl Supported
vicfg-mpath.pl
Not Supported
vicfg-nas.pl Supported
vicfg-nics.pl Supported
vicfg-ntp.pl Supported
vicfg-rescan.pl Supported
vicfg-route.pl Supported
vicfg-scsidevs.pl
Not Supported
vicfg-snmp.pl Supported
vicfg-syslog.pl Supported
vicfg-user Supported
vicfg-vmknic.pl  Supported
vicfg-vswitch.pl Supported
vifs.pl  Supported
vicfg-volume
Not Supported
vihostupdate.pl
Not Supported
vihostupdate35.pl
Not Supported
vmkfstools Supported
vmware-cmd.pl Supported