Hello everyone!
After recent discussion on vSphere Capacity planning, I thought I would share one of the tools I use for this purpose. This is a side project I've been working on for few months.
I present to you, my very own "VMware Capacity & Performance Report PowerCLI script (v2.1 Community edition)"
(Click here then click on "Download")
This is a complex PowerCLI script I wrote, that generates an e-mail report that gives you insight into the current state of your VMware vSphere environment's capacity. It generates tables, pie charts and line charts with information about CPU, Memory & Storage capacity, VM Provisioning Potential, Cluster Resilience and more. Check the script's #INFORMATION block for more information about prerequisites, script input and output.
Have a look at the report it generates and let me know what you think of it!
Please share your thoughts and comments!
Marc Davoli
http://ca.linkedin.com/in/marcvincentdavoli/
Edited on May 25 : Changed OneDrive link to updated script v2.1 with bugfix (for cluster names with a space in it)
Hi LucD,
The only metrics used to calculate the numbers in the tables are the cpu.usage.average and memory.usage.average (Line 14 and 123 of the script).
The goal was to keep it simple in this respect.
Thanks
Thanks! This is very much appreciated and looks like you put a lot of work into it.
Hi Marc,
I cant download it from the url.Its blocked here in our company.
Thanks
vmkguy2014
Nice script!
Does the script save the report locally only temporarily or is it kept after mail has been sent?
Can I define where to save the report and charts? The only user defined variables I see are VC, SMTP Server and To Address.
I get this error for the charts, eventhough I put the script in D:\scripts\
Exception calling "SaveImage" with "2" argument(s): "Access to the path 'D:\vCe
nter_CPU_Usage.png' is denied."
At D:\Script\CapacityReport.ps1:648 char:18
+ $Chart.SaveImage <<<< ($FullPath,"png")
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
Hi LucD,
Can you help me in resolving the error.
PowerCLI C:\VMware-KT\Script> .\capacity-management.ps1
Loading...
Preprocessing...
Connect-VIServer : 7/18/2014 3:52:16 PM Connect-VIServer Could not re
solve the requested VC server.
At C:\VMware-KT\Script\capacity-management.ps1:56 char:17
+ Connect-VIServer <<<< $vCenterServerName
+ CategoryInfo : ObjectNotFound: (:) [Connect-VIServer], ViServer
ConnectionException
+ FullyQualifiedErrorId : Client20_ConnectivityServiceImpl_Reconnect_NameR
esolutionFailure,VMware.VimAutomation.ViCore.Cmdlets.Commands.ConnectVISer
ver
thanks
vmk2014
At the beginning of the script there is a line
$vCenterServerName = "vCENTER_SERVER_NAME_OR_IP"
Did you substitute that for your vCenter hostname or IP address ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks LucD,
I missedout to subsitute. After correction i am getting message
Loading...
Preprocessing...
Working with multiple default servers?
Select [Y] if you want to work with more than one default servers. In this
case, every time when you connect to a different server using Connect-VIServer,
the new server connection is stored in an array variable together with the
previously connected servers. When you run a cmdlet and the target servers
cannot be determined from the specified parameters, the cmdlet runs against all
servers stored in the array variable.
Select [N] if you want to work with a single default server. In this case,
when you run a cmdlet and the target servers cannot be determined from the
specified parameters, the cmdlet runs against the last connected server.
WARNING: WORKING WITH MULTIPLE DEFAULT SERVERS WILL BE ENABLED BY DEFAULT
IN A FUTURE RELEASE. You can explicitly set your own preference at any time by
using the DefaultServerMode parameter of Set-PowerCLIConfiguration.
Will it make any changes if select option "Y" becz i have 5 vcenter server in current Environment.
thanks
vmk2014
It seems you have already a vCenter connection open when you run the script.
The prompt comes from the Connect-VIServer cmdlet in the script.
The script will run, but all the information will come from all the connected vCenters, since the script doesn't seem to use the Server parameter on all the Get- cmdlets.
I think it would be better to close all vCenter connections when you run the script
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
If you are working with multiple vcenter servers then just add the $DefaultVIServers variable after the $VcenterServername <server name> like this:
$vCenterServerName = "VcenterServer"
$DefaultVIServers="VcenterServer"
Hi Marcus
Great work ...Just checked it works for me nicely
can you please help me to get the report with below requiremnts
1.cpu and memory usage of esx host and VM with particular time period and week day for examples during buisness hours 6.00 Am to 6.00 PM from Mon to fri
2.in virtual machine report is it possible to have how many powered off vms and templates .and how much resources has been configured on powered on vm(no.of Vcpus and RAM) as on consolidated one and folder wise Vm cpu and memory usage during buisness hours 6.00 Am to 6.00 PM from Mon to fri
Great script, but the datastore totals don't seem correct? Here is what I got;
13 Datastores with a total of 1055 GB of disk space
Datastore Name | Total Disk Space (in GB) | Current Usage % | Number of VMs contained | Commitment % |
datastore1 | 274 GB | 1% | 0 | 0% |
datastore1 (1) | 62 GB | 2% | 0 | 2% |
datastore1 (2) | 62 GB | 2% | 0 | 2% |
datastore1 (3) | 62 GB | 2% | 0 | 2% |
Local Storage (Do Not Use) | 62 GB | 2% | 0 | 2% |
S1-XXXXX | 700 GB | 96% | 23 | 146% |
S1-XXXXX | 360 GB | 88% | 18 | 159% |
S1-XXXXX | 300 GB | 84% | 1 | 84% |
S1-XXXXX | 1100 GB | 87% | 27 | 111% |
S1-XXXXX | 420 GB | 76% | 2 | 95% |
S1-XXXXX | 1000 GB | 95% | 7 | 102% |
S1-XXXX | 1000 GB | 92% | 19 | 118% |
S1-XXXX | 100 GB | 84% | 1 | 83% |
Clearly I have more than 1055GB Allocated.
The other thing I'd like to know is if there is a way to exclude certain data stores from the script?
I'd like to remove all local host storage, so only my SAN shows in the report.
Figured out the answers to my own questions...and learnt a bit of CLI along the way
So the figure quoted in the above table is FREE Disk Space! I'm going to mod the script to include capacity and free space and perhaps even provisioned.
In order to only report on Storage that VM's were using (SAN Storage and not Local) I changed the following line from;
$Datastores = Get-Datastore | Sort-Object -Property Name #| Select-Object -First 1
to
$Datastores = Get-Datastore -VM $VM | Sort-Object -Property Name #| Select-Object -First 1
Hi Marc & all,
I have downloaded & tried running this script, but not having much luck. I will preface this with the fact that I am no programmer, just looking for something to give me some meaningful capacity information.
When I run the script I get the following in the attachment.
I am sure there's just a " in the wrong place, but any help would be appreciated.
What an amazing report, it has so much information. Needless to say the script worked flawlessly. Congrats on your level of expertise, that must be awesome to create such a useful report.
Do you have any ideas of holding an online review of all components for those who are still learning? Sign me up!
Simply amazing....Cheers.
Hi,
Is it possible to generate report/output in C drive temp folder rather than sending the report in email.I have mentioned in the script the smtp server and recipient email address but still output i cant see. thanks
Thanks
vm2014
I'm extremely interested in your most recent version of this script. Can you forward this as I've found no links accessible. Thanks!
Hello Marcus, thanks for sharing this amazing script.
I like to know if it is possible to change the background color of some specific cells according to criteria, Ex: Memory above 80% the background color red.
If so, could guide me how to do?
Thanks.
Hi Adriano,
Sorry for the delay in response!
It would not be easy to do that in the script's current form, since it has all the numbers in the script as "Integers".
You could do a check to know if a certain Integer is under a defined threshold(in a certain part of the script, the function), however, the problem is you would have to find a way to add the HTML tags to highlight that number (which is in another part of the script).
Take this function for example :
Function GetVMHostAverageMemoryUsagePercentage ($vmhosttemp) { #For the last 30 days
$AverageMemoryUsagePercentage = Get-Stat -Entity ($vmhosttemp)-start (get-date).AddDays(-30) -Finish (Get-Date)-MaxSamples 31 -stat mem.usage.average
$AverageMemoryUsagePercentage = $AverageMemoryUsagePercentage | Measure-Object -Property value -Average
$AverageMemoryUsagePercentage = $AverageMemoryUsagePercentage.Average
$AverageMemoryUsagePercentage = [system.math]::ceiling($AverageMemoryUsagePercentage) # Round up
return $AverageMemoryUsagePercentage
}
Since this function returns an Integer, and the script later EXPECTS an integer, that would mean you have to do a lot of work to adapt the script to use Strings instead of Integers and then add the highlighting condition.
I've considered adding this feature in the past to my script, however it just seemd like too much work compared to the potential benefit...
can you change the email address the script uses to send emails?
Great script and full of great information, thank you very very much.:smileylaugh:
Hi Jitla,
Of course: You can simply modify the variable $ToAddress. (Should be about at line 37 of the script).
Marcus