How to enable Maintenance mode on ESX host from command line

This is something that I’ve been meaning to post for a while now. It’s a simple thing but can save you from having to open up the vSphere client or allow you to use this in a script. The commands listed below will allow you to place a ESX host in and out of Maintenance mode from the command line or Service Console (what ever you like to call it).

To enter maintenance mode run the following command

vimsh -n -e /hostsvc/maintenance_mode_enter

To exit maintenance mode run the following command

vimsh -n -e /hostsvc/maintenance_mode_exit

So your probably wondering how do I know if the host is in Maintenance Mode, here you go:

vimsh -n -e /hostsvc/runtimeinfo | grep inMaintenanceMode | awk ‘{print $3}’

Update: March 1st 2011

I thought an update to cover the commands you can run from vMA to enter maintenance mode from vCLI. From the vMA command prompt you can enter the following command to enter maintenance mode.

vicfg-hostops -o enter –server 192.168.1.114

To exit maintenance mode from vMA enter the following.

vicfg-hostops -o exit –server 192.168.1.114

You can also issue shutdown or reboot commands from vMA.

vicfg-hostops -o shutdown –server 192.168.1.114
vicfg-hostops -o reboot –server 192.168.1.114

Also note that after entering any of the above commands from the vMA it will make you provide Username and Password for the Host that you are working on. Unless you choose to use Fast Pass or Passthrough authentication.

About Brian

Brian is a Technical Architect for a VMware partner and owner of this website. He is active in the VMware community and helps lead the Chicago VMUG group. Specializing in VDI and Cloud project designs. Awarded VMware vExpert status for 2012 & 2011. VCP3, VCP5, VCA-DT, VCP5-DT, Cisco UCS Design

Read More

How to run EMC grabs on a VMware ESX host

This is something that I have to do on Windows boxes all the time, but less on our ESX boxes. In the past we used to just run the vm-support to collect the support logs and turn those over to the storage team. They no longer are happy with those and since EMC now has a grab that supports both vSphere and VI3.5 it’s hard to deny them now. In case you do not know what a grab is, it’s a log collection utility that will provide the storage admin with all of the details about WWN’s, paths and which LUN’s a host can see. They can use this for planning upgrades and troubleshooting issues.

First thing you will need to do is to download the proper EMC grab version to support your hosts. At the time of writing this its a version 1.2.1 and is supports both ESX 3 and 4. Proceed on over to http://powerlink.emc.com and download it from the support programs area.

Once you have the file you will need to upload it to your host with something like WinSCP. I always upload it into the /tmp folder and unzip it there. It will create a folder called “emcgrab”. You can use the following command to do the unzip in case your not familiar with what to do.

tar -xvf emcgrab_ESX_vSphere_v.1.2.1.tar

Next thing is to move into the emcgrab directory that was created. From within there you will need to execute the following command. If you read the help file included in the directory it will explain some options to supress some annoying confirmation screens about the licensing and such.

./emcgrab.sh -nomsg

Once the program starts to run depending on the options you used it will prompt you to confirm and read the licensing. After you pass that part it will ask you a string of questions about your contact details and some questions about your environment. These are not necessary to complete it you are using these grabs in house. If you plan on sending these to EMC then I would advise to fill them out.

Once the script completes it will ask you if you want to run vm-support to collect the VMware support logs along with the EMCgrabs. This is up to you, if you have a need for them go ahead. Once the script finished it will place the zipped up file in the Output folder and you can pull off the file with WinSCP.

In closing it’s not necessary to be running Powerpath on your hosts to collect these grabs.

About Brian

Brian is a Technical Architect for a VMware partner and owner of this website. He is active in the VMware community and helps lead the Chicago VMUG group. Specializing in VDI and Cloud project designs. Awarded VMware vExpert status for 2012 & 2011. VCP3, VCP5, VCA-DT, VCP5-DT, Cisco UCS Design

Read More

A script to audit datastore visability to your ESX hosts in a cluster

If your running clusters with a bunch of hosts in them you probably had the need at one point for a script like this. So what does this puppy do? It will look at your clusters and then the hosts and verify if each host can see the datastore. You might have one host that cannot see a particular datastore and is causing you issues with migrations or DRS. You other option is to do this manually by looking at each host and checking the datastores via the vSphere client.

I would recommend you save yourself a bunch of time and gray hairs and use this great script that was written by LucD. You can get some more details about this script and download it from his blog here.

About Brian

Brian is a Technical Architect for a VMware partner and owner of this website. He is active in the VMware community and helps lead the Chicago VMUG group. Specializing in VDI and Cloud project designs. Awarded VMware vExpert status for 2012 & 2011. VCP3, VCP5, VCA-DT, VCP5-DT, Cisco UCS Design

Read More