Tuesday, August 30, 2016

Incorrect Nic to Mac Address table at ESXi

We had a situation here on a cisco c240 server where the mac to vmnic number was different and not in series.
The pic that you see is after we fixed it. Earlier the vmnic numbering was
Intel  I350

 Intel 82599 10 Gig ethernet

 Intel ethernet x540

where it should have been how it is in the picture. What my colleague and mentor kung fu panda aka ravi sutrave did was pretty simple, he renamed these last 4 suckers (vmnics) with some temporary names like this in the esx.conf file,



and then renamed them back to the way they should have been in the first place.



Yes we did reboot the hosts few times and these settings were persistent across reboots. If you want to do the same on multiple hosts then you can use the plink and push these commands to all hosts at once.
I have handy dandy tool which will take care of it (enable ssh, push commands via ssh, disable ssh), try it and let me know if it doesnt work on twitter.
Here is the https://raw.githubusercontent.com/MrAmbiG/vmware/master/vTool/vTool_2016aug.ps1 vtool and in one of its menus it contains WinSSH. Run that and it will take you through the process of pushing any ssh commands to esxi hosts.

Friday, August 12, 2016

VMware Esxi Performance Modes

It is quite normal for anyone wanting to extract as much as they can from a hardware that they have bought. Make optimal use of it. When you are looking at Esxi hosts you are looking at a certified hardware which has been tested and tasted by experts at VMware and the vendor. If you have put some thousands or crores of money into your hardware, then you might well make the best use of it. If you are a biological being, then you want to live longer but if you are hardware then you want to do the best before you become obsolete.
VMware itself supports 3 types of performance or power modes.
1.       High Performance
2.       Balanced
3.       Low power
I myself would put my hosts in high performance mode but your scenarios might differ. I mean does it make sense to put your bike always on high throttle or wheelie mode (if you have any of the newer street bikes with different riding modes coz I don’t) in a city traffic? No. Below is a glimpse of where you can do it via GUI.
I would however want to do this via Powercli where you can get this done to all your esxi hosts at once. High performance mode as the name suggests, the operating system assumes that your workload’s requirement of resources keeps changing drastically and it always needs the resources to be ready. It does however comes at the cost of more power consumption. The main goal here is the performance and power consumption is of no concern to the esxi host.
Balanced as the name itself suggests will maintain a balance between the power consumption and the performance. Here esxi will still give priority to the performance but not at the cost of too much power consumption.
Low Power is the most energy saving mode where esxi will prioritize on power saving against performance. This can be used for failover hosts in a cluster if your HA settings are such that you have reserved hosts for failover.
Combine this with the BIOS settings of your esxi hosts and you will have some amazing performance for your hosts.
I would suggest the following for your environment if you are wondering what is the right one for your environment. I suggest 2 ways of deciding it.
Method 1: Flactuation
You can approximately consider the following values per day or week.
Lowerst % of resource Usage
Highest % of Resource Usage
Flactuation [H-L]
Performance Setting
30 - 40
High Performance
20 - 30
20 - 10
Low Power

Method 2: Maximum Resource Usage
-+70% to -+90% à High performance
-+50% to -+70% à Balanced
50% or less         à Low Power
Here -+ stands for plus or minus, meaning an approximation or round figure.
This will set the performance of your esxi hosts to High Performance.
(Get-View (Get-VMHost | Get-View).ConfigManager.PowerSystem).ConfigurePowerPolicy(1)
Please note that here
1. High performance
2. Balanced
3. LowPower

You would however may not remember the above 3 options against their numbers. So it might be better to do a write-host for this function where it will inform about it and asks you to choose.
Write-Host "choose a number from below
1. High performance
2. Balanced
3. LowPower
" -BackgroundColor White -ForegroundColor Black

And take the user input after this with
$option = Read-Host "?"
It is also annoying that this won’t tell you the real progress or won’t tell you currently on which host is it running. That is why we might want to create a loop for each host and display the name of the host before it runs.
foreach ($vmhost in (get-cluster $cluster | get-vmhost | sort))
(Get-View (Get-VMHost $vmhost | Get-View).ConfigManager.PowerSystem).ConfigurePowerPolicy($option)
 This is how it will look at the end with some timers built in the script to tell you how much it took for you to run this script.
$cluster = Read-Host "name of the cluster[type * to include all clusters]?"
Write-Host "choose a number from below
1. High performance
2. Balanced
3. LowPower
" -BackgroundColor White -ForegroundColor Black
$option = Read-Host "?"

$stopWatch = [system.diagnostics.stopwatch]::startNew()

foreach ($vmhost in (get-cluster $cluster | get-vmhost | sort))
(Get-View (Get-VMHost $vmhost | Get-View).ConfigManager.PowerSystem).ConfigurePowerPolicy($option)

Write-Host "Elapsed Runtime:" $stopWatch.Elapsed.Hours "Hours" $stopWatch.Elapsed.Minutes "minutes and" $stopWatch.Elapsed.Seconds "seconds." -BackgroundColor White -ForegroundColor Black

Obviously you have noticed that I have left out the custom option. Well that is for you to discover and I am sure it will be worth your time.
I have put this into my vTool at github which contains a lot of such useful functions to make your life easier.

Friday, August 5, 2016

SSH PowerShell tricks with plink.exe

Okay i know i know, i am re using the same title from alan renouf's [http://www.virtu-al.net/2013/01/07/ssh-powershell-tricks-with-plink-exe/ ] site but this is in actuality the same content too.
The original scriptlet from alan renouf served me well so far untill i realized it won't do the 2 things that I want
1. There is no time out for the plink download, if it is blocked in your environment then it will just hang there and you have to close your powershell/powercli/ise to restart the whole process.
2. It won't wait for the user to manually copy the plink in that folder.
I thus decided to go with
Instead of
Since the former offers a time out period.
I also did a small do loop to keep asking for plink if it is not present in the folder. Another good thing about
is, it will download it to the root directory of the script without you mentioning it. Nice han!
Here is how the function looks
$PlinkLocation = $PSScriptRoot + "\Plink.exe"
$presence = Test-Path $PlinkLocation
if (-not $presence)
    Write-Host "Missing Plink.exe, trying to download...(10 seconds)" -BackgroundColor White -ForegroundColor Black
    Invoke-RestMethod "http://the.earth.li/~sgtatham/putty/latest/x86/plink.exe" -TimeoutSec 10 -OutFile "plink.exe"
    if (-not $presence)
            Write-Host "Unable to download plink.exe, please download and add it to the same folder as this script" -BackgroundColor Yellow -ForegroundColor Black
            Read-host "Hit Enter/Return once plink is present"
            $presence = Test-Path $PlinkLocation
            } while (-not $presence)

if ($presence) { Write-Host "Detected Plink.exe" -BackgroundColor White -ForegroundColor Black }
as you can see the line one is the location of the plink (root directory of the script).
2nd line creates a variable to check whether that plink’s path is true or not. The rest is pretty straight forward from then onwards.
You can always get it from my github page.