Jesudass
Contributor
Contributor

Fetching metrics from all resources in vrops

I am trying to fetch possible metrics from all available resources in the vrops server. I used the vrops rest api documentation to learn the methods and to work on gathering the data. I was successful when i executed the rest api on a rest client, i got the metrics of a single data but i want to run this as a continuous service so that the metrics are derived for a longer duration. I am looking into the JAVA client module and trying to fetch the data of all resource for last one week but did not work.

Is there any possible way i can get the data of all the available resources and for last one week and into CSV format. Need help on this please.

0 Kudos
19 Replies
carvaled
Enthusiast
Enthusiast

i know that from PowerCLI you can talk to vRops and get stats but i haven't used it in a while and cant remember how useful it is...

talking to the suite API is the right method in my opinion, what i would start by doing is to dump the list of objects and their resourceID and then collecting the statistics....

you can use some of the examples calls in my script... vRops – suite-api – stats on steroids | vMan the best language to use is perl for string manipulation of the transformation from epoc time in milliseconds to human readable time and to remap the ResourceID to a friendly name in vRops.

i also dont recommend dumping every single metric, as some objects can have 100's, focus on the key metrics per object and see how you go from there...

0 Kudos
Jesudass
Contributor
Contributor

vMan,

Thanks for replying to my question.

Actually i was trying to contact you on your blog. unfortunately the captcha on your blog did not display and i could not write to you. need more help on this from you. please share your email or write to me on jesuanthony@gmail.com.

Need your help . Thanks again

0 Kudos
carvaled
Enthusiast
Enthusiast

Hello Jesudass,

I have sent you a private message on the forum, thanks for letting me know about the broken page...

You can also contact me by posting a comment on one of my posts on vMan.ch

Cheers

vMan

0 Kudos
JackSmith1
Contributor
Contributor

Thank you for sharing your time on the important topic. Thanks again.

0 Kudos
Jesudass
Contributor
Contributor

hello vMan,

Thanks for your time and sharing your scripts. I am new to powershell and need help to execute the scripts to fetch a metric from vrops server. Need your support as i am stuck on this for days.

thanks again.

0 Kudos
carvaled
Enthusiast
Enthusiast

Please post some photos of the errors you are receiving

0 Kudos
Jesudass
Contributor
Contributor

Exception calling "DownloadString" with "1" argument(s): "The remote server returned an error: (401) Unauthorized."  I have created the creds and i am getting result when i execute the rest in chrome rest client. Please help me out.

0 Kudos
carvaled
Enthusiast
Enthusiast

what kind of account are you trying to login with?

a local or an LDAP / SSO / Domain Account?

0 Kudos
Jesudass
Contributor
Contributor

its a Domain account. i am getting this below error after i updated ps to v5 and installed export excel.

----------

Looking stuff up

powershell : Cannot convert value "<html>

At line:1 char:1

