ESXTOP in Mac Terminal looks funky…

Summary:

Seems that terminal in Mac is configured in a fashion where esxtop does not display properly.  Thankfully, it’s pretty easy to fix.

Example:

This demonstrates what you would see when accessing esxtop in a default configured terminal session:

esxtopmacdefault

Solution:

Simply change your terminal emulator session from xterm-256color to ansi, by accessing terminal’s preferences, settings, Advanced, under ‘declare terminal as:’

xterm-to-ansi

Open up a new terminal session, run esxtop, and you should end up w/ what looks like this:

esxtopmacansi

VMWare View Powershell useful cmdlet notes.

Summary:
I’m just staring to put this together mainly for my own benefit, but if someone else finds this useful, then great.  I’ll be continually adding to this post.  If you’d like to contribute or if I got something wrong please feel free to leave a comment.
Notes:


Disable Provisioning in all linked clone pools:
$pools = get-pool
$pools | Update-AutomaticLinkedClonePool -isProvisioningEnabled:$false
Gets list of all View related cmdlets:

get-command | where {$_.modulename -match 'vmware.view'}
#Below is so you can include it into the 
#add-pssnapin.ps1 under your View installation directory
function get-viewcommand {get-command | where {$_.modulename -match 'vmware.view'}}
Gets list of pools, max number of VM's, and datastores associated:

#Helps in making sure your pools are distributed across evenly among datastores.
Get-Pool | Select Pool_ID, MaximumCount, DatastorePaths

SQLPSX, redirected my documents, and 64-bit Windows

Summary:
These 3 things don’t really want to work together.  Three issues I’ve noticed w/ SQLPSX, but ways around them to get these awesome cmdlets to work.
Based on SQLPSX 2.3.2.1
Workaround:
  1. Run the MSI installation.  It defaults to your my documents directory.  Instead redirect the installation directory to your powershell module installation directory.
    • Usually for 64-bit: C:\Windows\System32\WindowsPowershell\v1.0\Modules\
    • 32-bit: C:\Windows\SysWow64\WindowsPowershell\v1.0\Modules\
      • These feel backwards to me, but seems to be true.
  2. Once installed, you’ll need to copy the module folders into your my documents redirected location.  You can get them from either the 64-bit or 32-bit paths above.  The folders you need to copy are as follows:
    1. SQLMaint
    2. SQLServer
    3. Agent
    4. Repl
    5. SSIS
    6. Showmbrs
    7. SQLParser
    8. adolib
  3. Once you do so, you should be able to run ‘import-module sqlpsx’ successfully.  To find out what new cmdlets are available to you, simply run the following:
    • get-command | where {$_.module -match "SQLMaint|SQLServer|Agent|Repl|SSIS|ShowMbrs|SQLParser|adolib"}
    • You can also make this a function and include it in your PS profile like so:
    • Function Get-SQLcommands {get-command |where {$_.module -match "SQLMaint|SQLServer|Agent|Repl|SSIS|ShowMbrs|SQLParser|adolib"}}
If I’ve misrepresented anything or you have still have issues, feel free to leave me comments stating so.  I check each and every one.

VMWare View 4.x/5.x (missing) entries

Summary:
Stale entries in VMWare View show desktops in any of following status:
  • Provisioning Error (Missing)
  • Deleting (Missing)
Resolution:
If remove from the view admin console does not clear out the above entries within 30 min. – 1 hour, the steps in this KB from VMWare can assist in clearing out the those stale entries.
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1008658

Cisco ASA, ESX/vSphere, and Duplicate IP’s

Summary:

Windows (2003/2008/R2) and/or Linux VM’s added to a VLAN and continuously report duplicate IP’s and Windows assign themselves APIPA (Private Address).

Symptoms:

  1. (Windows) 169.254.x.x Address shows up as (Preferred) when running ipconfig /all in command prompt
  2. Resetting Adapter pops up Duplicate IP Error.
  3. Changing VM Network to a dummy network and vm nic reset, causes issue to go away.
  4. Changing VM Network back to problem network clears issue until vm is reset or nic is reset.

Resolution:

