Table of Contents
This script allows you to track the number of VMs provisioned on monthly basis by looking at the event manager logs on either individual ESX(i) host or vCenter. The data goes as far back as you have in host or vCenter logs and outputs the results in html report. This script jogged my memory (sometimes you just forget what you've written) from the most recent twitter post by LucD:
LucD22 New blog post: Events – Part 4 : Who started that VM ? http://bit.ly/69FIJL
Check out Luc's 4 part series on Events which allows you to pretty much report anything that's going on in your VMware environment:
Supports vCenter and ESX and ESXi (licensed and free version)
Supports running on both Windows and Linux
Suppports email capablities
vCenter 2.5 or 4.0
ESX(i) 3.5 4.0
vSphere SDK for Perl/vCLI 4.0 Windows or Linux OR vMA 4.0
DateTime Perl Module (script included to install packages)
Supports ESX(i) hosts & vCenter
Supports both ESX and ESXi (licensed and free version)
Setup DateTime Perl Module
This script requires the use of DateTime module as it's one of the data objects used in vSphere SDK for Perl bindings yet VMware failed to provide Perl moduled in the their Perl distribution. When this script was tested, the following 7 Perl modules were tested, please ensure you download the required version as there are newer releases but may require other modules/etc.
I've included in the download attachment a shell script which will automatically download, unzip and install the required Perl modules on vMA only if your system has proxy access to the internet. Else you'll have to manually download each package and upload to your vMA system and manually install in the order specified in the requirements section.
1. Upload installDateTimePM.sh script to vMA host
2. Change the permission on the script to have execute permissions
chmod +x installDateTimePM.sh
3. Execute the script (you'll be prompted to enter your vi-admin credentials prior to installation)
4. Once the installation has completed, you'll be able to execute provisionedVMReport without running into this error:
Can't locate DateTime.pm in @INC ......
Execute report against ESX(i) host or vCenter
[vi-admin@scofield skunkworks] $ ./provisionedVMReport.pl --server mauna-loa.primp-industries.com --username primp Generating provision report: "vmProvisionReport.html" ...
Execute report based on specific start and end period (e.g. 2009-01-01 to 2009-12-20)
[vi-admin@scofield skunkworks] $ ./provisionedVMReport.pl --server mauna-loa.primp-industries.com --username primp --start 2009-01-01 --end 2009-12-20 Generating provision report: "vmProvisionReport.html" ...
The report name can also be specified
[vi-admin@scofield skunkworks] $ ./provisionedVMReport.pl --server mauna-loa.primp-industries.com --username primp --start 2009-01-01 --end 2009-12-20 --report myVMReport.html Generating provision report: "myVMReport.html" ...
If you could like to setup the report to email, you'll need to edit the script at the very top and modify the following variables:
################# # EMAIL CONF ################# my $SEND_MAIL = "no"; my $EMAIL_HOST = "emailserver"; my $EMAIL_DOMAIN = "localhost.localdomain"; my $EMAIL_TO = 'William Lam <email@example.com>'; my $EMAIL_FROM = 'vMA <vMA@primp-industries.com>';