VMware Cloud Community
Andreas_Diemer
Enthusiast
Enthusiast
Jump to solution

get performance data of VM

Hi community,

i try to get some performance data from a VM using following code:

//create start & stop time 
var end = new Date(); // now
var start = new Date();
start.setTime(end.getTime() - 3600000); // 1h before end
//create a querySpec for one entity
var querySpec = new Array();
querySpec.push(new VcPerfQuerySpec());
querySpec[0].entity = VM.reference; //set entity of workflow VM
querySpec[0].startTime = start;
querySpec[0].endTime = end;
//creteate PerfMetricID for one metric
var PM = new VcPerfMetricId();
PM.counterId = 2;
PM.instance = "";
var arrPM = new Array();
arrPM.push(PM);
querySpec[0].metricId = arrPM; //assign PerfMetric to querySpec
querySpec[0].intervalId = 20;
querySpec[0].format = "csv";

var CSV = VM.sdkConnection.perfManager.queryPerf(querySpec);  // query PerformanceManager
System.log (CSV);// show if type is OK
//show properties
System.log (CSV.entity);
System.log (CSV.value);
System.log (CSV.sampleInfoCSV);
System.log (CSV.dynamicProperty);

The workflow is valid and functional. But there is no data. Here's the log produced by the workflow:

