Hi all,
I need a little help writing a script to view storage events and extract the relevant data I’m after. More specifically I want to run a report that looks at anytime a esxi 5.5 server has lost access to a volume.
So far I have this.
Get-VIEvent
Then added a few filters.
Get-VIEvent | select EventTypeId, objectname, FullFormattedMessage | ft -wrap
performance has improved. I/O latency reduced from
22060 microseconds to 10269 microseconds.
performance has improved. I/O latency reduced from
112376 microseconds to 22060 microseconds.
performance has deteriorated. I/O latency increased
from average value of 5258 microseconds to 112376
microseconds.
What I noticed was some of the events are missing, specifically “Lost access to volume 00000000-00000000-0000-000000000000 (Local-Disk-0) due to connectivity issues. Recovery attempt is in progress and outcome will be reported shortly.” I can see them in the Web GUI but can’t locate them via powerCLI.
Can anyone point me to the right direction on where this object event could be queried by powerCLI?
Thanks
It could be that these are shown as EventEx objects.
When you do
$start = (Get-Date).AddDays(-1)
Get-VIEvent -Start $start -MaxSamples ([int]::MaxValue) |
where {$_.FullFormattedMessage -match "lost access"} |
Select FullFormattedMessage,@{N="Type";E={$_.GetType().Name}}
Do you get any results back ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
It could be that these are shown as EventEx objects.
When you do
$start = (Get-Date).AddDays(-1)
Get-VIEvent -Start $start -MaxSamples ([int]::MaxValue) |
where {$_.FullFormattedMessage -match "lost access"} |
Select FullFormattedMessage,@{N="Type";E={$_.GetType().Name}}
Do you get any results back ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you very much LucD, worked like a charm.
I hope this final code will save some future hair loss.:smileymischief:
It will find the event and link the Host,Datastore,Cluster,timecreated and message into something readable.
$start = (get-date).adddays(-1)
$events = Get-VIEvent -Start $start -MaxSamples ([int]::MaxValue) | where {$_.FullFormattedMessage -match "lost access"}
$objects = @()
foreach ($event in $events)
{
$esxhost = $event | select -ExpandProperty host
$datastore = $event | select -ExpandProperty ds
$cluster = $event | select -ExpandProperty computeresource
$object = new-object -TypeName psobject
$object | add-member -MemberType NoteProperty -Name 'esxhost' -Value $esxhost.name
$object | Add-Member -MemberType NoteProperty -Name 'datastore' -Value $datastore.name
$object | Add-Member -MemberType NoteProperty -Name 'cluster' -Value $cluster.name
$object | add-member -MemberType NoteProperty -Name 'createdtime' -Value $event.CreatedTime
$object | Add-Member -MemberType NoteProperty -Name 'message' -Value $event.FullFormattedMessage
$objects += $object
}
$objects
Hi,
I ran the script but the output is blank.
PowerCLI C:\temp> .\vSphere_Events.ps1
esxhost :
datastore :
cluster :
createdtime :
message :
Thanks
vmk2014
That could mean that there was no event with the "lost connection" message during the last day.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference