nested hypervisor (on ESXi 5.1)

Sometimes you might want to run a hypervisor on a hypervisor for testing purposes…. this is how you pass through the required CPU extensions in ESXi 5.1

Remember you will also need to enable promiscuous mode on the networking side also.

http://www.virtuallyghetto.com/2012/08/how-to-enable-nested-esxi-other.html

There are some changes with Nested Virtualization in vSphere 5.1 also officially known as VHV (Virtual Hardware-Assisted Virtualization). If you are using vSphere 5.0 to run Nested ESXi or other nested Hypervisors, then please take a look at the instructions in this article. With vSphere 5.1, there have been a few minor changes to enable VHV.

  1. The new Virtual Hardware 9 compatibility will be required when creating your nested ESXi VM, Virtual Hardware 8 will not work if you are running ESXi 5.1 on your physical host. You will still need to enable promiscuous mode on the portgroup that will be used for your nested ESXi VM for network connectivity.
  2. vhv.allow = “true” is no longer valid for ESXi 5.1 to enable VHV. A new parameter has been introduced called vhv.enable = “true” that is now defined on a per VM basis to provide finer granularity of VHV support. This also allows for better portability between VMware’s hosted products such as VMware Fusion and Workstation as they also support the vhv.enable parameter.
  3. You can now enable VHV on a per VM basis and using the new vSphere Web Client which basically adds the vhv.enable = “true” parameter to the VM’s .VMX configuration file.

 

vmware – powercli enable remote scripts

Neccesary commands to get vmware vsphere power cli scripts runnign in power cli;

(post installation of vsphere power cli extensions)

Set-ExecutionPolicy RemoteSigned
Set-PowerCLIConfiguration -InvalidCertificateAction “Ignore” -Confirm:$false

http://blogs.vmware.com/vipowershell/2011/06/back-to-basics-part-1-installing-powercli.html

HP Gen 8 servers and networking issues – TG3 driver

There is a bug in the tg3 driver on the ESXi hosts (1gbit broadcom cards in the new hosts). If the network card is put under load and netqueue is enabled it will sometimes decide to drop all traffic. Essentially i’ve disabled netqueue and the problems have gone away…. as per this vm kb :

http://kb.vmware.com/kb/2035701

The isues will present themselves as log entires like so;

2012-11-19T18:58:52.137Z cpu17:4155)<6>tg3 : vmnic8: RX NetQ allocated on 1
2012-11-19T18:58:52.138Z cpu17:4155)<6>tg3 : vmnic8: NetQ set RX Filter: 1 [00:50:56:71:46:87 0]
2012-11-19T18:58:52.138Z cpu17:4155)<6>tg3 : vmnic7: RX NetQ allocated on 1
2012-11-19T18:58:52.138Z cpu17:4155)<6>tg3 : vmnic7: NetQ set RX Filter: 1 [00:50:56:71:46:87 0]
2012-11-19T18:59:12.139Z cpu21:4155)<6>tg3 : vmnic4: NetQ remove RX filter: 1
2012-11-19T18:59:12.139Z cpu21:4155)<6>tg3 : vmnic4: Free NetQ RX Queue: 1
2012-11-19T18:59:22.137Z cpu24:4155)<6>tg3 : vmnic4: RX NetQ allocated on 1
2012-11-19T18:59:22.138Z cpu24:4155)<6>tg3 : vmnic4: NetQ set RX Filter: 1 [00:50:56:71:46:87 0]
2012-11-19T18:59:42.138Z cpu21:4155)<6>tg3 : vmnic7: NetQ remove RX filter: 1
2012-11-19T18:59:42.138Z cpu21:4155)<6>tg3 : vmnic7: Free NetQ RX Queue: 1
2012-11-19T18:59:42.140Z cpu21:4155)<6>tg3 : vmnic4: NetQ remove RX filter: 1
2012-11-19T18:59:42.140Z cpu21:4155)<6>tg3 : vmnic4: Free NetQ RX Queue: 1
2012-11-19T19:00:02.139Z cpu28:4155)<6>tg3 : vmnic8: NetQ remove RX filter: 1

vmware – copy networking port groups to another host

You might be able to do this via “host profiles” but if you do not have the licensing for it, this is the alternative. Very handy if you have over 50 or so port groups. It can be re-run to add to additional hosts as needed.

Install powercli, run the following to obtain your current list of virtual port groups off existing host;