[2010-11-12 12:12:53.742] [I] DynamicWrapper (Instance) : [VcPerfEntityMetricCSV]-[http://class com.vmware.vim.vi4.PerfEntityMetricCSV|http://class com.vmware.vim.vi4.PerfEntityMetricCSV] -- VALUE : com.vmware.vim.vi4.PerfEntityMetricCSV@beb35d25
[2010-11-12 12:12:53.742] [I] undefined
[2010-11-12 12:12:53.742] [I] undefined
[2010-11-12 12:12:53.742] [I] undefined
[2010-11-12 12:12:53.742] [I] undefined

I also tried querySpec[0].format = "normal"; - same result.

Where is my fault? Am I on the right way?

Pls support me in getting performance data, Thx.

-


Regards,

visit &

------ for correct and / or useful answers please award points visit http://www.vcoteam.info & http://mighty-virtualization.blogspot.com
Reply
0 Kudos
1 Solution

Accepted Solutions
tschoergez
Leadership
Leadership
Jump to solution

Servus Andreas!

I think I got the next step:

perfManager.queryPerf(...) returns an array, not the CSV values itself. So you have to pop() the data from the result-array.

A modification of your code which returns a lot of data in my lab:

var CSVArr = VM.sdkConnection.perfManager.queryPerf(querySpec); // query PerformanceManager

System.log (CSVArr);// show if type is OK

//show properties

var CSV = CSVArr.pop();

System.log (CSV.entity);

System.log (CSV.value);

System.log (CSV.sampleInfoCSV);

System.log (CSV.dynamicProperty);

But I don't know why the System.log(CSVArr) does not show the Array as type... (maybe because there is only one element!?!?)

edit: found the answer:

.....-- VALUE : com.vmware.vim.vi4.PerfEntityMetricCSV@229650a8 versus

..... VALUE : com.vmware.vim.vi4.PerfMetricSeriesCSV@5d7f26

"Again what learned!" Smiley Happy

BTW: I found the idea with the array on slide 59 of this presentation:

http://communities.vmware.com/servlet/JiveServlet/download/1371233-29453/vSphereAPI_PerfMonitoring.p...

Hope this helps Smiley Happy

Cheers,

joerg

PS: How do you add unformatted "verbatim" sourcecode-style here in the forums?

View solution in original post

Reply
0 Kudos
4 Replies
tschoergez
Leadership
Leadership
Jump to solution

Hi Andreas,

(I have no access to my lab so I cannot try to reproduce the issue right now), but some ideas for troubleshooting:

Have you tried to get the performance data with some other API-technology (perl, powercli, ....) to ensure the problem is your vCO-Script-Code and not a gerenal API-usage issue?

For the timeframe you try to get the data: Can you see performance charts in vSphere client?

And always tricky for performance data: time synchronization, timezone of vCO-server, vCenter server vSphere client...

Maybe you can also try to get performance counter from other timeframes in the past.

And check the vCenter settings, how many and which counters are stored and rolled up in the vCenter database (Administration / vCenter Server Settings / Statistics in vSphere Client)

cheers,

joerg

Reply
0 Kudos
Andreas_Diemer
Enthusiast
Enthusiast
Jump to solution

Hi Jörg,

instead of using realtime, I changed the intervall to past (also to avoid time difference to GMT).

To get historical data I comment the "intervalId = 20;

Additional I log time intervall.

This is the log:

[2010-11-12 16:17:55.832] [I] Thu, 11 Nov 2010 15:24:35 GMT
[2010-11-12 16:17:55.832] [I] Wed, 10 Nov 2010 15:24:35 GMT
[2010-11-12 16:17:56.067] [I] DynamicWrapper (Instance) : [VcPerfEntityMetric]-[http://class com.vmware.vim.vi4.PerfEntityMetric|http://class com.vmware.vim.vi4.PerfEntityMetric] -- VALUE : com.vmware.vim.vi4.PerfEntityMetric@873ead65
[2010-11-12 16:17:56.067] [I] undefined
[2010-11-12 16:17:56.067] [I] undefined
[2010-11-12 16:17:56.067] [I] undefined
[2010-11-12 16:17:56.067] [I] undefined

Shrinking the interval to 1h has the same result.

Use vSphere Client I can get Data for counter 16 (avg MemUsage%). I changed also counterId to 16.

I've compared the code to onyx:

var querySpec = System.getModule("com.vmware.onyx").array(VcPerfQuerySpec, 1);
querySpec[0] = new VcPerfQuerySpec();
querySpec[0].entity = Server.findForType("VC:VirtualMachine", managedObject.vimHost.id + "/vm-60");;
querySpec[0].startTime = new Date("2010-11-09T15:12:15Z");
querySpec[0].endTime = new Date("2010-11-10T15:12:15Z");
querySpec[0].metricId = System.getModule("com.vmware.onyx").array(VcPerfMetricId, 1);
querySpec[0].metricId[0] = new VcPerfMetricId();
querySpec[0].metricId[0].counterId = 16;
querySpec[0].metricId[0].instance = "";
querySpec[0].format = "csv";

To use this onxy code, you must change the date and replace the manageObject. Result is the same Smiley Sad

do you have more ideas....

-


Regards,

don't forget: award points to helpful answers

visit &

------ for correct and / or useful answers please award points visit http://www.vcoteam.info & http://mighty-virtualization.blogspot.com
Reply
0 Kudos
tschoergez
Leadership
Leadership
Jump to solution

Servus Andreas!

I think I got the next step:

perfManager.queryPerf(...) returns an array, not the CSV values itself. So you have to pop() the data from the result-array.

A modification of your code which returns a lot of data in my lab:

var CSVArr = VM.sdkConnection.perfManager.queryPerf(querySpec); // query PerformanceManager

System.log (CSVArr);// show if type is OK

//show properties

var CSV = CSVArr.pop();

System.log (CSV.entity);

System.log (CSV.value);

System.log (CSV.sampleInfoCSV);

System.log (CSV.dynamicProperty);

But I don't know why the System.log(CSVArr) does not show the Array as type... (maybe because there is only one element!?!?)

edit: found the answer:

.....-- VALUE : com.vmware.vim.vi4.PerfEntityMetricCSV@229650a8 versus

..... VALUE : com.vmware.vim.vi4.PerfMetricSeriesCSV@5d7f26

"Again what learned!" Smiley Happy

BTW: I found the idea with the array on slide 59 of this presentation:

http://communities.vmware.com/servlet/JiveServlet/download/1371233-29453/vSphereAPI_PerfMonitoring.p...

Hope this helps Smiley Happy

Cheers,

joerg

PS: How do you add unformatted "verbatim" sourcecode-style here in the forums?

Reply
0 Kudos
Andreas_Diemer
Enthusiast
Enthusiast
Jump to solution

Hi Jörg,

thx for this solution!!!!

And here the answer for native code:

  • I use only plain text tab

  • use the code tag - curly bracket code curly bracket your code curly bracket code curly bracket

 { code } your code (and remove the blanks before and after "code" { code } 

-


Regards,

don't forget: award points to helpful answers

visit &

------ for correct and / or useful answers please award points visit http://www.vcoteam.info & http://mighty-virtualization.blogspot.com
Reply
0 Kudos