ESX and ESXi commands usage

ESX Log localization
/var/log/
vmkernel.log – all messages from VMware kernel
vmkwarning.log – only error messages from kernel
messages – all info about server activity
/var/log/vmware
Esxcfg-boot – log from command esxcfg-boot
Esxcfg-firewall – log from command esxcfg-firewall
Esxupdate.log – log from updating server
Hostd.log – log from vmware-hostd process
/var/log/vmware/aam – folder with logs from cluster service
/var/log/vmware/vpx – folder with logs from vpx service
/var/log/vmware/webAccess – folder with logs from webAccess

ESX and ESXi Commands usage
Location: /usr/sbin/
esxcfg-mpath – Multipathing configuration
esxcfg-nas – Add, delete or manage NAS file systems
esxcfg-nics – Presents physical NIC information
esxcfg-rescan – Rescan LUN’s on SCSI device
esxcfg-resgrp – Create, delete and list resource groups
esxcfg-route – Enable or disable routing for vmknics
esxcfg-swscsi – Configures software iSCSIadapters
esxcfg-vmhbadevs – Maps COS device files to vmhbanames
esxcfg-vmknic – Create & configure VMkernel NICs
esxcfg-vswif – Create & configure vswifsfor the COS
esxcfg-advcfg – Sets advanced VMkernel options
esxcfg-auth – Authentication configuration
esxcfg-boot – Configure boot, including PCI allocation
esxcfg-dumppart – Set, activate, deactivate, list potential and current VMkernel dump partitions
esxcfg-firewall – Configure firewall options.
esxcfg-info – Prints information about the service console, the VMkernel, various subsystems in the virtual network and storage resource hardware
esxcfg-init – Perform initialization steps in the initrd
esxcfg-linuxnet – Converts vswif devices to eth when booting into Linux debugging mode
esxcfg-upgrade – Upgrade from ESX Server 2.X to 3.0 Commands
Below command is available in ESX version of hypervisor, up to vSphere 4.1.X
vmware-cmd – very useful command, located /usr/bin/ – using it you can start/stop/reset/ suspend/getstate of virtual machine, register or unregister Virtual Machine on ESX server and many other really useful stuff, especially when GUI interface fail. detailed command description with all parameters can be found VMware KB
vdf – will print vmfs datastore usage

How to check ESX version?
typing on CLI vmware -v

Restart Management network
ESXi
/etc/init.d/hostd restart
/etc/init.d/vpxa restart

ESX
service vmware-vpxa restart

Posted in Topics | Leave a comment

Get Guest OS from Host or Vcenter

Get-VMHost XXXXXX | Get-VM | Get-VMGuest

Get-VMHost au01esx204 | Get-VM | Get-VMGuest | Select OSFullName, State, VM, GuestFamily | Export-Csv E:\Shehbaaz\myreport1.csv

Get-Cluster “Cycle30 – Server Cluster” | Get-VMHost | Get-VM | Get-VMGuest | Select OSFullName, State, VM, GuestFamily | Export-Csv E:\Shehbaaz\myreport3.cs

Posted in Topics | Leave a comment

Linux/Unix installation commands

rpm
yum
apt-get
urpmi

Posted in Topics | Leave a comment

Linux/Unix power commands

init –help
init 6 reboot

telinit

halt – with root access

sudo halt – with user access

reboot

poweroff

Posted in Topics | Leave a comment

Centralized logging on ESXi

Go to VCenter server
create a folder in the shared datastore (remember the path)
Select the host and go to configuration
under the software section, select advanced setting
select syslog and change the datastorepath (shared datastore path)

Posted in Topics | Leave a comment

Generate and Export log bundle for esx/vcenter

1. Login to the VCenter
go to home – systemlog – export Vcenter logs

2. Login to the esx using vsphere client
go to home – systemlog – export

3. Go to the VCenter server again
all programs – generate Server log bundle

4. Using WinSCP
Open and connect to esx host server with root UN and PWD
Select SCP file protocol
Once connected: /var/log/ or /var/log/vmware
select the log you need and drop to local data

5. vm-support /f (for full bundle) from esx host

6. vc-support.wsf /f (for full bundle) from VCenter server
cd program files/vmware/infrastructure/VirtualCenter Server/scripts

cscripts vc-support.wsf to get support information

Posted in Topics | Leave a comment

vMA management

–vifp addserver
–vifp listservers
-vifptarget -s servername (to set) (not available in 5.1.x)

Log in to the vMA console as the root user.
Open the /etc/bash.bashrc file using a text editor.
At the end of the /etc/bash.bashrc file, add the lines:

