ESXi 4.1/5.0 Availability Report
Attached is a small application that is designed to output a basic monthly availability report for all hosts over multiple vCenter instances. In order to run the following tool you must have .NET 2.0 and PowerCLI 4.1/5.0 installed.
- If the connection to a host was lost and the host wasn't in maintenance mode, it counts against the availability percentage
- If the connection to a host was lost and the host was in maintenance mode, it doesn't count again it
In other words, it only counts unplanned hardware downtime against the percentage (for example, when a production host crashes with a PSOD). Here is a sample of the information contained in the detailed log file:
-------------------
xenserv3.domain.com - Uptime: 90 Days 10:37:51
-------------------
-----------------------
-----
Lost Connection Time: 0 seconds
Availability: 100%
-----
-------------------
xenserv4.domain.com - Uptime: 1 Days 20:33:17
-------------------
Host Connection Lost
Time: 12/21/2010 1:39:41 PM
Alarm 'Host connection and power state' on xenserv4.domain.com changed from Green to Red
Host Connection Re-established
Time: 12/21/2010 2:53:12 PM
Alarm 'Host connection and power state' on xenserv4.domain.com changed from Red to Green
Enter Maintenance Mode
Time: 12/21/2010 3:13:05 PM
Host xenserv4.domain.com in LAB has entered maintenance mode
Host Connection Lost
Time: 12/21/2010 3:16:39 PM
Alarm 'Host connection and power state' on xenserv4.domain.com changed from Green to Red
Host Connection Re-established
Time: 12/21/2010 3:28:17 PM
Alarm 'Host connection and power state' on xenserv4.domain.com changed from Red to Green
Exit Maintenance Mode
Time: 12/21/2010 3:28:46 PM
Host xenserv4.domain.com in LAB has exited maintenance mode
MM: (12/21/2010 3:13:05 PM - 12/21/2010 3:28:46 PM)
-----------------------
CON: (12/21/2010 1:39:41 PM - 12/21/2010 2:53:12 PM)
CON: (12/21/2010 3:16:39 PM - 12/21/2010 3:28:17 PM) - in MM
-----
Lost Connection Time: 4411.61 seconds
Availability: 99.8298%
-----
Here is how the resulting email will appear:
(Attachment: esxi-12-2010.txt)
ESXi Availability Report - December, 2010
--------------------------
xenserv3.domain.com
Avail. (Month): 100%
Current Uptime: 90 Days 10h 37m 51s
Lost Con. (Month): 0 Days 0h 0m 0s
--------------------------
xenserv4.domain.com
Avail. (Month): 99.8298%
Current Uptime: 1 Days 20h 33m 17s
Lost Con. (Month): 0 Days 1h 13m 31s
--------------------------
We have this scheduled to run on the first of every month at 12:15am with no parameters, which will provide us (via a distribution address defined in the .config file) with a report for the previous month. Here are the parameters that need to be entered into the .config file:
<!-- VCs - separate the FQDNs of all vCenter servers with commas -->
<add key="VCs" value="vc1.domain.com,vc2.domain.com" />
<!-- Usernames - separate the usernames of each vCenter with a comma -->
<add key="Usernames" value="vc1username,vc2username" />
<!-- Passwords - separate the passwords of each vCenter with a comma -->
<add key="Passwords" value="vc1userpassword,vc2userpassword" />
<!-- OutDir - supply the output directory of the report -->
<add key="OutDir" value="C:\ESXAR\" />
<!-- OutFilePrefix - supply the prefix that will be appended to the log file (*prefix*[timestamp].txt) -->
<add key="OutFilePrefix" value="esxi-" />
<!-- ToEmail - supply the email address that the report will be sent to -->
<add key="ToEmail" value="emailrecipient@company.com" />
<!-- FromEmail - supply the email address that the report will appear to come from -->
<add key="FromEmail" value="emailsender@company.com" />
<!-- SubjectEmail - supply the subject of the email -->
<add key="SubjectEmail" value="ESXi Availability Report - " />
<!-- SMTPServer - supply a valid SMTP server -->
<add key="SMTPServer" value="smtp.company.com" />
<!-- Verbose - (t/f) enter 't' to record *all* events to the log file -->
<add key="Verbose" value="f" />
The source code has been provided in case anyone would like to expand it or see how it works for their own projects. The above information can also be found in the included readme file.
Thanks, and please share any suggestions or modifications with the community!