Assuming the Cisco ASA is the cause, you can follow the below steps to rectify the issue:

  1. Login to the Security Appliance ASDM
  2. Select Device Setup
  3. Expand Routing
  4. Select Proxy ARP
  5. Disable Proxy arp on the related interface (usually associated w/ your VLAN)
    • Other command line method:
      • sysopt noproxyarp <interface name>

If Windows is the issue for some reason, you can do this:

  1. Start –> Run… –> Regedit
  2. Find this key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
  3. Insert a new DWORD value
  4. Name the DWORD value “ArpRetryCount”
  5. Change the value for the new entry to 0 if not already set that way.
  6. Disable and Re-enable your network adapter to see if problem goes away.

Save PowerCLI Login Credentials to XML Securely (Mostly)

Summary:
PowerCLI has a cmdlet that allows you to save your logins to vCenter and ESX(i) hosts to a XML file so you can use those as reference in your PowerCLI scripts when calling the Connect-VIServer cmdlet.
How to use it:
#This stores your credentials into an xml file.  You can open the xml file, but the password is hashed.
New-VICredentialStoreItem -Host ESXorvCenterHostname -User root -Password "Super$ecretPassword" -File C:\Whateveryouwanttonameit.xml
 
#To use the data stored in the XML file, we will call the Get-VICredentialStoreItem and place the data into a variable for use.
$Creds = Get-VICredentialStoreItem -Host ESXorvCenterHostName -File C:\Whateveryouwanttonameit.xml

#Now you can use the $Cred variable for the username and password switches in the connect-viserver cmdlet
Connect-VIServer ESXorvCenterHostName -User $Creds.User -Password $Creds.Password


Caveats:
  1. XML files can only be referenced from the computer they were created on.
    • Powershell Remoting or Running PowerCLI on the computer the xml files were generated.
  2. Nothing is truly secure, so make sure those generated xml files are placed into a secure location.  You don’t want users who don’t know what they are doing to access them.
I think this is a useful function especially if you have several vCenter servers not in linked mode.

Disable Delayed Acknowledgement Setting in iSCSI Software Adapter using PowerCLI

Summary:

Somebody posed this question in the vmware communities forum.  I figured out how to do it cheating w/ Onyx.  Not sure why this is needed (since I don’t use iSCSI much), but figure it’s best I post this for reference if I or anyone needs to do this particular task.

Script:

#This section will get host information needed
$HostView = Get-VMHost NameofESXServer | Get-View
$HostStorageSystemID = $HostView.configmanager.StorageSystem
$HostiSCSISoftwareAdapterHBAID = ($HostView.config.storagedevice.HostBusAdapter | where {$_.Model -match "iSCSI Software"}).device
 
#This section sets the option you want.
$options = New-Object VMWare.Vim.HostInternetScsiHbaParamValue[] (1)
 
$options[0] = New-Object VMware.Vim.HostInternetScsiHbaParamValue
$options[0].key = "DelayedAck"
$options[0].value = $false
 
#This section applies the options above to the host you got the information from.
$HostStorageSystem = Get-View -ID $HostStorageSystemID
$HostStorageSystem.UpdateInternetScsiAdvancedOptions($HostiSCSISoftwareAdapterHBAID, $null, $options)

You can have this script run against multiple ESX servers, but you will need to use the Foreach-Object cmdlet.

Hardware.SystemInfo.OtherIdentifyingInfo Blank in PowerCLI

Summary:
Using my PowerCLI script to get Dell warranty information, I noticed that some of my ESX hosts were not returning service/asset tag information.  The information was showing up in vCenter's hardware status tab, but not w/ my PowerCLI script.
Workaround:
  1. First, check to see if your ESX host has this information populated:
    • Connect-viServer ESXHostName
      $VMHost = Get-VMHost | Get-View
      $VMHost.Hardware.SystemInfo.OtherIdentifyingInfo

  2. If the above code returns objects, then the next step is to disconnect the host from vCenter, then reconnect it.  You can use the following PowerCLI code to find all hosts w/ empty properties to do this for you.  As always, test before you try it in a production environment.

    • $ESXHosts = @()
       
      $VMHosts = Get-VMHost | Get-View
      Foreach ($VMHost in $VMHosts)
      {
      $NewObj             = "" | Select Name, ServiceTag, AssetTag
      $NewObj.Name        = $VMHost.Name
      #Replace is used to clean up data that might be there for easier filtering
      $NewObj.ServiceTag    = ($VMHost.hardware.systeminfo.OtherIdentifyingInfo | where {$_.IdentifierType.Key -eq "servicetag"}).identifierValue -replace(" ","")
      $NewObj.AssetTag    = ($VMHost.hardware.systeminfo.OtherIdentifyingInfo | where {$_.IdentifierType.Key -eq "assettag"}).identifierValue -replace(" ","")
      $ESXHosts += $NewObj
      }
       
      $VMHostsFiltered = $ESXHosts | Where-Object {($_.ServiceTag -eq "" -or $_.AssetTag -eq "") -and ($_.ServiceTag -ne "unknown") -and ($_.AssetTag -ne "unknown")}
       
      Foreach ($EvilESXBox in $VMHostsFiltered)
      {
      Set-VMHost -VMHost $EvilESXBox.Name -State Disconnected
      Set-VMHost -VMHost $EvilESXBox.Name -State Connected
      }

  3. Now running the code in my Dell Warranty Script should have all information populated as long as the ESX host has the information.
FYI:  
If the assettag and servicetag fields are blank or unknown, it's likely that your server needs to be flashed by a Dell Technician to insert the service tag info.  It supposed to be pre-populated by the factory, but if you've had the motherboard replaced, then it needs to be flashed.

Get ESX Host Warranty Info for Dell Servers

[Update: This code has been updated since it appears the 'OtherIdentifyingInfo' property seems to have problem coming through to vCenter.  Click here to see updated code]

Summary:
Needed to get my ESX host warranty info since we haven’t completely deployed our Dell vCenter Plugin.  Here is the code, w/ the Dell Warranty grab code from Marcus Oh.  It’ll get you some additional info too.  You can always edit and remove what you don’t need.
Code:
$ESXServers = Get-VMHost
$ESXServerView = $ESXServers | Get-View
$ESXInfo = @()
 
$oWeb = New-Object System.Net.WebClient
 
Foreach ($ESX in $ESXServers){
$TargetESXServerView = $ESXServerView | where {$_.MoRef -eq $ESX.Id}
$NewObj         = "" | Select Cluster, Name, Model, Version, BIOs, ServiceTag, AssetTag, ShipDate, ExpiryDate
$NewObj.Cluster = $ESX.Parent.Name
$NewObj.Name    = $ESX.Name
$NewObj.Model    = $ESX.Model
$NewObj.Version    = $ESX.Version
$NewObj.BIOs    = (($TargetESXServerView.Runtime.HealthSystemRuntime.SystemHealthInfo.NumericSensorInfo | where {$_.Name -like "*BIOS*"  -and $_.SensorType -eq "Software Components"}).Name) -replace(".* BIOS ","") -replace(" .*","")
$NewObj.ServiceTag     = ($TargetESXServerView.hardware.systeminfo.OtherIdentifyingInfo | where {$_.IdentifierType.Key -eq "servicetag"}).identifierValue -replace(" ","")
$NewObj.AssetTag    = ($TargetESXServerView.hardware.systeminfo.OtherIdentifyingInfo | where {$_.IdentifierType.Key -eq "assettag"}).identifierValue -replace(" ","")
## Gets ServiceTag Info from Dell
#$oWeb = New-Object System.Net.WebClient
$ServiceTag = $null
If ($NewObj.ServiceTag -eq $null -or $NewObj.ServiceTag -eq "unknown" -or $NewObj.ServiceTag -eq "") {$ServiceTag = $NewObj.AssetTag} Else {$ServiceTag = $NewObj.ServiceTag}
$sUrl = "http://support.dell.com/support/topics/global.aspx/support/my_systems_info/details?c=us&l=en&s=gen&~ck=anavml&servicetag=$($ServiceTag)"
$sData = $oWeb.DownloadString($sUrl)
#get just the dates from the dell site.
$oRegEx = [regex]'\d{1,2}/\d{1,2}/\d{4}'
$cMatches = $oRegEx.Matches($sData)
#convert to a date object
$test = @()
foreach ($a in $cMatches){$Test += ([datetime]$a.Value)}
#Sort by the year
$datedata = $test | Sort-Object year
#Grab the earliest date for Shipdate
$ShipDate = ($Datedata[0]).toshortdatestring()
#Find the last object in the array
$cDates = ($Datedata.count) - 1
#Grab the latest date from the array for the warranty end date
$EndDate = ($Datedata[$cDates]).toshortdatestring()
## End Dell Site Code
$NewObj.ShipDate    = $ShipDate
$NewObj.ExpiryDate     = $EndDate
 
$ESXInfo += $NewObj
$ShipDate = $null
$EndDate = $null
}
$ESXInfo


If info is missing check this post.

ESX/ESXi Recommended BIOs Settings

Summary:

Came across a PSOD on one my lab manager hosts.  The error read:

LINT1 motherboard interrupt.  This is a hardware problem; please contact your hardware vendor

PSOD

Resolution:

According to Dell, this occurs because the C1E setting is enabled in the BIOs.  This post helped me from EnterpriseAdmins.org.

Finally, it’s mentioned in Page 15 of the vSphere 4.0 Best Practices Guide for recommended hardware BIOs settings.  Guess I need to work w/ Dell to do this for me before sending me an ESX Server.

NFS Datastore appears inactive in vCenter

Summary:

This was more of an annoyance for me, but essentially I had two NFS datastores that were mapped incorrectly to some ESX hosts.  Those datastores were unmounted and remounted w/ correct pathing using PowerCLI.  However, one host ‘seemed’ to hold onto the incorrectly mapped one.  This was only reflected in vCenter, not the host itself.

Experience:

  • vCenter 4.1
  • ESX 4.0 U2

Symptoms:

  • When attempting to unmount the following error appears:
    • The object has been deleted or has not been completely created
  • Connecting directly to the ESX host does not show these ‘inactive’ nfs datastores.
  • esxcfg-nas –l within TSM/SC on the ESX host does not show these ‘inactive’ datastores.

Resolution:

  1. Disconnect ESX host from vCenter
  2. Connect ESX host to vCenter.

This seems to help vCenter resolve the display issue.  For help on similar NFS issues, this search seemed helpful.

EMC Virtual Storage Integrator (VSI 4.1)

Summary:
Upgrading to VSI 4.1 is fairly painless if you followed my last post on 3.0.1.  You still have to do a couple things for it to work though.

PreReq:

  • VSI Installed on server system.
  • Reference last post for install instructions.  Overall same process.
  • Downloaded VSI Storage Viewer Plug-in 4.1 
  • Record IP's, username's, and passwords of your array connections.


