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.

Reset Syslog.Global.Loghost to blank

This morning I worked with the customer where syslog traffic was choking an already crippled network. As a quick fix we wanted to spare the network from syslog data being generated by ESXi hosts. The only problem was that we had a few hundred host at hand. SSH and UI was not an option. #Change the FQDN of vCenter server per your enviroment Connect-VIServer -Server vc.nukescloud.com #Change the $Cluster as per your enviroment $cluster = "sgp" #Change the $datacenter as per your enviroment $datacenter = "nukescloud" #Applying the setting $hosts = Get-Datacenter $datacenter | Get-Cluster -Name $cluster | Get-VMHost Get-AdvancedSetting -Name "Syslog.Global.Loghost" -Entity $hosts | Set-AdvancedSetting -Value "" #Change the -Server per your enviroment Disconnect-VIServer -Server vc.nukescloud.com ...
/ / PowerCLI, PowerShell, The Tech Center

Debloat DB (PostgreSQL) for VMware appliances

As vSphere admin you might be managing a few VMware appliances running an instance of PostgreSQL like SRM, vCenter etc In most of these appliances PostgreSQL runs with the default setting for Auto-vacuum. In some setups the default setting might not be aggressive enough to keep the DB lean. If you have a fat DB, you might want to check the bloating levels The procedure requires the application services to be down. Step1: Connect to the application DB
  • Connect to the appliance using SSH as root
  • Connect to the PostgreSQL instance
/opt/vmware/vpostgres/current/bin/psql -U postgres
  • The above will connect you to the default DB instance which in a few cases might not be the application DB
  • List the database present on the system using the meta command \l
VCDB=# \l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+----------+----------+-------------+-------------+----------------------- VCDB ...

Find CPU, Memory and Volume Info

Introduction: As a Wintel admin you might come across a situation where you want specific information about CPU, Memory and Volume information for multiple servers. The script below is a quick way to find this info Prerequisite:
  1. The user that runs this script must have local administrator access on the remote system
  2. You need to have a list of host names or IPs for the remote systems
  3. PowerShell version 5 or above
Code: Remove-Item $env:USERPROFILE\Documents\MemInfo.csv $env:USERPROFILE\Documents\CpuInfo.csv $env:USERPROFILE\Documents\DiskInfo.csv Start-Transcript $env:USERPROFILE\Documents\findSysInfo.log $SystemNames = Get-Content $env:USERPROFILE\Documents\Systemlist.txt echo "SystemName,BankLabel,Capacity,DeviceLocator,Speed" > $env:USERPROFILE\Documents\MemInfo.csv foreach ($SystemName in $SystemNames) { $CpuInfo = Get-WmiObject -ComputerName $SystemName -class win32_processor -Property SystemName,Manufacturer,DeviceID,MaxClockSpeed,NumberOfCores,NumberOfLogicalProcessors | Select-Object SystemName,Manufacturer,DeviceID,MaxClockSpeed,NumberOfCores,NumberOfLogicalProcessors | Export-Csv -Append -NoTypeInformation $env:USERPROFILE\Documents\CpuInfo.csv $DiskInfo = Get-WmiObject -ComputerName $SystemName -Class Win32_Volume -Property SystemName,DriveLetter,Label,BootVolume,BlockSize,FileSystem,Capacity,FreeSpace | Select-Object SystemName,DriveLetter,Label,BootVolume,BlockSize,FileSystem,Capacity,FreeSpace | Export-Csv -Append -NoTypeInformation $env:USERPROFILE\Documents\DiskInfo.csv $MemInfo = Get-WmiObject -ComputerName $SystemName -Class Win32_PhysicalMemory -Property BankLabel,Capacity,DeviceLocator,Speed | Select-Object BankLabel,Capacity,DeviceLocator,Speed foreach($Obj in $MemInfo ) { $BankLabel = $Obj.BankLabel $Capacity = $Obj.Capacity $DeviceLocator = $Obj.DeviceLocator ...
/ / PowerShell, The Tech Center

Mass lunreset

Introduction: The organization's data center suffered a power loss impacting multiple components and systems. Post the power restoration you are observing issues with in your SDDC platform like but not limited to below
  1. ESXi hosts keep dropping out of vCenter server
  2. Multiple VMFS datastores are inaccessible or facing performance issues
  3. Host reboots have been attempted
  4. The scale of the environment is making it difficult to isolate the hosts that need a reboot
Solution: A quick and dirty way to recover out of the situation is to perform a Mass LUN reset. Since, we are already broken this cannot make the situation any worse. Run the script below on all powered on ESXi hosts in the environment. It is preferable to run the script simultaneously on the hosts in a same cluster naaIds=`ls /vmfs/devices/disks/ | grep -i :1 | grep -v vml | awk -F: '{print $1}'` for i in $naaIds; ...
/ / The Tech Center, vSphere