alias vifptarget=”source /opt/vmware/vma/bin/vifptarget”
source /opt/vmware/vma/bin/completion_vifp
source /opt/vmware/vma/bin/completion_vifptarget
source /opt/vmware/vma/bin/completion_vifs
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}/opt/vmware/vma/lib64:/opt/vmware/vma/lib

Save and close the /etc/bash.bashrc file.
To apply the changes, run the command:
source /etc/bash.bashrc

-vicfg-nics (to display the nics on servername
-vifgtarget -c (to clear the selection)

————————————————————

We can save the session that can help us to skip typing the servername and target commands

/usr/bin/share/doc/vmware-vcli/samples/session
ls
save_session.pl

./save_session.pl –server esx3 –username root –password Howdy@123 –savesessionfile /home/vi-admin/esxsession

this will save the session; Next
then go to the target location
/home/vi-admin/vicfg-nics -l -sessionfile esxsession

For vi-user
sudo reboot – to restart
sudo halt to shutdown

For vi-admin
reboot
halt

Posted in Topics | Leave a comment

Configure vMA as a log server for vShpere

Configure vMA as a log server for vShpere

Vilogd – performs log collections
Vilogger – is used to enable/disable or configure
Commands to add a server:
–vifp addserver
–vifp listservers
–vilogger enable
–vilogger list
–vilogger updatepolicy

Logs will be located in /var/log/vmware/[Server]
Vilogger config file is in
/etc/vmware/viconfig/vilogdefaults.xml
Control vilogd with /etc/init.d/vmware-vilogd restart
Disable vilogger with vilogger disable

Posted in Topics | Leave a comment

Collecting diagnostic information using the vm-support command in VMware ESX/ESXi (1010705)

Running vm-support in a console session on ESXi/ESX hosts

vm-support
A compressed bundle of logs is produced and stored in a file with a .tgz extension in one of these locations:

/var/tmp/
/var/log/
The current working directory
To export the log bundle to a shared vmfs datastore, use this command:

vm-support -f -w /vmfs/volumes/DATASTORE_NAME

Note: The -f option is not available in ESXi 5.x, ESXi/ESX 4.1 Update 3, and later.

Posted in Topics | Leave a comment

Collecting the VMware vSphere Replication logs (2013091)

You can use the vSphere Replication logs for troubleshooting and analysis. A VMware support engineer might request these logs during a support call.

To automatically gather a vSphere Replication log bundle from the VRMS Server using the command line

To collect logs from the VRMS server:
Open the console for the VRMS server appliance and log in as the root user. The default password is vmware.
Confirm PermitRootLogin is set to yes in the SSH configuration file.
To set the PermitRootLogin parameter to yes:

Open the /etc/ssh/sshd_config file using a text editor.
Locate the line that begins with PermitRootLogin.
Set this parameter to yes.
Save and close the file.
Restart the sshd service using this command:
service sshd restart

Start generating the support bundle using this command:
/opt/vmware/hms/generatesupportbundle.sh

The completed log bundle is located at:
/opt/vmware/hms/support/HSB-hms-/bundle.tar.gz

Connect to the VRMS server appliance using an SFTP client, such as FileZilla, and download the log bundle.
Note: By default, the VRMS server logs (hms*.log ) are located at /opt/vmware/hms/logs.

————————————————————————————————-
To automatically gather a vSphere Replication log bundle from the VR Server using the command line

To collect logs from the VR server:
Open the console for the VR server appliance and log in as the root user. The default password is vmware.
Start generating the support bundle using this command:
/usr/bin/hbrsrv-support-bundle.sh

The completed log bundle is located in:
/tmp/hbrsrv-2011-08-20-14-34-6.tgz

Connect to the VR server appliance using an SFTP client, such as FileZilla, and download the log bundle.

Notes:
By default, the VR server logs (hbrsrv*.log ) are located at /var/log/vmware.
The /var/log/messages file can also be a useful source of information for VR server issues.

Posted in Topics | Leave a comment

Crashing a virtual machine on ESX/ESXi to collect diagnostic information (2005715)

ESXi 5.x

Obtain a list of all registered and running virtual machines using this command:
vm-support –listvms
vmdumper -l

Collect coredumps from a specific virtual machine, plus performance metrics and logs from the host, using this command:

vm-support –performance –groups=”HungVM Fault Hardware Logs Network Storage System Userworld Virtual” –vm=””

A vm-support log bundle is created locally on the host, the filename is displayed when complete. Copy this file off the host manually.

—————————————————————————————————
ESX/ESXi 3.x and 4.x
vm-support -x
vm-support -X

A vm-support log bundle is created locally on the host, the filename is displayed when complete. Copy this file off the host manually.
—————————————————————————————————
ESX/ESXi 3.x – 5.x vmdumper command-line

ESXi: /sbin/vmdumper -l
ESX: /usr/lib/vmware/bin/vmdumper -l

Example output:

wid= pid=-1 cfgFile=”/vmfs/volumes/path/to/filename.vmx” uuid=”ab cd ef …” displayName=”Virtual Machine Name”

Create coredumps from the VMM and VMX using four vmdumper commands:

vmdumper unsync
vmdumper sync
vmdumper vmx
vmdumper vmx_force

Coredumps are created in the virtual machine’s working directory, beside the .vmx configuration file. Copy the files manually, or while collecting logs from the host. For more information, see Collecting diagnostic information for VMware ESX/ESXi using the vSphere Client (653) or Collecting diagnostic information for VMware ESX/ESXi using the vm-support command (1010705).
————————————————————————————————-
ESXi 5.x HTTP-based vm-support

Prerequisites
The hostd management service must be running
The virtual machine’s .vmx configuration file path must be known.
On ESXi 5.x, a web browser or other HTTP client can be used to download a vm-support log bundle, specifying manifests to create or collect specific information from a host or virtual machine.

Using a web browser or other HTTP client, fetch the url:

https://:@/cgi-bin/vm-support.cgi?groups=HungVM &vm=

Example: Using wget,

wget –no-check-certificate ‘https://root:password@10.11.12.13/cgi-bin/vm-support.cgi?groups=HungVM Fault Hardware Logs Network Storage System Userworld Virtual&vm=’

After a few moments, the client downloads a vm-support log bundle containing the results of generating coredumps for the specified virtual machine.

Posted in Topics | Leave a comment

Registering a VM on ESX/ESXi

vmware-cmd -s register \.vmx

vim-cmd solo/registervm /vmfs/volumes/datastore_name/VM_directory/VM_name.vmx

Posted in Topics | Leave a comment

RAMDISK disk is full

First check the files

df -h
vdf -h
ls -arth

according check the log occupying the space and remove it
rm command to remove the file from the dir/folde

rm /xxx.log from root
rm /var/xxx/xxx.log from the folder

ESXi ramdisk full due to /var/log/hpHelper.log file size ————-
To remove the hpHelper.log file:
/etc/init.d/hp-ams.sh stop
rm /var/log/hpHelper.log
/etc/init.d/hp-ams.sh start
chkconfig hp-ams.sh off

Posted in Topics | 3 Comments

Powering off a virtual machine on an ESXi host (Force and soft)

ESXi 5.x and above —-
esxcli vm process list
esxcli vm process kill –type=[soft,hard,force] –world-id=WorldNumber OR
esxcli vm process kill -t [soft,hard,force] -w WorldNumber

ESXi 4.1
esxcli vms vm list
esxcli vms vm kill –type=[soft,hard,force] –world-id=WorldNumber
esxcli vms vm kill -t [soft,hard,force] -w WorldNumber

PowerCLI:
Soft kill: Get-VM XYZ | Kill-VM
Force Kill: Get-VM XYZ | Kill-VM -Killtype force

SSH:
vim-cmd vmsvc/getallvms
vim-cmd vmsvc/power.getstate VMID
vim-cmd vmsvc/power.shutdown VMID
vim-cmd vmsvc/power.off VMID

ps | grep vmx
kill (process id)
kill -9 (process id) [this is the force command]

ESXTOP:
esxtop
c to switch to CPU view
shift+v to limit the view to the VM
f to display the list of fields
c to add the coloum for the leader World ID (LWID)
Identify the target virtual machine by its Name and Leader World ID (LWID)
Press k
enter the world ID to kill
——– wait 30 secs ———

Posted in Topics | Leave a comment

Get ESX/ESXi version from command line

uname -a
esxcli system version get

Posted in Topics | Leave a comment

List running/registered VMs on ESX/ESXi host

ESX 3.5|4.0|4.1

vmware-cmd -l
vmware-vim-cmd vmsvc/getallvms

ESXi 3.5|4.0|4.1|5.0|5.1|5.5

vim-cmd vmsvc/getallvms
esxcli vm process list
vm-support –listvms

vm-support -V

Posted in Topics | Leave a comment

Protected: Microsoft & Vmware Licensing, programs and much more information

This content is password protected. To view it please enter your password below:

Posted in Topics | Enter your password to view comments.

Protected: Server Sizing in Virtual Environment

This content is password protected. To view it please enter your password below:

Posted in Topics | Enter your password to view comments.

Protected: IOPs Calculator

This content is password protected. To view it please enter your password below:

Posted in Topics | Enter your password to view comments.

Protected: RAID understanding and Calculations

This content is password protected. To view it please enter your password below:

Posted in Topics | Enter your password to view comments.

Open Directory to Active Directory Migration: FV & Mobile enabled user | Manual migration GUI

Posted in Topics | Leave a comment

How to recover VMware ESXi root password ?

In order to recover the root password, you need  ubuntu Desktop operating system DVD.

1.) Halt the VMware ESXi server from the console (Hardware console whatever you have) since we can’t login to ESXi host to shutdown the server by pressing F12.

