Tuesday, December 3, 2019

How to Install or upgrade the VMWare Tools


1.    Select machine on which wants to install/upgrade the VMWare tools (Navigate to Summary > Install/Upgrade VMWare Tools)



     2. Select the Interactive Upgrade option and click on Upgrade.


    3. After upgrade selection you can see and verify the ISO image is connected as mentioned below.


   4. Now take access of machine and mount the attached ISO.

   # mount /dev/cdrom /mnt/

   5. Temporary copy the VMWareTools upgrade tar to local machine.

   # mkdir /tmp/vmware

   # cp VMwareTools-10.3.5-10430147.tar.gz /tmp/vmware/

   # cd /tmp/vmware/

   # tar xzvf VMwareTools-10.3.5-10430147.tar.gz

   # cd vmware-tools-distrib/

   # ./vmware-install.pl


   Press “Enter” on asked inputs.

   Once installed the tools successfully it will prompt the status of installed tool and its service status.

   6. Check the service status by below command.

   # /etc/vmware-tools/services.sh “status/start/stop”


   7. It will automatically eject the ISO file, if not then un-mount the ISO file manually and    disconnect/verify it from vCenter.

   8. Check and verify the status of VMware Tools from vCenter.



   9. Re-config the VMWare tools after each Kernel upgrades.

   # ./usr/bin/vmware-config-tools.pl

   VMware automatic kernel modules: yes

   10. Upgrade VMware Tools in Windows machines.

    Fist attach the ISO as mentioned in Points 1, 2 & 3.
    Take access of machine and open the CD/DVD, there you can see and run the VMware/setup.exe
    Follow the instructions for successfully installation/up gradation of tools.
    Restart the machine when prompted and disconnect the CD/DVD from vCenter.
    Verify the VMware Tools status from vCenter (As mentioned in point no. 8).


Thursday, January 10, 2019

[Solved]: unable to add devices in OpenDCIM

If unable to add device in OpenDCIM, need to find below method to get it resolved.

# mysql -u root -p
# select @@global.sql_mode;
# set sql_mode="";
# SET GLOBAL sql_mode = "";
# service httpd restart

Re-scan Disk after adding disk to virtual machine

Execute below command after add the disk to the machine in vmware.

# ls /sys/class/scsi_host

host 0

# echo "- - -" > /sys/class/scsi_host/host0/scan

# fdisk -l

Friday, July 20, 2018

Create script to get gateway address, DNS, NTP, & Service Status in Linux

Copy the below content and paste it in a file, it will give you the output at /opt/ location, if you wants to change the location you can change.

You have to change the NTP server IP Address in file rest of the things will work on all environment.

