Pages

Wednesday 27 January 2010

Helpful ESX Commands






# cd /var/run/vmware
Navigate to the /var/run/vmware directory
vdh -h
will show you all the partitions including those being controlled by the VMKernel.
Esxcfg-vswitch Description: Creates and updates virtual machine (vswitch) network settings
Syntax: esxcfg-vswitch [vswitch[:ports]]

Options:
-a Add a new virtual switch.
-d Delete the virtual switch.
-l List all the virtual switches.
-L Set pnic as an uplink for the vswitch.
-U Remove pnic from the uplinks for the vswitch.
-p Specify a portgroup for operation.
Use ALL for operation to work on all portgroups
-v Set VLAN ID for portgroup specified by
-p. 0 would disable the VLAN.
-c Check to see if a virtual switch exists. Program outputs a 1 if it exists, 0 otherwise.
-A Add a new portgroup to the virtual switch.
-D Delete the portgroup from the virtual switch.
-C Check to see if a portgroup exists. Program outputs a 1 if it exists, 0 otherwise.
-r Restore all virtual switches from the configuration file (Internal use only)
-h Displays command help

esxcfg-vswitch examples:
Add a pnic (vmnic2) to a vswitch (vswitch1): esxcfg-vswitch -L vmnic2 vswitch1.
Remove a pnic (vmnic3) from a vswitch (vswitch0): esxcfg-vswitch -U vmnic3 vswitch0.
Create a portgroup (VM Network3) on a vswitch (vswitch1): esxcfg-vswitch -A "VM Network 3" vSwitch1 Assign a VLAN ID (3) to a portgroup (VM Network 3) on a vswitch (vswitch1): esxcfg-vswitch -v 3 -p "VM Network 3" vSwitch1.
NOTE: Port group Names are CaSe SenSiTive

esxcfg-vswif
Description: Creates and updates service console network settings. This command is used if you cannot manage the ESX Server host through the VI Client because of network configuration issues.
Syntax: esxcfg-vswif [vswif]

Options:
-a Add vswif, requires IP parameters. Automatically enables interface.
-d Delete vswif. -l List configured vswifs.
-e Enable this vswif interface.
-s Disable this vswif interface.
-p Set the portgroup name of the vswif.
-i or DHCP The IP address for this vswif or specify DHCP to use DHCP for this address.
-n The IP netmask for this vswif.
-b The IP broadcast address for this vswif. (not required if netmask and ip are set)
-c Check to see if a virtual NIC exists. Program outputs a 1 if the given vswif exists, 0 otherwise.
-D Disable all vswif interfaces. (WARNING: This may result in a loss of network connectivity to the Service Console)
-E Enable all vswif interfaces and bring them up.
-r Restore all vswifs from the configuration file. (Internal use only)
-h Displays command help. Note: You can set the Service Console default gateway by editing the /etc/sysconfig/network file or through the VI Client under Configuration, DNS & Routing.

esxcfg-vswif examples:
Change your Service Console (vswif0) IP and Subnet Mask: esxcfg-vswif -i 172.20.20.5 -n 255.255.255.0 vswif0 Add a Service Console (vswif0): esxcfg-vswif -a vswif0 -p "Service Console" -i 172.20.20.40 -n 255.255.255.0

Esxcfg-route
Description: Sets or retrieves the default VMkernel gateway route Syntax:
esxcfg-route can be specified in 2 ways: as a single argument in / format or as a pair. is either an IP address or 'default'

Options:
-a Add route to the VMkernel, requires network address (or 'default') and gateway IP address.
-d Delete route from the VMkernel, requires network address (or 'default').
-l List configured routes for the Service Console.
-r Restore route setting to configured values on system start. (Internal use only)
-h Displays command help
esxcfg-route examples:
Set the VMkernel default gateway route: esxcfg-route 172.20.20.1.
Add a route to the VMkernel: esxcfg-route -a default 255.255.255.0 172.20.20.1
Esxcfg-vmknic
Description: Creates and updates VMkernel TCP/IP settings for VMotion, NAS, and iSCSI
Syntax: esxcfg-vmknic [[portgroup]]