Get-VirtualPortGroup -VirtualSwitch vSwitch0 -VMHost esx-01

Grab the output and place into CSV file or copy straght into Excel…

Following the formatting of the following “esx_switching-generic.csv” import the required data from aboves output. Note : the top line is the headers and should always be at the top of the CSV file.

Type,HostName,SwitchName,NIC,PortGroupName,VLAN,IP,Subnet,KernelGW
Portgroup,esx-02,vSwitch0,,Test_Network1,510,,,
Portgroup,esx-02,vSwitch0,,Test_Network2,511,,,

 

Place this file in a location that is called by this script —

#This script is designed to allow you to configure switches on multiple hosts by
#importing information from a prepopulated .csv file. vMotion switch created based
#on Mike Laverick's posting http://www.rtfm-ed.co.uk/?p=1514
#!!!!!!!Values passed for Type are Case sensitive since comparisons are being made.!!!!!!!

$getinfo = Import-Csv "D:\esx_switching-generic.csv" #need to input locatin of .CSV file

#Connect-VIServer -Server #Need to input appropriate vCenter Server

$getinfo | % {
$Type = $_.Type #!!!! Case Sensitive !!!!!!
$gethost = Get-VMHost -Name $_.HostName
$SwitchName = $_.SwitchName
$PortGroup = $_.PortGroupName
$Nic = $_.NIC
$VLAN = $_.VLAN
$IP = $_.IP
$Subnet = $_.Subnet
$kernelGW = $_.KernelGW

If ($Type -eq "Switch") {
$gethost | New-VirtualSwitch -Name $SwitchName -Nic $Nic
}

#Gets Switch object based on the value for SwitchName (required for several cmd-lets that do not accept Strings)
#'If' statement is used since a vMotion type does not already have a switch configured which will throw up an error.
If ($Type -ne "vMotion") {
$getswitch = Get-VirtualSwitch -VMHost $gethost -Name $SwitchName
}

#Add additional NIC to vSwitch to create a Team
If ($Type -eq "Team"){
$getswitch | Set-VirtualSwitch -Nic $Nic
}

#Add Portgroup to existing switch with VLAN
IF ($Type -eq "Portgroup") {
$getswitch | New-VirtualPortGroup $PortGroup -VLanId $VLAN
}

#Creates vMotion switch and configures vmkernel gateway (located under DNS and Routing in configuration tab)
IF ($Type -eq "vMotion") {

$newvswitch = New-VirtualSwitch -VMHost $gethost -Name $SwitchName -Nic $Nic
$vmotion = New-VirtualPortGroup -VirtualSwitch $newvswitch -Name $PortGroup
New-VMHostNetworkAdapter -VMHost $gethost -PortGroup $PortGroup -VirtualSwitch $newvswitch -IP $IP -SubnetMask $subnet -VMotionEnabled: $true

$vmhostnetwork = get-vmhostnetwork $gethost
set-vmhostnetwork -network $vmhostnetwork -vmkernelgateway $kernelGW
}
}

vmware – updating vcenter email alert for monitoring

I’ve used the following powershell script to assist with setting up a consistant email alert on various vmware envionrments.


# Usage ;
# Please manually connect to vCenter, use "Connect-VIServer" -- this promotes usernames and passwords not beings saved with script.
# Update below variable with email(s) use comma as delimita 
$MailtoAddresses= “[email protected]

