Showing posts with label CLI. Show all posts
Showing posts with label CLI. Show all posts

Monday, June 11, 2012

ESX host Maintenance mode from ESX CLI

1) login to ESX host to execute below.


To enter Maintenance Mode, at the ESX console:
vimsh -n -e /hostsvc/maintenance_mode_enter

To exit Maintenance Mode :
vimsh -n -e /hostsvc/maintenance_mode_exit

To display whether the ESX Server is currently in maintenance mode or not type:
vimsh -n -e"hostsvc/hostsummary" | grep inMaintenanceMode

Using system libcrypto, version 90810F
inMaintenanceMode = false, 

(False - means "not in maintenance mode" / True - Means "in maintenance mode") 

Friday, January 14, 2011

ESXTOP - Deep Dive

Source - www.yellow-bricks.com
ESXTOP
Intro
Thresholds
Howto – Run
Howto – Capture
Howto – Analyze
Howto – Limit esxtop to specific VMs
References
Changelog
This page is solely dedicated to one of the best tools in the world for ESX; esxtop.

Intro

I am a huge fan of esxtop! I read a couple of pages of the esxtop bible every day before I go to bed. Something I however am always struggling with is the “thresholds” of specific metrics. I fully understand that it is not black/white, performance is the perception of a user in the end.
There must be a certain threshold however. For instance it must be safe to say that when %RDY constantly exceeds the value of 20 it is very likely that the VM responds sluggish. I want to use this article to “define” these thresholds, but I need your help. There are many people reading these articles, together we must know at least a dozen metrics lets collect and document them with possible causes if known.
Please keep in mind that these should only be used as a guideline when doing performance troubleshooting! Also be aware that some metrics are not part of the default view. You can add fields to an esxtop view by clicking “f” on followed by the corresponding character.
I used VMworld presentations, VMware whitepapers, VMware documentation, VMTN Topics and of course my own experience as a source and these are the metrics and thresholds I came up with so far. Please comment and help build the main source for esxtop thresholds.

Metrics and Thresholds

Display Metric Threshold Explanation
CPU %RDY 10 Overprovisioning of vCPUs, excessive usage of vSMP or a limit(check %MLMTD) has been set. See Jason’s explanation for vSMP VMs
CPU %CSTP 3 Excessive usage of vSMP. Decrease amount of vCPUs for this particular VM. This should lead to increased scheduling opportunities.
CPU %SYS 20 The percentage of time spent by system services on behalf of the world. Most likely caused by high IO VM. Check other metrics and VM for possible root cause
CPU %MLMTD 0 The percentage of time the vCPU was ready to run but deliberately wasn’t scheduled because that would violate the “CPU limit” settings. If larger than 0 the world is being throttled due to the limit on CPU.
CPU %SWPWT 5 VM waiting on swapped pages to be read from disk. Possible cause: Memory overcommitment.
MEM MCTLSZ 1 If larger than 0 host is forcing VMs to inflate balloon driver to reclaim memory as host is overcommited.
MEM SWCUR 1 If larger than 0 host has swapped memory pages in the past. Possible cause: Overcommitment.
MEM SWR/s 1 If larger than 0 host is actively reading from swap(vswp). Possible cause: Excessive memory overcommitment.
MEM SWW/s 1 If larger than 0 host is actively writing to swap(vswp). Possible cause: Excessive memory overcommitment.
MEM CACHEUSD 0 If larger than 0 host has compressed memory. Possible cause: Memory overcommitment.
MEM ZIP/s 0 If larger than 0 host is actively compressing memory. Possible cause: Memory overcommitment.
MEM UNZIP/s 0 If larger than 0 host has accessing compressed memory. Possible cause: Previously host was overcommited on memory.
MEM N%L 80 If less than 80 VM experiences poor NUMA locality. If a VM has a memory size greater than the amount of memory local to each processor, the ESX scheduler does not attempt to use NUMA optimizations for that VM and “remotely” uses memory via “interconnect”.
NETWORK %DRPTX 1 Dropped packets transmitted, hardware overworked. Possible cause: very high network utilization
NETWORK %DRPRX 1 Dropped packets received, hardware overworked. Possible cause: very high network utilization
DISK GAVG 25 Look at “DAVG” and “KAVG” as the sum of both is GAVG.
DISK DAVG 25 Disk latency most likely to be caused by array.
DISK KAVG 2 Disk latency caused by the VMkernel, high KAVG usually means queuing. Check “QUED”.
DISK QUED 1 Queue maxed out. Possibly queue depth set to low. Check with array vendor for optimal queue depth value.
DISK ABRTS/s 1 Aborts issued by guest(VM) because storage is not responding. For Windows VMs this happens after 60 seconds by default. Can be caused for instance when paths failed or array is not accepting any IO for whatever reason.
DISK RESETS/s 1 The number of commands reset per second.
DISK CONS/s 20 SCSI Reservation Conflicts per second. If many SCSI Reservation Conflicts occur performance could be degraded due to the lock on the VMFS.

