<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>failover Archives - LucD notes</title>
	<atom:link href="https://www.lucd.info/tag/failover/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.lucd.info/tag/failover/</link>
	<description>My PowerShell ramblings</description>
	<lastBuildDate>Sat, 06 Apr 2013 08:17:12 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9</generator>

<image>
	<url>https://www.lucd.info/wp-content/uploads/2018/12/cropped-120px-Tibetan_Dharmacakra-32x32.png</url>
	<title>failover Archives - LucD notes</title>
	<link>https://www.lucd.info/tag/failover/</link>
	<width>32</width>
	<height>32</height>
</image> 
<atom:link rel="hub" href="https://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="https://pubsubhubbub.superfeedr.com"/><atom:link rel="hub" href="https://websubhub.com/hub"/>	<item>
		<title>HA VM failover tracking</title>
		<link>https://www.lucd.info/2013/04/06/ha-vm-failover-tracking/</link>
					<comments>https://www.lucd.info/2013/04/06/ha-vm-failover-tracking/#comments</comments>
		
		<dc:creator><![CDATA[LucD]]></dc:creator>
		<pubDate>Sat, 06 Apr 2013 00:56:53 +0000</pubDate>
				<category><![CDATA[event]]></category>
		<category><![CDATA[HA]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Virtual Machine]]></category>
		<category><![CDATA[failover]]></category>
		<category><![CDATA[VM]]></category>
		<guid isPermaLink="false">http://www.lucd.info/?p=4435</guid>

					<description><![CDATA[Another interesting question in the PowerCLI Community today. David wanted to know if [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Another interesting question in the <a href="https://communities.vmware.com/community/vmtn/server/vsphere/automationtools/powercli?view=discussions" target="_blank">PowerCLI Community</a> today.<br />
<a href="https://communities.vmware.com/people/drivera01" target="_blank">David</a> wanted to know if it was possible to <a href="https://communities.vmware.com/thread/442036?tstart=0" target="_blank">track</a> which VMs had been <strong>failed over</strong> to another ESXi host by HA.<br />
With the <strong>Get-VIEventPlus</strong> function from my <a href="https://www.lucd.info/2013/03/31/get-the-vmotionsvmotion-history/" target="_blank">Get the vMotion/svMotion history</a> post it is easy to get that informatiom from the <strong>Tasks and Events</strong> that are kept in the vCenter database.</p>
<p style="padding-left: 60px;"><a href="https://www.lucd.info/2013/04/06/ha-vm-failover-tracking/ha-failover/" rel="attachment wp-att-4437"><img fetchpriority="high" decoding="async" class="alignnone  wp-image-4437" alt="HA-failover" src="https://lucd.info/wp-content/uploads/2013/04/HA-failover.png" width="409" height="246" srcset="https://www.lucd.info/wp-content/uploads/2013/04/HA-failover.png 511w, https://www.lucd.info/wp-content/uploads/2013/04/HA-failover-300x180.png 300w" sizes="(max-width: 409px) 100vw, 409px" /></a></p>
<p>But which event to look for ?</p>
<p><span id="more-4435"></span></p>
<h2>The Making Of</h2>
<p>In the <a href="https://communities.vmware.com/community/vmtn/server/vsphere/automationtools/powercli?view=discussions" target="_blank">PowerCLI Community</a> there are often questions on how track a specific type of event. The best source of information to start with is of course the <a href="https://pubs.vmware.com/vsphere-51/topic/com.vmware.wssdk.apiref.doc/right-pane.html" target="_blank">VMware vSphere API Reference Documentation</a>. Under the <strong>Data Object Types</strong> you&#8217;ll find most of the events that can occur in a vSphere environment.</p>
<p>But there are ways to make the search easier. In my <a href="https://www.lucd.info/2010/06/15/events-part-7-working-with-extended-events-update-manager/" target="_blank">Events – Part 7 : Working with extended events – Update Manager</a> post I already provided a short script to produce a cross-reference of the available events in your vSphere environment.</p>
<p>This is an improved version of that script.</p>
<p></p><pre class="urvanov-syntax-highlighter-plain-tag">$report = @()
$eventMgr = Get-View EventManager
$events = foreach($event in $eventMgr.Description.EventInfo){
  New-Object PSOBject -Property @{
    Key = $event.Key
    Category = $event.Category
    EventTypeId = &amp;{
      If('ExtendedEvent','EventEx' -contains $event.Key){
        $event.FullFormat.Split('|')[0]
      }
      else{ $null}}
    Description = $event.Description
  }
}
$events | Export-Csv C:\events.csv -NoTypeInformation -UseCulture</pre><p></p>
<p>The resulting table looks something like this.</p>
<p><a href="https://www.lucd.info/2013/04/06/ha-vm-failover-tracking/event-xref/" rel="attachment wp-att-4438"><img decoding="async" class="alignnone  wp-image-4438" alt="event-xref" src="https://lucd.info/wp-content/uploads/2013/04/event-xref.png" width="650" height="216" srcset="https://www.lucd.info/wp-content/uploads/2013/04/event-xref.png 1015w, https://www.lucd.info/wp-content/uploads/2013/04/event-xref-300x99.png 300w" sizes="(max-width: 650px) 100vw, 650px" /></a></p>
<p>Important to remember here, there are 3 major categories of events: a regular <a href="https://pubs.vmware.com/vsphere-51/topic/com.vmware.wssdk.apiref.doc/vim.event.Event.html" target="_blank">Event</a>, an <a href="https://pubs.vmware.com/vsphere-51/topic/com.vmware.wssdk.apiref.doc/vim.event.EventEx.html" target="_blank">EventEx</a> and an <a href="https://pubs.vmware.com/vsphere-51/topic/com.vmware.wssdk.apiref.doc/vim.event.ExtendedEvent.html" target="_blank">ExtendedEvent</a>. The hierarchy of these different object types looks like this.</p>
<p style="padding-left: 30px;"><a href="https://www.lucd.info/2013/04/06/ha-vm-failover-tracking/event-inheritance/" rel="attachment wp-att-4439"><img decoding="async" class="alignnone  wp-image-4439" alt="event-inheritance" src="https://lucd.info/wp-content/uploads/2013/04/event-inheritance.png" width="376" height="332" srcset="https://www.lucd.info/wp-content/uploads/2013/04/event-inheritance.png 626w, https://www.lucd.info/wp-content/uploads/2013/04/event-inheritance-300x265.png 300w" sizes="(max-width: 376px) 100vw, 376px" /></a></p>
<p>Now that we have our events XRef, it&#8217;s a matter of doing a bit of searching. The Excel filtering options do wonders here. In this case it was obvious that the HA component produces a number of events that all seem to start with <strong>com.vmware.vc.HA</strong>. The one we were after had <strong>VmRestartedByHAEvent</strong> in the identifier. And the Description confirms that this was the event we were looking for.</p>
<p><a href="https://www.lucd.info/2013/04/06/ha-vm-failover-tracking/ha-vm-restart/" rel="attachment wp-att-4440"><img loading="lazy" decoding="async" class="alignnone  wp-image-4440" alt="HA-VM-Restart" src="https://lucd.info/wp-content/uploads/2013/04/HA-VM-Restart.png" width="606" height="251" srcset="https://www.lucd.info/wp-content/uploads/2013/04/HA-VM-Restart.png 1010w, https://www.lucd.info/wp-content/uploads/2013/04/HA-VM-Restart-300x124.png 300w" sizes="auto, (max-width: 606px) 100vw, 606px" /></a></p>
<p>We pass this <strong>EventTypeId</strong> with the <strong>EventType</strong> parameter to the <strong>Get-VIEventPlus</strong> function. This is explained in the description of the <strong>eventTypeId</strong> property on the <a href="https://pubs.vmware.com/vsphere-51/topic/com.vmware.wssdk.apiref.doc/vim.event.EventFilterSpec.html" target="_blank">EventFilterSpec</a> object.</p>
<p>The script to get the specific events and produce a report is quite simple.</p>
<p></p><pre class="urvanov-syntax-highlighter-plain-tag">$entity = Get-Folder Datacenters
$start = (Get-Date).AddMonths(-3)
$Recurse = $false
$eventTypes = &quot;com.vmware.vc.ha.VmRestartedByHAEvent&quot;

Get-VIEventPlus -Entity $entity -Start $start -EventType $eventTypes |
Select CreatedTime,@{N=&quot;VM&quot;;E={$_.Vm.Name}},@{N=&quot;ESX&quot;;E={$_.Host.Name}}</pre><p></p>
<p>The result looks something like this.</p>
<p><a href="https://www.lucd.info/2013/04/06/ha-vm-failover-tracking/ha-vm-restart-output/" rel="attachment wp-att-4441"><img loading="lazy" decoding="async" class="alignnone  wp-image-4441" alt="HA-VM-restart-output" src="https://lucd.info/wp-content/uploads/2013/04/HA-VM-restart-output.png" width="474" height="85" srcset="https://www.lucd.info/wp-content/uploads/2013/04/HA-VM-restart-output.png 592w, https://www.lucd.info/wp-content/uploads/2013/04/HA-VM-restart-output-300x53.png 300w" sizes="auto, (max-width: 474px) 100vw, 474px" /></a></p>
<p>Enjoy !</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.lucd.info/2013/04/06/ha-vm-failover-tracking/feed/</wfw:commentRss>
			<slash:comments>5</slash:comments>
		
		
			</item>
	</channel>
</rss>