2.) Boot the server from ubuntu Desktop DVD. Here I am using ubuntu Desktop 14.04 (Latest Version) since it will work as Live CD.

3.) Once the Ubuntu is boot up , it will ask two option. You just select “Try Ubuntu”. We don’t want to install it .

4.) From the Ubuntu desktop, Click on the search icon and search for terminal .

Here you go.Double click the terminal icon.

5.) In the terminal , just gain root access by using Sudo command.Use fdisk command to list the available disks.

VMware ESXi root disk

6.) Normally /dev/sda will be the root disk of VMware ESxi . As per the above screenshot , sda is having GPT partition and it’s not supported in fdisk .Let me try from Gparted utility.

Search gparted and open it

Gparted screen will something like below one.

Gparted - /dev/sda

7.) You need to mount /dev/sda5 to recover the VMware ESXi password. You need to identify in terms of size and flag.Once you have mounted , you can see files like the below screen shot.

Mount /dev/sda5

8.) Copy the file “state.tgz” to /tmp . Then untar the state.tgz which will create file called local.tgz.

untar the state.tgz file

9.) untar the local.tgz file and it will create a directory called “etc”.

untar the local.tgz file

10.) Go to the “etc” directory and edit the file called “shadow” using vi editor. You need to remove the strings between the first colon to the second colon.(which will be encrypted password).