#—-These Alarms will send a single email message and not repeat —-
$LowPriorityAlarms=”Timed out starting Secondary VM”,`
“No compatible host for Secondary VM”,`
“Virtual Machine Fault Tolerance vLockStep interval Status Changed”,`
“Migration error”,`
“Exit standby error”,`
“License error”,`
“Virtual machine Fault Tolerance state changed”,`
“VMKernel NIC not configured correctly”,`
“Unmanaged workload detected on SIOC-enabled datastore”,`
“Host IPMI System Event Log status”,`
“Host Baseboard Management Controller status”,`
“License user threshold monitoring”,`
“Datastore capability alarm”,`
“Storage DRS recommendation”,`
“Storage DRS not supported on host”,`
“Datastore is in multiple datacenters”,`
“Insufficient vSphere HA failover resources”,`
“License capacity monitoring”,`
“Pre-4.1 host connected to SIOC-enabled datastore”,`
“Virtual machine cpu usage”,`
“Virtual machine memory usage”,`
“License inventory monitoring”

#—-These Alarms will repeat every 24 hours—-
$MediumPriorityAlarms=`
“Virtual machine error”,`
“Health status changed alarm”,`
“Host cpu usage”,`
“Health status monitoring”,`
“Host memory usage”,`
“Cannot find vSphere HA master agent”,`
“vSphere HA host status”,`
“Host service console swap rates”,`
“vSphere HA virtual machine monitoring action”,`
“vSphere HA virtual machine monitoring error”

#—-These Alarms will repeat every 2 hours—-
$HighPriorityAlarms=`
“Host connection and power state”,`
“Host processor status”,`
“Host memory status”,`
“Host hardware fan status”,`
“Host hardware voltage”,`
“Host hardware temperature status”,`
“Host hardware power status”,`
“Host hardware system board status”,`
“Host battery status”,`
“Status of other host hardware objects”,`
“Host storage status”,`
“Host error”,`
“Host connection failure”,`
“Cannot connect to storage”,`
“Network connectivity lost”,`
“Network uplink redundancy lost”,`
“Network uplink redundancy degraded”,`
“Thin-provisioned LUN capacity exceeded”,`
“Datastore cluster is out of space”,`
“vSphere HA failover in progress”,`
“vSphere HA virtual machine failover failed”,`
“Datastore usage on disk”

#—Set Alarm Action for Low Priority Alarms—
Foreach ($LowPriorityAlarm in $LowPriorityAlarms) {
Get-AlarmDefinition -Name “$LowPriorityAlarm” | Get-AlarmAction -ActionType SendEmail| Remove-AlarmAction -Confirm:$false
Get-AlarmDefinition -Name “$LowPriorityAlarm” | New-AlarmAction -Email -To @($MailtoAddresses)
# Get-AlarmDefinition -Name “$LowPriorityAlarm” | Get-AlarmAction -ActionType SendEmail | New-AlarmActionTrigger -StartStatus “Green” -EndStatus “Yellow”
Get-AlarmDefinition -Name “$LowPriorityAlarm” | Get-AlarmAction -ActionType SendEmail | New-AlarmActionTrigger -StartStatus “Yellow” -EndStatus “Red” # This ActionTrigger is enabled by default.
# Get-AlarmDefinition -Name “$LowPriorityAlarm” | Get-AlarmAction -ActionType SendEmail | New-AlarmActionTrigger -StartStatus “Red” -EndStatus “Yellow”
# Get-AlarmDefinition -Name “$LowPriorityAlarm” | Get-AlarmAction -ActionType SendEmail | New-AlarmActionTrigger -StartStatus “Yellow” -EndStatus “Green”
}

#—Set Alarm Action for Medium Priority Alarms—
Foreach ($MediumPriorityAlarm in $MediumPriorityAlarms) {
Get-AlarmDefinition -Name “$MediumPriorityAlarm” | Get-AlarmAction -ActionType SendEmail| Remove-AlarmAction -Confirm:$false
Set-AlarmDefinition “$MediumPriorityAlarm” -ActionRepeatMinutes (60 * 24) # 24 Hours
Get-AlarmDefinition -Name “$MediumPriorityAlarm” | New-AlarmAction -Email -To @($MailtoAddresses)
# Get-AlarmDefinition -Name “$MediumPriorityAlarm” | Get-AlarmAction -ActionType SendEmail | New-AlarmActionTrigger -StartStatus “Green” -EndStatus “Yellow”
Get-AlarmDefinition -Name “$MediumPriorityAlarm” | Get-AlarmAction -ActionType SendEmail | Get-AlarmActionTrigger | Select -First 1 | Remove-AlarmActionTrigger -Confirm:$false
Get-AlarmDefinition -Name “$MediumPriorityAlarm” | Get-AlarmAction -ActionType SendEmail | New-AlarmActionTrigger -StartStatus “Yellow” -EndStatus “Red” -Repeat
# Get-AlarmDefinition -Name “$MediumPriorityAlarm” | Get-AlarmAction -ActionType SendEmail | New-AlarmActionTrigger -StartStatus “Red” -EndStatus “Yellow”
# Get-AlarmDefinition -Name “$MediumPriorityAlarm” | Get-AlarmAction -ActionType SendEmail | New-AlarmActionTrigger -StartStatus “Yellow” -EndStatus “Green”
}

#---Set Alarm Action for High Priority Alarms---
Foreach ($HighPriorityAlarm in $HighPriorityAlarms) {
Get-AlarmDefinition -Name "$HighPriorityAlarm" | Get-AlarmAction -ActionType SendEmail| Remove-AlarmAction -Confirm:$false
Set-AlarmDefinition "$HighPriorityAlarm" -ActionRepeatMinutes (60 * 2) # 2 hours
Get-AlarmDefinition -Name "$HighPriorityAlarm" | New-AlarmAction -Email -To @($MailtoAddresses)
# Get-AlarmDefinition -Name "$HighPriorityAlarm" | Get-AlarmAction -ActionType SendEmail | New-AlarmActionTrigger -StartStatus "Green" -EndStatus "Yellow"
Get-AlarmDefinition -Name "$HighPriorityAlarm" | Get-AlarmAction -ActionType SendEmail | Get-AlarmActionTrigger | Select -First 1 | Remove-AlarmActionTrigger -Confirm:$false
Get-AlarmDefinition -Name "$HighPriorityAlarm" | Get-AlarmAction -ActionType SendEmail | New-AlarmActionTrigger -StartStatus "Yellow" -EndStatus "Red" -Repeat
# Get-AlarmDefinition -Name "$HighPriorityAlarm" | Get-AlarmAction -ActionType SendEmail | New-AlarmActionTrigger -StartStatus "Red" -EndStatus "Yellow"
# Get-AlarmDefinition -Name "$HighPriorityAlarm" | Get-AlarmAction -ActionType SendEmail | New-AlarmActionTrigger -StartStatus "Yellow" -EndStatus "Green"
}
This is another version i created that just grabs all alarms and sets email trigger. Note that it will delete all the current triggers (so ensure you dont have SNMP traps etc that you need)


# v3 : grab all alarms from vcenter (so should work all versions) and use these for alarm variables
# Usage ;
# Please manually connect to vCenter, use "Connect-VIServer" -- this promotes usernames and passwords not beings saved with script.
# Any alarm that is currently active will send email alert -- please confirm appropriate values for tiggers before running this script.

#Set Notification emails here;
$MailTo= “[email protected]

#define alarms to be set;
$Alarms = Get-AlarmDefinition | sort Name | select name | ft -HideTableHeaders

foreach ($Alarm in $Alarms)
{
# Delete Trigger;
Get-AlarmDefinition -Name “$Alarm” | Get-AlarmAction | Remove-AlarmAction -Confirm:$false

# Create Trigger;
Get-AlarmDefinition -Name “$Alarm” | New-AlarmAction -Email -To “$MailTo”
}

UPDATE : I generally use the following script now. Less to maintain, and covers any alarms that have not been managed.

# Author : Darren Taylor
# v5 : grab all alarms from vcenter (so should work all versions) and use these for alarm variables
# Usage ;
# Please manually connect to vCenter, use “Connect-VIServer” — this promotes usernames and passwords not being saved with script.
# Any alarm that is currently active will send email alert — please confirm appropriate values for tiggers before running this script.
#
# Note ;
# This script needs to be modified to exclude alarms that are not critical (exclusive rather than inclusive)
# Once Exceptions list is updated, re-run script.

# ——————- VARIABLES ————————-

#Set Notification emails here;
$MailTo= “[email protected]

# These are the names of the alarms to ignore — i.e. do NOT setup email alert
# THESE ALARMS ARE CONSIDERED NON CRITICAL
$Exceptions= `
“Virtual machine cpu usage”,`
“Virtual machine memory usage”

# ——————- CODE ONLY BELOW ——————-

# TODO:
# Change triggers on some alarms?

#define alarms to be set; (ALL ALARMS)
$Alarms = Get-AlarmDefinition | sort name | select name

foreach ($Alarm in $Alarms)
{

# Test variable in array
Write-Host “Setting Alarm… ” -NoNewLine; Write-Host $Alarm.Name -NoNewLine;

# Delete Trigger; (clears all existing EMAIL triggers)
Get-AlarmDefinition -Name $Alarm.Name | Get-AlarmAction -ActionType:SendEmail | Remove-AlarmAction -Confirm:$false;

# Exceptions to email trigger
$SetAlarm = 1;
foreach ($Exception in $Exceptions) {if($Alarm.Name -eq $Exception){$SetAlarm=0; Write-Host ” Ignored” -foregroundcolor red;}}

# Create Trigger;
if($SetAlarm -eq “1”){Get-AlarmDefinition -Name $Alarm.Name | New-AlarmAction -Email -To $MailTo}

}