So the next script is something I built to pull metric, inventory and relationship data from vCenter on a regular basis using PowerCLI, I then extended the script to collect metrics from vRops once PowerCLI 6.3 Release 1 was available.

I borrowed get-stats2 function from lucd for the datastore metric collection as he did a great job on it and there is no point reinventing the wheel ūüôā

The way I use this script is to schedule it with a user that has read only access to the vCenter &/or vRops environment.

You will need to configure and add all the metrics in the MetricConfig.xml file that you wish to collect, I have already left some of the default stuff I collect as an example.. those of you familiar with get-stat will know what to specify in the <MetricName></MetricName> nodes.

In the PCLICollector.ps1 script make sure to update the path to the MetricConfig.xml file.

inside the MetricConfig.xml make sure to update the paths to¬†<ElementList></ElementList> which is used to load the list’s of hosts, vms (Elementlist_HOST.csv or¬†Elementlist_VM.csv), … for the real time metric collection.

You will also need to update all the output paths within <LocalSettings></LocalSettings>

If you wish to collect metrics in Real Time you will need to specify the list of machines within¬†Elementlist_HOST.csv or¬†Elementlist_VM.csv¬†file, I did this as my requirement was not to collect real time data for every object in vCenter¬†but only the ones I was troubleshooting… also note that you must update the¬†<Jobs></Jobs> section in the¬†MetricConfig.xml as it execute several power shell jobs to collect the¬†real time¬†data in¬†parallel….¬†you will need to adjust the number of jobs depending on the CPU capacity of your collector box.

I am not going to go over the script in this post as its 1108 lines long… ¬†just¬†run the script without parameters and you will get the instructions on how to use it.. if you have any questions please feel free to post them in the comments.

 

If you found this script / post useful… please feel free to check out some of the sponsored links as it helps with my hosting costs.

Script Download: pclicollector