Options:
-a Add a VMkernel NIC to the system, requires IP parameters and portgroup name.
-d Delete VMkernel NIC on given portgroup.
-e Enable the given NIC if disabled.
-D Disable the given NIC if enabled.
-l List VMkernel NICs.
-i The IP address for this VMkernel NIC. Setting an IP address requires that the -n option be given in same command.
-n The IP netmask for this VMkernel NIC. Setting the IP netmask requires that the -
i option be given in the same command.
-r Restore VMkernel TCP/IP interfaces from configuration file. (Internal use only)
-h Displays command help

esxcfg-vmknic examples:
Add a VMkernel NIC and set the IP and subnet mask: esxcfg-vmknic -a "VM Kernel" -i 172.20.20.19 -n 255.255.255.0
Esxcfg-firewall
Description: Configures the service console firewall ports Syntax: esxcfg-firewall


Options:
-l Lists current settings -q Lists settings for the specified service
-q incoming|outgoing Lists settings for non-required incoming/outgoing ports
-s Lists known services -l Loads current settings
-r Resets all options to defaults
-e Allows specified service through the firewall (enables)
-d Blocks specified service (disables)
-o Opens a port
-c Closes a port previously opened by
-h Displays command help
-allowincoming
-blockincoming Block all non-required incoming ports (default value)
-blockoutgoing Block all non-required outgoing ports (default value)
vmware-cmd –l
Description: Useful for use with ALL vmware-cmd commands which require the path to the VMX file to run successful
vmware-cmd –l examples
/vmfs/volumes/48ce49a0-6fc41293-9781-001f296bdb5d/VM1/VM1.vmx
/vmfs/volumes/48ce49a0-6fc41293-9781-001f296bdb5d/VM2/VM2.vmx
/vmfs/volumes/48ce49a0-6fc41293-9781-001f296bdb5d/VM3/VM3.vmx

vmware-cmd stop vmware-cmd reset
Description: where hard, soft or trysoft specifies the behavior of the power operation . If is not specified, the default behavior is soft.
For more information, see the VMware Scripting API User's Manual.
vmware-cmd stop/start examples
vmware-cmd /vmfs/volumes/48ce49a0-6fc41293-9781-001f296bdb5d/VM1/VM1.vmx stop
service mgmt-vmware restart
Description: For troubleshooting purposes, it may be necessary to restart the management agents on your ESX 
Server.

Viewing logs from your ESX Server.
add one of the following commands to view any logs on a ESX server :tail, more, less, cat and grep.
Examples: more /var/log/vmkernel
NOTE: you can also use WinSCP ( www.winscp.com ) to browse your ESX server folders in a "Windows Explorer Like" style and open log files with its file editor or you can copy them to a PC and open them with your favorite editor.
Service Console Commands

