Home > Blogs > VMware PowerCLI Blog


Working with Recommendations and Statistics in vR OPs with PowerCLI

In our previous post you learned how to get started with using PowerCLI against vR Ops and how to use the cmdlets to work with alerts, in this post we take you a step further an learn how to take the work from the previous post and use it with Recommendations and Statistics from vR Ops.

As part of an alert which we discussed previously, vR Ops provides recommendations that guide you to possible solutions. These recommendations are available as well via the Get-OMRecommendation cmdlet. Continuing with the example, now that I have taken ownership of an alert I can easily grab the recommendation.

image

The recommendation is to consolidate snapshots, which I can also do via PowerCLI (actually, I will just delete the snapshot since I do not need it any longer). But to do this I need the VM object. Happily, the vR Ops resource object is provided as a property of the alert. I simply need to retrieve it and here we see it contains the MOID.

image

Even better, you can simply use the VI module cmdlet Get-VM with the vR Ops resource to retrieve the VM object. From here it is just a matter of getting the snapshot and deleting it.

image

To wrap up this introduction, I want to show how you can easily retrieve metric data (or stats) from vR Ops using PowerCLI. Many times customers will ask if they can export metric data from vR Ops for usage in other analytical tools or reports. While there are other methods, the PowerCLI module offers a really elegant way to extract that data.

The cmdlet Get-OMStat will provide the metric data output but it is useful to review the cmdlet Get-OMStatKey first. vR Ops stores hundreds of metrics for CPU, memory, disk, networking and other items. For example, if you browse the Troubleshooting > All Metrics tab for a VM you can see all the metric data available.

image

Each of these metrics is contained in a construct called statKeys in vR Ops. For example, as the screenshot above shows, Average Demand in KB for Memory is stored as memory|averagedemand(kb) within vR Ops. To retrieve these statKeys programmatically you need to use the Get-OMStatKey cmdlet as shown below where I list the statKeys for a virtual machine resource (the $vmresource vra7 used in the alert examples above).

image

A lot of metrics! And that is just for CPU related metrics. I will select a specific statKey based on the name.

image

Now I can get the stats for the resource and statKey. In the example below I am getting daily metric averages for the last 30 days.

image

By the way, the values for the –IntervalType parameter are:

  • Seconds
  • Minutes
  • Hours
  • Days
  • Weeks
  • Months
  • Years

Also, the –IntervalCount parameter is a multiplier. If I specified a value of “7” instead of “1” I would have a weekly aggregation of the daily averages, as below.

image

There is a lot more capability than I have shown here, but hopefully this gives you a good start. For customers who have deep expertise in Powershell and PowerCLI the vR Ops integration can be a huge help.

In our next post we will talk more about how you can access 100% of the vR Ops public API and show a few examples of how to create functions that enable you to work with vR Ops to solve even more issues.

 


Dias_John_thumb[1]John Dias is a Staff Systems Engineer on VMware’s Solution Engineering and Technology team specializing in Cloud Management solutions.

John is a veteran IT professional with over 22 years of experience, most of that having been on the customer side running data center operations, data storage, virtual infrastructure and Unix environments for a major financial institution.

He normally blogs at storagegumbo.com and in his spare time he enjoys astronomy and astrophotography.

This entry was posted in vRealize Operations and tagged on by .
Alan Renouf

About Alan Renouf

Alan Renouf is a Product Line Manager at VMware focusing on API's, SDK's and CLI's, He is responsible for providing the architects and operators of private and public cloud infrastructure with the toolkits/frameworks and command-line interfaces they require to build a fully automated software-defined datacenter. Alan is a frequent blogger at http://blogs.vmware.com/PowerCLI a book author and has a personal blog at http://virtu-al.net. You can follow Alan on twitter as @alanrenouf.

3 thoughts on “Working with Recommendations and Statistics in vR OPs with PowerCLI

  1. Pingback: Using the entire API for vRealize Operations via PowerCLI - VMware PowerCLI Blog - VMware Blogs

  2. Pingback: PowerCLI study guide – core concepts - The Crazy Consultant

  3. vikrant

    Thanks for sharing . Your previous post was very helpful . I learned a lot and now you shared the other useful information , vR Ops provides recommendations that guide us to possible solutions. These recommendations are available as well via the Get-OMRecommendation cmdlet . We are working on the Powershell and the vR Ops integration is a beneficial for us. Thanks once again .

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

*