Running esxtop

Although understanding all the metrics esxtop provides seem to be impossible using esxtop is fairly simple. When you get the hang of it you will notice yourself staring at the metrics/thresholds more often than ever. The following keys are the ones I use the most.
Open console session or ssh to ESX(i) and type:
esxtop
By default the screen will be refreshed every 5 seconds, change this by typing:
s 2
Changing views is easy type the following keys for the associated views:
c = cpu
m = memory
n = network
i = interrupts
d = disk adapter
u = disk device (includes NFS as of 4.0 Update 2)
v = disk VM
p = power states

V = only show virtual machine worlds
e = Expand/Rollup CPU statistics, show details of all worlds associated with group (GID)
k = kill world, for tech support purposes only!
l  = limit display to a single group (GID), enables you to focus on one VM
# = limiting the number of entitites, for instance the top 5

2 = highlight a row, moving down
8 = highlight a row, moving up
4 = remove selected row from view
e = statistics broken down per world
6 = statistics broken down per world
Add/Remove fields:
f
Changing the order:
o
Saving all the settings you’ve changed:
W
Keep in mind that when you don’t change the file-name it will be saved and used as default settings.
Help:
?
In very large environments esxtop can high CPU utilization due to the amount of data that will need to be gathered and calculations that will need to be done. If CPU appears to highly utilized due to the amount of entities (VMs / LUNs etc) a command line option can be used which locks specific entities and keeps esxtop from gathering specific info to limit the amount of CPU power needed:
esxtop -l
More info about this command line option can be found here.

Capturing esxtop results

First things first. Make sure you only capture relevant info. Ditch the metrics you don’t need. In other words run esxtop and remove/add(f) the fields you don’t actually need or do need! When you are finished make sure to write(W) the configuration to disk. You can either write it to the default config file(esxtop4rc) or write the configuration to a new file.
Now that you have configured esxtop as needed run it in batch mode and save the results to a .csv file:
esxtop -b -d 2 -n 100 > esxtopcapture.csv
Where “-b” stands for batch mode, “-d 2″ is a delay of 2 seconds and “-n 100″ are 100 iterations. In this specific case esxtop will log all metrics for 200 seconds. If you want to record all metrics make sure to add “-a” to your string.
Or what about directly zipping the output as well? These .csv can grow fast and by zipping it a lot of precious diskspace can be saved!
esxtop -b -a -d 2 -n 100 | gzip -9c > esxtopoutput.csv.gz

Analyzing results

You can use multiple tools to analyze the captured data.
  1. perfmon
  2. excel
  3. esxplot
Let’s start with perfmon as I’ve used perfmon(part of Windows also know as “Performance Monitor”) multiple times and it’s probably the easiest as many people are already familiar with it. You can import a CSV as follows:
  1. Run: perfmon
  2. Right click on the graph and select “Properties”.
  3. Select the “Source” tab.
  4. Select the “Log files:” radio button from the “Data source” section.
  5. Click the “Add” button.
  6. Select the CSV file created by esxtop and click “OK”.
  7. Click the “Apply” button.
  8. Optionally: reduce the range of time over which the data will be displayed by using the sliders under the “Time Range” button.
  9. Select the “Data” tab.
  10. Remove all Counters.
  11. Click “Add” and select appropriate counters.
  12. Click “OK”.
  13. Click “OK”.
The result of the above would be:

With MS Excel it is also possible to import the data as a CSV. Keep in mind though that the amount of captured data is insane so you might want to limit it by first importing it into perfmon and then select the correct timeframe and counters and export this to a CSV. When you have done so you can import the CSV as follows:
  1. Run: excel
  2. Click on “Data”
  3. Click “Import External Data” and click “Import Data”
  4. Select “Text files” as “Files of Type”
  5. Select file and click “Open”
  6. Make sure “Delimited” is selected and click “Next”
  7. Deselect “Tab” and select “Comma”
  8. Click “Next” and “Finish”
All data should be imported and can be shaped / modelled / diagrammed as needed.
Another option is to use a tool called esxplot”. You can download the latest version here.
  1. Run: esxplot
  2. Click File -> Import -> Dataset
  3. Select file and click “Open”
  4. Double click host name and click on metric

As you can clearly see in the screenshot above the legend(right of the graph) is too long. You can modify that as follows:
  1. Click on “File” -> preferences
  2. Select “Abbreviated legends”
  3. Enter appropriate value
For those using a Mac, esxplot uses specific libraries which are only available on the 32Bit version of Python. In order for esxplot to function correctly set the following environment variable:
export VERSIONER_PYTHON_PREFER_32_BIT=yes

Limiting your view

In environments with a very high consolidation ratio (high number of VMs per host) it could occur that the VM you need to have performance counters for isn’t shown on your screen. This happens purely due to the fact that height of the screen is limited in what it can display. Unfortunately there is currently no command line option for esxtop to specify specific VMs that need to be displayed. However you can export the current list of worlds and import it again to limit the amount of VMs shown.
esxtop -export-entity filename
Now you should be able to edit your file and comment out specific worlds that are not needed to be displayed.
esxtop -import-entity filename
I figured that there should be a way to get the info through the command line as and this is what I came up with. Please note that needs to be replaced with the name of the virtual machine that you need the GID for.
VMWID=`vm-support -x | grep  |awk '{gsub("wid=", "");print $1}'`
VMXCARTEL=`vsish -e cat /vm/$VMWID/vmxCartelID`
vsish -e cat /sched/memClients/$VMXCARTEL/SchedGroupID
Now you can use the outcome within esxtop to limit(l) your view to that single GID. William Lam has written an article a couple of days after I added the GID section. The following is a lot simpler than what I came up with, thanks William!
VM_NAME=STA202G ;grep "${VM_NAME}" /proc/vmware/sched/drm-stats  | awk '{print $

Monday, June 14, 2010

Using MOB- (Managed Object Browser) --> Ops Panel for ESX

I was recently reading Eric Sloof article,
Where you can go and edit (index.html - which opens as ESX server home page) customize by using MOB (Via Java Scripting).. here is the cool video by Eric.

The Operations Panel is a script tool, which runs on the client browser and extends the default ESX server web page with a short list of all available virtual machines. It gives the user the ability to perform simple power operations (start, stop, suspend, resume). Easily accessible user interface for some of the most common operations on an ESX host, available directly from the ESX home page.


Ops Panel for ESX from Eric Sloof NTPRO.NL on Vimeo.

Wednesday, March 31, 2010

Performance Monitoring of LUN, HBA, VM & for Which Threshold values, you should show concern

The esxtop utility can be used to measure how much I/O is moving across various devices. The esxtop utility is interactive. As such, pressing certain keys changes the view.

Configuring monitoring using esxtop


To monitor storage performance per HBA:
  1. Start esxtop by typing esxtop at the command line.
  2. Press d to switch to disk view (HBA mode).
  3. Press f to modify the fields that are displayed.
  4. Press b, c, d, e, h, and j to toggle the fields and press Enter.
  5. Press s, then 2 to alter the update time to every 2 seconds and press Enter.
  6. See Analyzing esxtop columns for a description of relevant columns.
 Click below --> "Read More" for Full Article (Tolerable Threshold Values in Real time)..


Monday, March 29, 2010

How to troubleshoot Pink Screen on Death (PSOD) in ESX

Source : VMware KB, VMworld PSOD Guide, TechTarget

VMware might not want to get into Blues like Microsoft much famed BSOD (Blue Screen on Death). So they named it as PSOD (Pink Screen on Death).. LOL..

As you know PSOD crash normally could have no shortcut to find the source of problem, VMware tried it's best to make to straight, possible PSOD causes as mentioned below

1) Hardware Faults
2) Host Faults
3) VMM Faults
4) Guest Operating System Faults
5) Application Faults

  How to Capture the PSOD crash dump (By default PSOD dump is saved on /root)

1) type "vm-support" (on # Prompt) without any options. The utility will run and create a single Tar file that will be named  "esx-xxxxxx..tgz".

2) Alternatively, you can generate the same file by using the VMware Infrastructure Client (VI Client). Select  Administration, then Export Diagnostic Data, and select your host (VirtualCenter data optional) and a directory on your local PC to store the file that will be created. 


You may follow these steps to resolve the issue

 Click below --> "Read More" for Full Article

How CDP (Cisco Discovery Protocol) will benefit you to identify *** Which NIC connected to what External Device on ESX ***

Source : VMware KB and www.vmetc.com 
 

This is a handy little trick, starting with version 3.5, VMware added support for Cisco Discovery Protocol (CDP) on the ESX Server vSwitches. CDP support is enabled on a vSwitch with this command:

Verify the current CDP setting for vSwitch2
ESX# esxcfg-vswitch -b vSwitch2 

down 
The above output is down - which indicates CDP is currently not enabled vSwitch2  

To enable CDP on vSwitch2
ESX# esxcfg-vswitch -B both vSwitch2

To Verify the CDP Status (Expect -> Down, Listen, Advertise, Both)
ESX# esxcfg-vswitch -b vSwitch2


Both

Check CDP information on Physical Switch

Once CDP support is enabled on the vSwitch & physical switch - execute below command on Phy.Switch. Which will show the link between each physical switch port and the matching ESX Server NIC. The output will look something like this:

# show cdp neighbor 

 Capability Codes: R-Router, T-Trans Bridge, B-Source Route Bridge
                  S-Switch, H-Host, I-IGMP, r-Repeater, P-Phone

DeviceID  Local Intrfce  Holdtme  Capability  Platform      Port ID
s3        Gig   0/26        147      T S    WS-C3524-XFas 0/24
esx04     Gig   0/22        168       S     VMware        ESXvmnic0
esx04     Gig   0/21        168       S     VMware        ESXvmnic1

As you can see in the output above, the CDP output clearly links the physical switch port and the ESX Server NIC. This makes it incredibly easy to identify the NICs in the server. This is particularly helpful in blade situations, since you can’t exactly unplug the NIC and see which one goes down with “esxcfg-nics -l” (a common approach to identifying the NICs in the server). Of course, this requires CDP switches in the blade chassis. Since the internal port mappings on the blade chassis determine which NICs connect to which ports, this command adds the mapping within ESX Server and lets us quickly and definitively identify the NICs in the server as seen by ESX Server.

Check CDP information in VI Client

Now, using the VI Client you can go to the Configuration tab of a host and select Networking. To the right of each vSwitch is what I’ll describe as a dialogue icon.

Clicking this Call out icon (Green circle) brings up the switch port info you are seeking.

Sunday, March 28, 2010

Discover iSCSI SAN LUN on ESX via CLI - As easy as you count 1,2,3 (assumes SAN admin mapped LUN to ESX Host & VMkernel port ready on ESX)



The command vmkiscsi-tool. Really good stuff, I can complete the rest of my setup without the GUI. One thing though to list out the iqn for iscsi after you enable it you must know the device name (ie vmhba??). Using this command:

# vmkiscsi-tool -I -l

I usually guess the iscsi hba is vmhba33 or 32 but how do I know for sure? Try:
# esxcfg-scsidevs -a
esxcfg-scsidevs-a
Ok great, now we know it is vmhba33 (Click the above image for full details as well)

[root@esxhost01 sbin]# vmkiscsi-tool -I -l vmhba33


iSCSI Node Name: iqn.1998-01.com.vmware:esxhost01-35151883
 

[root@esxhost01 sbin]#

Now with a few more vmkiscsi-tool commands I can finish configuring my iSCSI.

Add the Ip of the SAN:
[root@esxhost01 sbin]# vmkiscsi-tool -D -a 172.16.23.251 vmhba33

Now rescan:
[root@esxhost01 sbin]# esxcfg-rescan -a vmhba33

Wednesday, March 24, 2010

Not able to manage ESX from vSphere Client/vCenter --> How to associate Service Console to VMNIC0 (Phy NIC0) from CLI

ESX Server 3.x Service Console NIC Assignment (VMware KB 8018438)
--> During Installation of ESX did not assign Service Console to Phy NIC
--> or Can't Associate Network Card with Service Console
--> or Due to some problem (or messed up), Service Console is currently not assigned to Phy NiC

Details
When installing ESX Server 3.x, you are not given the option to select which network card should be associated with the service console. By default, it seems as though vmnic0 is selected.

