We've been searching for a way to generate a monthly availabillity report for our soon-to-be ESXi 4.1 hosts. The commonplace third-party utililties don't appear to have this functionality built-in, so we're looking into using PowerCLI to gather this information.
Has anyone seen/heard of a script to accomplish such a task? Basically, we would like to be able to generate a report that gives a percentage (eg: 98.x%) of time that each host was available for use by the environment. Any downtime would include system downtime, maintenance mode timeframes, periods of host network isolation, etc.
Any insight, ideas, or suggestions would be greatly appreciated. Thanks for any help you can offer!
I think the best way to do this is via the events.
With the following you can retrieve the events for a specific host over the last 31 days.
From these events you filter out the ones you're interested in (HostConnectedEvent,HostConnectionLostEvent...).
Have a look at my Events, Dear Boy, Events – Part 2 post to find out what events are available.
But watch out, some events are hidden in TaskEvent entries (the switches to/from maintenance mode for example).
$esx = Get-VMHost <esxi-hostname> $start = (Get-Date).AddDays(-31) $events = Get-VIEvent -Entity $esx -Start $start
Once you have the events you're interested in, it will be a matter of sorting them on the timestamp and then producing a kind of timeline.
This looks like a fun weekend project
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I think the best way to do this is via the events.
With the following you can retrieve the events for a specific host over the last 31 days.
From these events you filter out the ones you're interested in (HostConnectedEvent,HostConnectionLostEvent...).
Have a look at my Events, Dear Boy, Events – Part 2 post to find out what events are available.
But watch out, some events are hidden in TaskEvent entries (the switches to/from maintenance mode for example).
$esx = Get-VMHost <esxi-hostname> $start = (Get-Date).AddDays(-31) $events = Get-VIEvent -Entity $esx -Start $start
Once you have the events you're interested in, it will be a matter of sorting them on the timestamp and then producing a kind of timeline.
This looks like a fun weekend project
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks for your help Luc! Once we get something functional/useful, I'll post it up here in case anyone else is interested.
After finally having some time to work on this I was able to write a small utility to provide us with basic monthly availability statistics for our environment. In order to use the following tool you must run it on a system with .NET 2.0 and PowerCLI 4.1 installed.
The tool generates a detailed report for multiple vCenter instances and sends a summary/copy of the report in an email to a given address. The tool requires that the 'Host connection and power state' alarm was enabled during the given month and looks for the following information:
This is all that the utility looks for. The source code has been provided in case anyone would like to expand it or see how it works for their own projects. The readme included in the .zip explains how to configure it and describes how the syntax works as well.
Good luck!
Mike
Edit: The tool can be downloaded here: http://communities.vmware.com/docs/DOC-14433
Great stuff.
I would suggest that you make a Document of this script.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks Luc, I threw together a document for the utility and removed the outdated files from the discussion.
good stuff
Have been looking for a tool like this for a long while and was very pleased to find this....
However, I can't get it to work!
Tried various boxes but to no avail. Keep getting this error -
Unhandled Exception: System.TypeInitializationException: The type initializer fo
r 'ESXAR.ESXAR' threw an exception. ---> System.IO.FileNotFoundException: Could
not load file or assembly 'VMware.Vim, Version=4.1.0.0, Culture=neutral, PublicK
eyToken=10980b081e887e9f' or one of its dependencies. The system cannot find the
file specified.
File name: 'VMware.Vim, Version=4.1.0.0, Culture=neutral, PublicKeyToken=10980b0
81e887e9f'
at ESXAR.ESXAR..cctor()
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\M
icrosoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure lo
gging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fus
ion!EnableLog].
--- End of inner exception stack trace ---
at ESXAR.ESXAR.Main(String[] args)
Any help gratefully received!
I assume that on machine where this .executable is running you already have .NET 2.0 and VMware Powercli 4.1 installed. The executable relies on few .dll files that are part of Powercli 4.1 installation. These .dlls (a.k.a vSphere .NET SDK wrapper) contain all methods you need.
You can download Powercli 4.1 from VMware download sites.
good luck
Hmmm, I already have installed Microsoft .NET Framework v2.0 and VMware vSphere PowerCLI v4.1 (4.1.1.2816) on Windows Server 2003 SP1 and still get the following error -
Unhandled Exception: System.TypeInitializationException: The type initializer fo
r 'ESXAR.ESXAR' threw an exception. ---> System.IO.FileNotFoundException: Could
not load file or assembly 'VMware.Vim, Version=4.1.0.0, Culture=neutral, PublicK
eyToken=10980b081e887e9f' or one of its dependencies. The system cannot find the
file specified.
File name: 'VMware.Vim, Version=4.1.0.0, Culture=neutral, PublicKeyToken=10980b0
81e887e9f'
at ESXAR.ESXAR..cctor()
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\M
icrosoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure lo
gging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fus
ion!EnableLog].
--- End of inner exception stack trace ---
at ESXAR.ESXAR.Main(String[] args)
Very frustrating indeed.
If anyone has this working properly please let me know your setup......
Did you install PowerShell ?
Preferably PowerShell v2.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
As far as i know you can't install powercli if there isn't powershell installed. So i assume that's not an issue.
I think that the vmware.wim.dll (normally installed in global assembly cache; start -- >run --> C:\windows\assembly\gac\Vmware.vim) is newer than the version was used to compile the esxrar.exe.
So i would suggest
a.) compare the version of assembly found under folder 'C:\windows\assembly\gac\Vmware.vim' against the expected version in this error message. If that's case then..
1.) dowgrade your powercli to previous version (4.1.0 as shown in error message) and it will work.
or
2.) if you have visual studio 2008/2010. load the solution (.sln file) , make reference to you're currently installed vmware.vim.dll and build your solution with newly referenced .dll file.
good luck
LucD,
I have, and I've been very careful to do it on a clean server. PowerShell 2.0, .Net and PowerCLI 4.1 all installed.
It's very weird and I'm losing the will to live with this!
Jon
Ok, let's try this step by step.
Open the PowerCLI prompt.
Execute
Get-ExecutionPolicy
Depending on what this displays , you will have to do
Set-ExecutionPolicy RemoteSigned
Then let's check the snapins. Do a
Get-PSSnapin
Check the output and verify if there is an entry saying VMware.VimAutomation.Core in there.
If there isn't, do a
Add-PSSnapin VMware.VimAutomation.Core
Let's how far you get with this
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference