Hello,
i found command get-vievent, output is like this
template : False
key : 8240
chainId : 8240
createdTime : 3/23/2009 2:38:03 PM
userName :
datacenter : VimApi.DatacenterEventArgument
computeResource : VimApi.ComputeResourceEventArgument
host : VimApi.HostEventArgument
vm : VimApi.VmEventArgument
fullFormattedMessage : Virtual Machine viedfs1-clone is connected
dynamicType :
dynamicProperty :
It`s possible to get there real host name instead of value VimApi.HostEventArgument ?
What i try to do is to get list of errors and warnings with time stamp , source name (host or guest) and full formated message. Perfect example is event export from VC GUI
error 1/30/2009 12:43:20 PM Unable to contact a primary HA agent in cluster Cluster1 in Test-Enviroment
error 1/30/2009 12:43:20 PM Host abcd.fqdn.com in Test-Enviroment is not responding
it`s possible to reproduce logfile like that by VI toolkit ?
Thnx a lot
The following should do what you want.
Note that I export the text to a CSV file, that makes it easier to see the different fields
$report = @() get-vievent -Types Error,Warning -Start (Get-Date).addminutes(-15) | %{ $row = "" | Select Time, Text, Host $row.Time = $_.CreatedTime.ToString() $row.Text = $_.fullFormattedMessage if($_.host -ne $null){ $row.Host = $_.host.name } else{ $row.Host = "" } $report += $row } $report | Export-Csv "C:\report.csv" -noTypeInformation
Message was edited by: LucD
Just noticed I put 1500 instead of 15 as argument to the addminutes method.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes, you can use the Get-ViEvent cmdlet to create a kind of log with host-related messages.
In the -Entity parameter you pass the host you're interested in.
With the -Start and -Finish parameters you can define the start and stop time of the interval you want to look at.
With the -Maxsamples parameter you need to specify how many events you want to see (the default is 100)
Some examples:
# The 100 last events of type "error" for host <ESX-hostname> Get-VIEvent -Entity (Get-VMHost <ESX-hostname>) -Types Error | select CreatedTime, fullFormattedMessage # The events of the last 2 days of type "error" for host <ESX-hostanem> Get-VIEvent -Entity (Get-VMHost <ESX-hostname>) -Types Error -Start (get-Date).adddays(-2) | select CreatedTime, fullFormattedMessage
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
It`s possible to include there whole enviroment ? I mean to have this "view" for all ESX hosts?
Anyway thanks a lot for great hint.
Sure you can, leave out the -Entity parameter.
Get-VIEvent -Types Error -Start (get-Date).adddays(-2) | select CreatedTime, fullFormattedMessage
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Lucd,
my goal is to have script which will export every 15 mins all errors and warnings from whole enviroment to txt logfile.
example (time , message, host name where it appeard)
3/19/2009 6:01:50 PM Failed to login user qazwsxedc@127.0.0.1: No permission viehpesx02.extmonitor.hosting.emea.com
could you please help here
Thnx
The following should do what you want.
Note that I export the text to a CSV file, that makes it easier to see the different fields
$report = @() get-vievent -Types Error,Warning -Start (Get-Date).addminutes(-15) | %{ $row = "" | Select Time, Text, Host $row.Time = $_.CreatedTime.ToString() $row.Text = $_.fullFormattedMessage if($_.host -ne $null){ $row.Host = $_.host.name } else{ $row.Host = "" } $report += $row } $report | Export-Csv "C:\report.csv" -noTypeInformation
Message was edited by: LucD
Just noticed I put 1500 instead of 15 as argument to the addminutes method.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
#1
thanks a lot.
You really rocks LucD !
i'm gonna add your host.name trick into the Al's Dailly Report