Tech Center

This page is a home for my technology related posts.

Disclaimer!

The views, information or opinions expressed on this site are my own and do not represent my current/future employer or customer.

The author of the information takes no responsibility of any damages that may occur using the information.

You are free to share or redistribute the information as you seem fit.

Collecting esxtop data for long intervals

While troubleshooting performance issues with Vmware support, a constant ask that comes forward is to collect esxtop data during the issue. This can be operational nightmare as performance issues are unpredictable and can happen when there is no one around to take actions. The best solution to this is to use vROPs as it can collect most of the data that esxtop can. In cases where vROPs is not available a simple bash script can help Code: #!/bin/sh x=0 while [ $x -lt $1 ] do x=$(( $x + 15)) mkdir /vmfs/volumes/$2/esxtop_data time=$(date +%s) esxtop -b -a -d 2 -n 450 | gzip -9c >/vmfs/volumes/$2/esxtop_data/esxtop_$time.csv.gz done How to use?
  1. Save the code in a file. Let's say test.sh
  2. chmod +x on the file (chmod +x test.sh)
  3. Execute test.sh
Syntax: ./test.sh 15 56c125f1-f9b4b30a-31e6-e0db550bb0d6 In the above command '15' is the number of minutes you would like the collection to run. You can increment ...

Adding the host to Distributed switch and Mapping the VMs [V2]

A few days ago, I posted a DVS management script that added hosts, uplinks and mapped VM based on user inputs in the form of prompts and csv file. A colleague of mine used that script and found a use case where it could be seriously destructive. I will refer to that as V1 script in rest of the post Failed use case: The V1 script made use of Auto assign vmnic to DVS uplink. Due to this there was no way to specify vmnic to uplink mapping. Hence, in an environment where vmnic to uplink mapping is required to be a constant the V1 script broke the setup. The code below is updated to add the vmnic to uplink mapping feature Code: Do not use the script without testing it in your Test/Dev environment Start-Transcript -Append -Path "$env:USERPROFILE\Documents\DVScopy.log" $vCenterIP = Read-Host "Enter vCenter IP or Name where the operation ...

What’s wrong with this code?

Code: $vCenterIP ="vc.vmzoneblog.com" Connect-VIServer $vCenterIP $myDatacenter ="nukescloud" $Cluster ="sgp" $NewDVS ="DSwitch" $NicName ="vmnic4" $UplinkName="Uplink 4" $hostnames=Get-Datacenter -Name $myDatacenter | Get-Cluster -Name $Cluster | Get-VMHost $hostnames=$hostnames.name ForEach ($hostname in $hostnames) { Write-Host -ForegroundColor red "The $hostname already has 1 or more physical Nics on $NewDVS" $EsxHost = Get-VMHost -Name $hostname $vds = Get-VDSwitch -Name $NewDVS -VMHost $EsxHost $uplinks = Get-VDPort -VDSwitch $vds -Uplink | where {$_.ProxyHost -like $hostname} $config = New-Object VMware.Vim.HostNetworkConfig $config.ProxySwitch = New-Object VMware.Vim.HostProxySwitchConfig[] (1) $config.ProxySwitch[0] = New-Object VMware.Vim.HostProxySwitchConfig $config.ProxySwitch[0].Uuid = $vds.ExtensionData.Uuid $config.ProxySwitch[0].ChangeOperation = 'edit' $config.ProxySwitch[0].Spec = New-Object VMware.Vim.HostProxySwitchSpec $config.ProxySwitch[0].Spec.Backing = New-Object VMware.Vim.DistributedVirtualSwitchHostMemberPnicBacking $config.ProxySwitch[0].Spec.Backing.PnicSpec = New-Object VMware.Vim.DistributedVirtualSwitchHostMemberPnicSpec[] (2) $config.ProxySwitch[0].Spec.Backing.PnicSpec[0] = New-Object VMware.Vim.DistributedVirtualSwitchHostMemberPnicSpec $config.ProxySwitch[0].Spec.Backing.PnicSpec[0].PnicDevice = $NicName $config.ProxySwitch[0].Spec.Backing.PnicSpec[0].UplinkPortKey = $uplinks | where{$_.Name -eq $UplinkName} | Select -ExpandProperty Key $config.ProxySwitch[0].Spec.Backing.PnicSpec[1] = New-Object VMware.Vim.DistributedVirtualSwitchHostMemberPnicSpec $config.ProxySwitch[0].Spec.Backing.PnicSpec[1].PnicDevice = $uplink.ConnectedEntity | Where-Object {$_.ConnectedEntity.Name -like "vmnic*"} $config.ProxySwitch[0].Spec.Backing.PnicSpec[1].UplinkPortKey = $uplink.Key | Where-Object {$_.ConnectedEntity.Name -like "vmnic*"} $changeMode = 'modify' $netSys = Get-View -Id $EsxHost.ExtensionData.ConfigManager.NetworkSystem $netSys.UpdateNetworkConfig($config, $changeMode) Write-Host -ForegroundColor Green ...

Adding the host to Distributed switch and Mapping the VMs [V1]

Hello 2020 and my fist technical post of the year. Use case: You have built a new vCenter from scratch and would like to move host from an existing vCenter server to this one. As a preparation for this migration you performed following steps 1Created Network mapping of all VMs in the source vCenter server2Exported the Distributed switch configuration from the source vCenter server3Imported the Distributed switch configuration to the new vCenter server4Added ESXi hosts in the New vCenter server to their respective Datacenter and cluster However, you are still left with mammoth task of adding the host to Distributed switch and Mapping the VMs to a Distributed PortGroups. If you have not completed the Step 1 above, you may do so using the code below Code to create Network mapping: Start-Transcript -Append -Path "$env:USERPROFILE\Documents\NetMap.log" $vCenterIP = Read-Host "Enter vCenter IP or Name where the operation needs to be ...

LIST 10 LARGEST TABLES (vPostgres)

Connecting to a vPostgres instance: For most VMware products you can connect to the vPostgres instance using the command below /opt/vmware/vpostgres/current/bin/psql -U postgres -d VCDB Sometimes, the default user for vPostgres is not "postgres". The above command will fail in that case. One such application is Site Recovery Manager. For these applications, you can find the vPostgres user details by reviewing the out of ps -aux command. Look at the line 3, the location following "-D" is where you should find pg_hba.conf. Look at the line 11 and 22, the information following "postgres:" is "user" followed by "database" ps -aux | grep -i postgres vpostgr+ 1405 0.0 0.0 1599532 19904 ? Ss 00:41 0:00 postgres: vumuser VCDB 127.0.0.1(54316) idle vpostgr+ 2847 0.0 0.2 1597388 94352 ? S Nov11 4:20 /opt/vmware/vpostgres/current/bin/postgres -D /storage/db/vpostgres vpostgr+ 2903 0.0 0.0 68964 4592 ? Ss Nov11 0:13 postgres: logger process vpostgr+ 2919 0.0 0.6 1598588 ...
/ / PGSQL, The Tech Center, vPostgres