Solution
Note: This article assumes that the correct network settings (IP Address, Subnet Mask, Gateway and DNS) were assigned during the initial installation.

To resolve this issue, use the esxcfg-vswitch command, as follows:
To the physical switch, attach only the network cable used for the service console.

List all of the network adapters from the ESX Server service console and locate the name of the vmnic# that has a link status of up.
# esxcfg-nics –l
If vmnic0 has a link status of up, stop now. Otherwise, remove vmnic0 from vSwitch0.
# esxcfg-vswitch -U vmnic0 vSwitch0

Associate the vmnic# that has a link status of up from step 2.
# esxcfg-vswitch -L vmnic# vSwitch0

Use the following commands to determine where the ESX Server service console portgroup is (if you are doing a repair after changing physical NICs or similar activity, for example):
# esxcfg-nics -l
Determines which NICs are link up esxcfg-vswif -l to ensure Service Console is the port group, and the settings are correct.

# esxcfg-vswitch -l
Shows which vSwitch the service console port group is in.

# esxcfg-vswitch -L
Links the vmnic and service console together.

Prior to changing the IP address of Service Console on ESX hosts

Take the following into consideration prior to changing the IP address of the Service Console:
  • Changing the primary Service Console's IP address may result in network connectivity loss.
  • Connect to ESX shell via a remote console or a KVM console. The PUTTY or SSH connection terminates during IP address change.
  • VMware HA and DRS, if enabled, must be disabled to eliminate failover.
  • Disconnect and remove the host from VirtualCenter.
  • Change the DNS database for the forward entries and the reverse entries if applicable.
  • For manual resolution in /etc/hosts, change the IP for each ESX host in the VMware HA cluster and, if needed, in any other host in your environment.
  • If there is more than one Service Console present, determine the primary one by checking /etc/sysconfig/network for default gateway device and IP address.

Changing the IP address on ESX 3.x and 4.0

To change the IP address on ESX 3.x and 4.0: 
  1. Log in as root to the ESX host console using a SSH or KVM connection.
  2. Run the following command to stop the network service:
    service network stop
     
  3. Run the esxcfg-vswif command to change the IP of the hosts:
    esxcfg-vswif -i NEW_IP_ADDRESS -n MASK_ADDRESS vswif0
     
  4. Edit the /etc/sysconfig/network file and change the gateway IP if needed.
  5. Run the following command to restart the network:
    service network start
     
  6. Add the host back to VirtualCenter using a FQDN (preferably) or by its IP.
  7. Reconnect host to VirtualCenter (if applicable).   

Changing the IP address on ESX 2.5

To change the IP address on ESX 2.5:
  1. Log in as root to the ESX host console using a SSH or KVM connection.
  2. Run the following command to stop the network service:
    service network stop 
  3. Change the IP and net mask in the correct file. Edit the /etc/sysconfig/network-scripts/ifcfg-eth0 file and change the IP and the net mask.
  4. Change the gateway configuration. Edit the /etc/sysconfig/network file and change the gateway IP if needed.
  5. Run the following commands to restart the interface and the network:
    • ifdown eth0
    • ifup eth0
    • service network start

How to exempt the DELL OMSA port number only on ESX Firewall?

How to exempt the DELL OMSA port number only on ESX Firewall?
(Without Disabling entire Firewall)

Dell Openmanage Installation on ESX

Firstly the standard steps (to Install OMSA):

1. Download the tar file from the ftp site or the support site
2. Copy the file using winscp(this is what i use at least) to /tmp/openmanage on the server
3. Log into the box either via winscp /via putty or onto the console directly and type in:

cd /tmp/openmanage
tar -zxvf OM_X.X.0_ManNode_A01.tar.gz (OM_6.2.0_ManNode_A00.tar currently)

4. Once the files have unpacked type in:
cd linux/supportscripts/
./srvadmin-install.sh -x (-x is for express install and installs everything but if you only want to install specific features the commands you can also use are -d -w -r –s )

-d = Dell Agent
-w = web interface
-r = DRAC services
-s = storage management

5. Once the files have unpacked and installed type:
srvadmin-services.sh start
6. When the various component services have finished starting type in:
cd /tmp
rm -rf Openmanage
7. To allow the Openmanage agent to function the following firewall commands
need to be run,
these open the firewall ports required:
# esxcfg-firewall -o 1311,tcp,in,OpenManageRequest