+ powershell -ExecutionPolicy ByPass -File .\vrops_psscripts.ps1 -vRops ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (Cannot convert value "<html>:String) [], RemoteException

    + FullyQualifiedErrorId : NativeCommandError

  <head>

    <META HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8">

    <!-- redirect immediately -->

    <meta http-equiv="refresh" content="0; url=ui/">

    <!-- and do not cache this file in the browser! -->

    <meta http-equiv="cache-control" content="no-cache">

    <meta http-equiv="cache-control" content="no-store">

    <meta http-equiv="pragma" content="no-cache">

    <meta http-equiv="expires" content="-1">

  </head>

  <body>Redirecting to vRealize Operations Manager Web UI...</body>

</html>

" to type "System.Xml.XmlDocument". Error: "The 'meta' start tag on line 10

position 6 does not match the end tag of 'head'. Line 11, position 5."

At C:\Users\Janthony\Desktop\vrops_psscripts.ps1:171 char:22

+ ...                 [xml]$Properties = $wc.DownloadString($Propertiesurl)

+                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidArgument: (:) [], RuntimeException

    + FullyQualifiedErrorId : InvalidCastToXmlDocument

----pleae help vMan 

0 Kudos
carvaled
Enthusiast
Enthusiast

When you generate the credentials file make sure you specify user@domain.com ....

its returning a HTML page instead of an XML as expected...   <body>Redirecting to vRealize Operations Manager Web UI...</body>

Try to login to the suite api directly in a browser and make sure you get results using the same account and format that you will in the credentials file...

Https://yourvropsip/suite-api/api/resources

0 Kudos
Jesudass
Contributor
Contributor

hi. yes, its working in the browser am getting the result as below

<ops:pageInfo totalCount="162">

<ops:page>0</ops:page>

<ops:pageSize>100</ops:pageSize>

</ops:pageInfo>

what could be the issue and need your help. please share your skype or email.

0 Kudos
carvaled
Enthusiast
Enthusiast

What version of vRops are you running?

Does it generate any files in the collected or completed directory?

Please post the whole command string you are using to run the powershell script with all parameters.

Also post a screenshot of the script, i see you have changed the name... did you change any contents also?

Sorry i dont have skype and if i share my email on a public forum i will be spammed...

0 Kudos
Jesudass
Contributor
Contributor

May be you can write to my email. i will reply. jesuanthony@gmail.com

powershell -ExecutionPolicy ByPass -File .\vrops_psscripts.ps1 -vRopsAddress 10.10.6.65 -CollectionType Collection -ResourceByName 'IEMSCA','SCALA135','JANTHONY-Workstation' -Metrics 'cpu|usagemhz_average','cpu|costopPct','cpu|readyPct','cpu|iowaitPct','cpu|idletimepercent','cpu|demandPct' -Creds HOME -rollUpType AVG -intervalType MINUTES -startdate '2016/09/18 19:20' -enddate '2016/09/19 19:20' -Format XLS

the collection directory is empty. in the script i did not change anything except i hardcoded the credentials. otherwise i was getting

Method invocation failed because [Deserialized.System.Management.Automation.PSCredential] does not contain a method

named 'GetNetworkCredential'.At C:\Users\Janthony\Desktop\vrops_psscripts.ps1:49 char:5

+     $vRopsUser = $cred.GetNetworkCredential().Username

+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidOperation: (GetNetworkCredential:String) [], RuntimeException

    + FullyQualifiedErrorId : MethodNotFound

0 Kudos
carvaled
Enthusiast
Enthusiast

Did you hard code credentials before or after upgrading to powershell v5?

I suspect the credentials are not passing through as expected due to the change in the script... as you are still passing through  -creds HOME

Dis you create HOME.XML in config directory with thw Credentials specified the same way ay you used to login to the browser suite-api?

I am going to sleep.. try to solve your credentials issue and do not hard code as you have changed how the script works and thats probably why its not working...

0 Kudos
Jesudass
Contributor
Contributor

when i dont hardcode i get the

GetNetworkCredential:String) [], RuntimeException

    + FullyQualifiedErrorId : MethodNotFound  error.

I have cretaed HOME.xml too. and the version of vrops is 6.2 .

0 Kudos
Jesudass
Contributor
Contributor

Hi,

Is there any limitation on the number of vms to be included in the -ResourceByName array.

Because when i try multiple resources i am getting result for only a few . Any restrictions?

0 Kudos
Jesudass
Contributor
Contributor

What change do i need to do in the script if i want to make metric name as the column header and value under it. and the interval to be every 5 minutes. can you suggest the changes i need to make.

0 Kudos
carvaled
Enthusiast
Enthusiast

I have run the report with about 50 machines at a time but that was for the higher roll up of daily over a few months. the limit would be the size of the url that thw rest call makes... i never tried to test the limit to be honest...

Instead of XLS or CSV try the output format in XML... this might get you the format you want.

As long as the VM names are valid, the VM is still alive in vRops and not duplicated it should export for the VM's you list

0 Kudos
carvaled
Enthusiast
Enthusiast

Specify MINUTES instead of HOURS or DAYS and it will give you the 5 minute samples. (Just remember that the data transformation takes some time and is CPU intensive to generate the data for the pivot)

vRops already outputs the data in the csv format that you want ao just make the calls to The api to get it out in that format. i cant give you an example as i killed my lab and am in the process of rebuilding it

Https://vrops/suite-api go to the documentation and specify the output format as CSV..

So the script is working for you?

0 Kudos