Details:

  1. Upgrade the version on your server and upgrade the version on your system.
  2. Follow step 1 on my last post on the server.  (This is so your local system can connect to the server's solutions enabler service.)
  3. Once done, vCenter should show the new EMC VSI icon under 'Solutions and Applications'
Other Optional Components:
There are additional plug-ins that can be installed to allow self-service operations among other things:
  1. VSI Unified Storage Management
    • NaviSphere CLI required for block provisioning
    • UniSphere CLI required for VNXe provisioning
  2. VSI Storage Pool Management
  3. VSI Symmetrix SRA Utilities
    • This works in conjunction w/ VMWare SRM.
  4. VSI Path Management

ESXi 4.1 Kickstart Script for EDA Virtual Appliance

Summary:
This one has been on the back burner for a little while, but I finally got it put together thanks to resources like virtualghettolamw is crazy smartz!
Script:
Everything seems to work fine, the only one I’m not sure of is the enabling the CIMoemProviderEnabled Advanced setting as to whether that works or not.  Let me know if you happen to brave my custom kickstart script made for Dell servers, but can be adjusted for pretty much any setup I think.
   1: # Bind vmnic4 to vSwitch0.  EDA adds vmnic0 automatically
   2: # Active/Passive
   3: esxcfg-vswitch -L vmnic4 vSwitch0
   4: esxcfg-vswitch -X 1 vSwitch0
   5:  
   6: # Add vSwitch1, VMkernel, and bind vmnic1/3
   7: # Active/Passive
   8: # The following configures vSwitch1 as the vmKernel vmotion switch
   9: esxcfg-vswitch -a vSwitch1
  10: esxcfg-vswitch -A VMkernel vSwitch1
  11: esxcfg-vswitch -L vmnic1 vSwitch1
  12: esxcfg-vswitch -L vmnic3 vSwitch1
  13: esxcfg-vswitch -X 1 vSwitch1
  14:  
  15: # Add vSwitch2 and bind vmnic2/5
  16: # Active/Passive
  17: # Created VM Switch
  18: esxcfg-vswitch -a vSwitch2
  19: esxcfg-vswitch -L vmnic2 vSwitch2
  20: esxcfg-vswitch -L vmnic5 vSwitch2
  21: esxcfg-vswitch -X 1 vSwitch2
  22:  
  23: # NTP Configuration
  24: /bin/echo "restrict 127.0.0.1" &gt; /etc/ntp.conf
  25: /bin/echo "restrict default kod nomodify notrap" &gt;&gt; /etc/ntp.conf
  26: /bin/echo "server timeserver1.local" &gt;&gt; /etc/ntp.conf
  27: /bin/echo "server timeserver2.local" &gt;&gt; /etc/ntp.conf
  28: /etc/init.d/ntpd restart
  29:  
  30: # Configures vmk0 as Mgmt Interface
  31: HOSTSVC_FILE=/etc/vmware/hostd/hostsvc.xml
  32:  
  33: /bin/cat &gt; ${HOSTSVC_FILE} &lt;&lt; __CREATE_HOST_SVC__
  34: &lt;ConfigRoot&gt;
  35:   &lt;mangementVnics&gt;
  36:     &lt;nic id="0000"&gt;vmk0&lt;/nic&gt;
  37:   &lt;/mangementVnics&gt;
  38:   &lt;mode&gt;normal&lt;/mode&gt;
  39:   &lt;service&gt;
  40:     &lt;tsm-ssh&gt;off&lt;/tsm-ssh&gt;
  41:   &lt;/service&gt;
  42: &lt;/ConfigRoot&gt;
  43: __CREATE_HOST_SVC__
  44:  
  45: # Configure vmk1 as vMotion Interface
  46: esxcfg-vmknic -a VMkernel -i ###HOSTIP### -n 255.255.255.0
  47: /bin/vim-cmd hostsvc/net/refresh
  48: /bin/vim-cmd hostsvc/vmotion/vnic_set vmk1
  49:  
  50: # DNS Secondary (replace x.x.x.x w/ IP of another DNS server) 
  51: /bin/echo "nameserver x.x.x.x" &gt;&gt; /etc/resolv.conf
  52:  
  53: # Configure Local Datastore Name to standard
  54: /bin/vim-cmd hostsvc/datastore/rename datastore1 "$(hostname -s)_local"
  55:  
  56: # Configure Syslog to forward to remote syslog server like Splunk
  57: /bin/vim-cmd hostsvc/advopt/update Syslog.Remote.Hostname string x.x.x.x
  58:  
  59: # Configure port to forward Syslogs.
  60: /bin/vim-cmd hostsvc/advopt/update Syslog.Remote.Port int 514
  61:  
  62: # Only needed if local syslog going to be used.
  63: #/bin/vim-cmd hostsvc/advopt/update Syslog.Local.DatastorePath string "[$(hostname -s)_local] /logfiles/hostName.log"
  64:  
  65: # Maps standard NFS Shares (I use these as shared stores for iso and vmtemplates)
  66: esxcfg-nas -a -o linuxserver1 -s /share/STUFF nfs_share
  67: esxcfg-nas -a -o nasdevice1 -s esx_vmtemplates nfs_share_vmtemplates
  68:  
  69: #### Start of Join AD code ####
  70: #Joins to Active Directory (ESX 4.1) Update 1 Code Hashed Out
  71: /bin/cat &gt; /tmp/joinActiveDirectory.py &lt;&lt; __JOIN_AD__
  72: import sys,re,os,urllib,urllib2,base64
  73:  
  74: # mob url
  75: url = "https://localhost/mob/?moid=ha-ad-auth&amp;method=joinDomain"
  76:  
  77: # mob login credentials -- use password = "" for build scripting
  78: username = "root"
  79: password = ""
  80:  
  81: # which domain to join, and associated OU
  82: # e.g.
  83: #       "local.com"
  84: #       "local.com/VMware Server OU"
  85: domainname = "local.com/someOU/"
  86:  
  87: # active directory credentials using encoded base64 password
  88: ad_username = "someserviceaccount@local.com"
  89: ### To get an encoded password, use python.  It's not really secure, but better than plain text.
  90: encodedpassword = ""
  91: ad_password = base64.b64decode(encodedpassword)
  92:  
  93: # Unhash for ESXi 4.1 Update 1
  94: ### Create global variables
  95: # global passman,authhandler,opener,req,page,page_content,nonce,headers,cookie,params,e_params
  96:  
  97: # Code to build opener with HTTP Basic Authentication
  98: passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
  99: passman.add_password(None,url,username,password)
 100: authhandler = urllib2.HTTPBasicAuthHandler(passman)
 101: opener = urllib2.build_opener(authhandler)
 102: urllib2.install_opener(opener)
 103:  
 104: # Unhash below for 4.1 Update 1
 105: ### Code to capture required page data and cookie required for post back to meet CSRF requirements  ###
 106: #req = urllib2.Request(url)
 107: #page = urllib2.urlopen(req)
 108: #page_content= page.read()
 109:  
 110: # Unhash below for 4.1 Update 1
 111: ### regex to get the vmware-session-nonce value from the hidden form entry
 112: # reg = re.compile('name="vmware-session-nonce" type="hidden" value="?([^\s^"]+)"')
 113: #nonce = reg.search(page_content).group(1)
 114:  
 115: # Unhash below for 4.1 Update 1
 116: ### Code to join the domain ESXi 4.1U1
 117: #params = {'vmware-session-nonce':nonce,'domainName':domainname,'userName':ad_username,'password':ad_password}
 118: #e_params = urllib.urlencode(params)
 119: #req = urllib2.Request(url, e_params, headers={"Cookie":cookie})
 120: #page = urllib2.urlopen(req).read()
 121:  
 122: #Hash if using 4.1 U1
 123: ### Code to join domain ESX 4.1
 124: params = {'domainName':domainname,'userName':ad_username,'password':ad_password}
 125: e_params = urllib.urlencode(params)
 126: req = urllib2.Request(url,e_params)
 127: page = urllib2.urlopen(req).read()
 128:  
 129: __JOIN_AD__
 130:  
 131: #execute python script to Join AD
 132: /bin/python /tmp/joinActiveDirectory.py
 133:  
 134: #### End AD Join Code ####
 135: # Changes UserVars.CIMoemProviderEnabled to 1.  Required for OMSA VIB to work properly.
 136: esxcfg-advcfg -s 1 /UserVars/CIMoemProviderEnabled 
 137: %firstboot --unsupported --interpreter=busybox --level=9999
 138: # Do Patching in this section
 139:  
 140: #Gets Emulex and OMSA VIB from IIS Server w/ virtual directory pointed to NAS hosted directory
 141: #Applies Emulex then OMSA VIB &lt;-- Must be in this order.
 142: # Maintenance Mode attempted twice before attempting patch because it sometimes fails.
 143: /bin/vim-cmd hostsvc/maintenance_mode_enter
 144: sleep 5
 145: /bin/vim-cmd hostsvc/maintenance_mode_enter
 146:  
 147: # Entries entered twice due to metadata.zip possibly not extracting properly the first time.
 148: /sbin/esxupdate --bundle=http://IISSERVER.local.com/VIBS/Emulex_CIM/elx-esx-4.1.0-emulex-cim-provider-3.2.30.1-offline_bundle-364582.zip update
 149:  
 150: /sbin/esxupdate --bundle=http://IISSERVER.local.com/VIBS/Emulex_CIM/elx-esx-4.1.0-emulex-cim-provider-3.2.30.1-offline_bundle-364582.zip update
 151:  
 152: /sbin/esxupdate --bundle=http://IISSERVER.local.com/VIBS/Dell_OMSA/OM-SrvAdmin-Dell-Web-6.5.0-2247.VIB-ESX41i_A01.zip update
 153:  
 154: /sbin/esxupdate --bundle=http://IISSERVER.local.com/VIBS/Dell_OMSA/OM-SrvAdmin-Dell-Web-6.5.0-2247.VIB-ESX41i_A01.zip update
 155:  
 157:  
 158: /bin/vim-cmd hostsvc/maintenance_mode_exit
 159:  
 160: /sbin/reboot -d 120