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.
-
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!"
BTW: I found the idea with the array on slide 59 of this presentation:
Hope this helps
Cheers,
joerg
PS: How do you add unformatted "verbatim" sourcecode-style here in the forums?
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
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
do you have more ideas....
-
don't forget: award points to helpful answers
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!"
BTW: I found the idea with the array on slide 59 of this presentation:
Hope this helps
Cheers,
joerg
PS: How do you add unformatted "verbatim" sourcecode-style here in the forums?
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 }
-
don't forget: award points to helpful answers