#!/bin/bash
rm -rf /opt/ping_result
echo -e "\nTIMESTAMP: `date`" >> /opt/ping_result
echo -e "HOSTNAME: `hostname`"  >> /opt/ping_result
#hostname >> /opt/ping_result
GW=`/sbin/ip route | awk '/default/ { print $3 }'`
checkdns=`cat /etc/resolv.conf | awk '/nameserver/ {print $2}' | awk 'NR == 1 {print; exit}'`
checkntp1=10.200.247.21
checkntp2=10.200.247.22
output=/opt/ping_result
GN='\033[0;32m'
RD='\033[0;31m'
NC='\033[0m'
function pingdns 
{
  tput setaf 6; echo -e "Pinging DNS server in resolv.conf ($checkdns) to check name resolution" >> $output; tput sgr0;
  ping $checkdns -c 4
    if [ $? -eq 0 ]
    then
      tput setaf 6; echo -e "${GN}Primary DNS is Pingable.${NC} Proceeding with NTP Server 1 Check. \n" >> $output; tput sgr0;
    else
      echo -e "Could not establish internet connection to DNS. ${RD}Something may be wrong here.${NC} \n" >> $output >&2
  fi
}
function pingntp1
{
  tput setaf 6; echo -e "Pinging ($checkntp1) to check NTP status"  >> $output; tput sgr0;
  ping $checkntp1 -c 4
    if [ $? -eq 0 ]
    then
      tput setaf 6; echo -e "${GN}NTP Server 1 is Pingable.${NC} Proceeding with NTP Server 2 check. \n" >> $output; tput sgr0;
    else
      echo -e "Could not establish connection to NTP Server 1. ${RD}Something may be wrong here.${NC} \n" >> $output >&2
  fi
}
function pingntp2
{
  tput setaf 6; echo -e "Pinging ($checkntp2) to check NTP status" >> $output; tput sgr0;
  ping $checkntp2 -c 4
    if [ $? -eq 0 ]
    then
      tput setaf 6; echo -e "${GN}NTP Server 2 is Pingable.${NC} \n" >> $output; tput sgr0;
    else
      echo -e "Could not establish connection to NTP Server 2. ${RD}Something may be wrong here.${NC} \n" >> $output >&2
  fi
}
function services1
{
  tput setaf 6; echo -e "${GN}Running Services${NC}" >> $output; tput sgr0;
  service --status-all | grep running >> $output;
    if [ $? -eq 0 ]
    then
      tput setaf 6; echo -e "${GN}Above Given Services are Running.${NC} \n" >> $output; tput sgr0;
    else
      echo -e "${GN}Above Given Services are Running.${NC} \n" >> $output >&2
  fi
}
function services2
{
  tput setaf 6; echo -e "${RD}Stopped Services${NC}" >> $output; tput sgr0;
  service --status-all | grep stopped >> $output;
    if [ $? -eq 0 ]
    then
      tput setaf 6; echo -e "${RD}Above Given Services are Stopped.${NC} \n" >> $output; tput sgr0;
    else
      echo -e "${RD}Above Given Services are Stopped.${NC} \n" >> $output >&2
  fi
}
tput setaf 6; echo -e "\nPinging Defaut gateway ($GW) to check for LAN connectivity">> $output; tput sgr0;
if [ "$GW" = "" ]; then
    tput setaf 1;echo -e "${RD}There is no gateway. Probably disconnected...${NC} \n" >> $output; tput sgr0;
fi
ping $GW -c 4
if [ $? -eq 0 ]
then
  tput setaf 6; echo -e "${GN}Default Gateway Pingable.${NC} Proceeding with internet connectivity check.\n " >> $output; tput sgr0;
  pingdns
  pingntp1
  pingntp2
  services1
  services2
  exit 0
else
  echo -e "${RD}Something is wrong with LAN (Gateway unreachable)${NC} >> /opt/ping_result "
  pingdns
  pingntp1
  pingntp2
  services1
  services2
fi


The output of the file will as mentioned below.



Wednesday, May 30, 2018

Get Complete Virtual Machine inventory of vcenter using vmwarepowercli

Copy below given script and save it as filename.ps1

execute the same script your output of this script will be saved at "c:\vminventory.csv"


You will get below mentioned information from this script.

1.  VMName
2.  IP Address
3.  Domain Name
4.  Real-OS
5.  vCPU
6.  RAM(GB)
7.  Total-HDD(GB)
8.  HDDs(GB)
9.  Datastore
10. Partition/Size
11. Hardware Version
12. PowerState
13. Setting-OS
14. EsxiHost
15. vCenter Server
16. Folder
17. MacAddress
18. VMX
19. VMDK
20. VMTools Status
21. VMTools Version
22. VMTools Version Status
23. VMTools Running Status
24. SnapShots
25. DataCenter
26. vNic
27. PortGroup
28. RDMs


#Add-PSSnapin vmware.vimautomation.core
Connect-Viserver    
#####################################  
 ## http://kunaludapi.blogspot.com  
 ## Version: 1  
 ## Tested this script on  
 ##  1) Powershell v3  
 ##  2) Powercli v5.5  
 ##  3) Vsphere 5.x  
 ####################################
 function Get-VMinventory {  
 function Get-RDMDisk {  
   [CmdletBinding()]  
   param (  
     [Parameter(Mandatory=$True)]  
     [string[]]$VMName  
     )  
         $RDMInfo = Get-VM -Name $VMName | Get-HardDisk -DiskType RawPhysical, RawVirtual  
         $Result = foreach ($RDM in $RDMInfo) {  
          "{0}/{1}/{2}/{3}"-f ($RDM.Name), ($RDM.DiskType),($RDM.Filename), ($RDM.ScsiCanonicalName)     
         }  
         $Result -join (", ")  
 }  
 function Get-vNicInfo {  
   [CmdletBinding()]  
   param (  
     [Parameter(Mandatory=$True)]  
     [string[]]$VMName  
     )  
         $vNicInfo = Get-VM -Name $VMName | Get-NetworkAdapter  
         $Result = foreach ($vNic in $VnicInfo) {  
           "{0}={1}"-f ($vnic.Name.split("")[2]), ($vNic.Type)  
         }  
         $Result -join (", ")  
 }  
 function Get-InternalHDD {  
   [CmdletBinding()]  
   param (  
     [Parameter(Mandatory=$True)]  
     [string[]]$VMName  
     )  
         $VMInfo = Get-VMGuest -VM $VMName # (get-vm $VMName).extensiondata  
         $InternalHDD = $VMInfo.ExtensionData.disk   
         $result = foreach ($vdisk in $InternalHDD) {  
           "{0}={1}GB/{2}GB"-f ($vdisk.DiskPath), ($vdisk.FreeSpace /1GB -as [int]),($vdisk.Capacity /1GB -as [int])  
         }  
         $result -join (", ")  
 }  
   foreach ($vm in (get-vm)) {  
     $props = @{'VMName'=$vm.Name;  
           'IP Address'= $vm.Guest.IPAddress -join ","; #$VM.ExtensionData.Summary.Guest.IpAddress  
           'PowerState'= $vm.PowerState;  
           'Domain Name'= ($vm.ExtensionData.Guest.Hostname -split '\.')[1,2] -join '.';            
           'vCPU'= $vm.NumCpu;  
           'RAM(GB)'= $vm.MemoryGB;  
           'Total-HDD(GB)'= $vm.ProvisionedSpaceGB -as [int];  
           'HDDs(GB)'= ($vm | get-harddisk | select-object -ExpandProperty CapacityGB) -join " + "            
           'Datastore'= (Get-Datastore -vm $vm) -split ", " -join ", ";  
           'Partition/Size' = Get-InternalHDD -VMName $vm.Name  
           'Real-OS'= $vm.guest.OSFullName;  
           'Setting-OS' = $VM.ExtensionData.summary.config.guestfullname;  
           'EsxiHost'= $vm.VMHost;  
           'vCenter Server' = ($vm).ExtensionData.Client.ServiceUrl.Split('/')[2].trimend(":443")  
           'Hardware Version'= $vm.Version;  
           'Folder'= $vm.folder;  
           'MacAddress' = ($vm | Get-NetworkAdapter).MacAddress -join ", ";  
           'VMX' = $vm.ExtensionData.config.files.VMpathname;  
           'VMDK' = ($vm | Get-HardDisk).filename -join ", ";  
           'VMTools Status' = $vm.ExtensionData.Guest.ToolsStatus;  
           'VMTools Version' = $vm.ExtensionData.Guest.ToolsVersion;  
           'VMTools Version Status' = $vm.ExtensionData.Guest.ToolsVersionStatus;  
           'VMTools Running Status' = $vm.ExtensionData.Guest.ToolsRunningStatus;  
           'SnapShots' = ($vm | get-snapshot).count;  
           'DataCenter' = $vm | Get-Datacenter;  
           'vNic' = Get-VNICinfo -VMName $vm.name;  
           'PortGroup' = ($vm | Get-NetworkAdapter).NetworkName -join ", ";  
           'RDMs' = Get-RDMDisk -VMName $VM.name  
           #'Department'= ($vm | Get-Annotation)[0].value;  
           #'Environment'= ($vm | Get-Annotation)[1].value;  
           #'Project'= ($vm | Get-Annotation)[2].value;  
           #'Role'= ($vm | Get-Annotation)[3].value;  
           }  
     $obj = New-Object -TypeName PSObject -Property $Props  
     Write-Output $obj | select-object -Property 'VMName', 'IP Address', 'Domain Name', 'Real-OS', 'vCPU', 'RAM(GB)', 'Total-HDD(GB)' ,'HDDs(GB)', 'Datastore', 'Partition/Size', 'Hardware Version', 'PowerState', 'Setting-OS', 'EsxiHost', 'vCenter Server', 'Folder', 'MacAddress', 'VMX', 'VMDK', 'VMTools Status', 'VMTools Version', 'VMTools Version Status', 'VMTools Running Status', 'SnapShots', 'DataCenter', 'vNic', 'PortGroup', 'RDMs' # 'Folder', 'Department', 'Environment' 'Environment'  
   }  
 }  
 Get-VMinventory 

 $obj | Sort VMName | Export-Csv -Path "c:\vminventory.csv"