clear the root password of VMware ESXi

11.) Here I am updating the “etc” to local.tgz and local.tgz to state.tgz. After updating the tar files , I am copying the updated state.tgz file to /mnt where we have mounted the VMware ESXi root.

copy the updated tgz file to ESXi root FS

12.) Unmount the /mnt and reboot it . Please make sure that you need to remove the “ubuntu Desktop” DVD from the server.So that it can boot from local hard disk.

umount & reboot the ubuntu

13.) Once the VMware ESXi 5.5 boots up , just log in as root without a password.

Login to VMware Esxi

14.) Please make sure that you are setting the new root password and store it confidentially. Do not lose it again.

Change password of VMware Esxi

Change password of VMware ESXi

We have successfully reset/recover the root password of VMware ESXi 5.5 host.

Note: VMware is not responsible if you lose something after the root password reset by following above method. I didn’t face any issue after   following this method .It may differ to another environment.

Credit: http://www.unixarena.com/2014/05/recover-vmware-esxi-root-password.html

Posted in Topics | Leave a comment

Remove VM lock from Host (.lck)

1) esxcli vm process list

You see output similar to:

VirtualMachineName
World ID: 1268395
Process ID: 0
VMX Cartel ID: 1264298
UUID: ab cd ef ...
Display Name: VirtualMachineName
Config File: /path/VirtualMachineName.vmx

2) esxcli vm process kill –type=soft –world-id=xxxxxx

This kills the VM  process and removes the lock

Posted in Topics | Leave a comment

Get ESXi license information though CLI

vim-cmd vimsvc/license –show

Posted in Topics | Leave a comment

Find VirtualCenter IP address through ESXi box

To check VirtualCenter IP address

Log in to the ESXi /ESX host with an SSH client as root. For more information, see Connecting to an ESX host using a SSH client (1019852).
Navigate to the /etc/opt/vmware folder by typing:

cd /etc/opt/vmware

Review the serverIP configuration section of the/etc/opt/vmware/vpxa.cfg file to see if the IP address is correct
Run the command:

cat /etc/opt/vmware/vpxa.cfg | more

Posted in Topics | Leave a comment

Dell OpenManage commands on Linus/Unix servers

To stop the Dell OpenManage(TM) Server Administrator service,
run “omconfig system webserver action=stop”

To start the Server Administrator service,
run “omconfig system webserver action=start”

To stop the Server Administrator Storage Management Service,
run “/etc/init.d/dataeng stop”

To start the Server Administrator Storage Management Service,
run “/etc/init.d/dataeng start”

Posted in Topics | 2 Comments