/proc/vmware/vm//mem/minReading from this file reports the minimum memory size in megabytes for the virtual machine identified by .
Writing a number  to this file changes the minimum memory size for the virtual machine identified by  toMB.
/proc/vmware/vm//mem/sharesReading from this file reports the number of memory shares allocated to the virtual machine identified by .
Writing a number  to this file changes the number of memory shares allocated to the virtual machine identified by to . The valid range of numerical values for  is 0 to 100000. You may also use the special values low,normal and high. These values are automatically converted into numbers, through the configuration optionsMemSharesPerMBLowMemSharesPerMBNormal and MemSharesPerMBHigh, described below.
Note that a value of zero (0) shares causes the virtual machine memory size allocation to be exactly equal to its specified minimum size, even if excess memory is available.
/proc/vmware/vm//mem/statusReading from this file reports current status information for the virtual machine identified by , including the specified shares, minimum size and maximum size parameters as well as the virtual machine name, current status, whether the virtual machine is currently waiting for memory to be reserved, current memory usage, current target size, memory overhead for virtualization and the amount of allocated memory actively in use. All memory sizes are reported in kilobytes.
/proc/vmware/sched/memReading from this file reports the memory status information for all non-system virtual machines in the entire system as well as several aggregate totals.
Writing the string realloc to this file causes an immediate memory reallocation. Memory is normally reallocated periodically every MemBalancePeriod seconds. (See /proc/vmware/config/MemBalancePeriod below for more information.) Reallocations are also triggered by significant changes in the amount of free memory.
/proc/vmware/memReading from this file reports the maximum size with which a new virtual machine can be powered on, admission control status including the amount of unreserved memory and unreserved swap space and the current amount of free memory in the system.
/proc/vmware/pshare/statusReading from this file reports various detailed statistics about the current status of transparent page sharing.
/proc/vmware/swap/statsReading from this file reports various detailed swap statistics.
/proc/vmware/config/MemSharesPerMBLowThis option specifies the a numerical value for the low shares value. By default, this number is 5.This number is multiplied by the virtual machine's maximum memory size to obtain the number of shares.
/proc/vmware/config/MemSharesPerMBNormalThis option specifies the a numerical value for the normal shares value. By default, this number is 10. This number is multiplied by the virtual machine's maximum memory size to obtain the number of shares.
/proc/vmware/config/MemSharesPerMBHighThis option specifies the a numerical value for the high shares value. By default, this number is 20. This number is multiplied by the virtual machine's maximum memory size to obtain the number of shares.
/proc/vmware/config/MemBalancePeriodThis ESX Server option specifies the periodic time interval, in seconds, for automatic memory reallocations. Reallocations are also triggered by significant changes in the amount of free memory. The default is 15 seconds.
/proc/vmware/config/MemSamplePeriodThis ESX Server option specifies the periodic time interval, measured in seconds of virtual machine virtual time, over which memory activity is monitored in order to estimate working set sizes. The default is 30 seconds.
/proc/vmware/config/MemIdleTaxThis ESX Server option specifies the idle memory tax rate as a percentage. A tax rate of x percent means that up to xpercent of a virtual machine's idle memory may be reclaimed. Virtual machines are charged more for idle memory, than for memory that they are actively using. A tax rate of 0 percent defines an allocation policy that ignores working sets and allocates memory strictly based on shares. A high tax rate results in an allocation policy that allows idle memory to be reallocated away from virtual machines that are unproductively hoarding it, regardless of shares. The default is 75 percent.
/proc/vmware/config/MemShareScanVMThis ESX Server option specifies the maximum per-virtual machine rate at which memory should be scanned for transparent page sharing opportunities. The rate is specified as the number of pages to scan per second. The default is 50 pages per second per virtual machine.
/proc/vmware/config/MemShareScanTotalThis ESX Server option specifies the total systemwide rate at which memory should be scanned for transparent page sharing opportunities. The rate is specified as the number of pages to scan per second. The default is 200 pages per second.
/proc/vmware/config/MemCtlMaxPercentThis ESX Server option limits the maximum amount of memory that may be reclaimed from any virtual machine usingvmmemctl, based on a percentage of its maximum size. Specifying 0 effectively disables reclamation via vmmemctl for all virtual machines. Defaults to 50.
/proc/vmware/config/MemCtlMax[OSType]These ESX Server options restrict the maximum amount of memory that may be reclaimed from a virtual machine usingvmmemctl, based on the limitations of guest operating system type. The value is specified in megabytes. Defaults to 128 for OSType=NT4 (Windows NT 4.0), 2048 for OSType=NT5 (Windows 2000 or Windows Server 2003), and 768 forOSType=Linux.

Good ESX logs to check

cat /var/log/vmware/vpx/vpxa.log
vmkernel/hostd.log

No comments:

Post a Comment