VMware {code} Community
arpitmpatel13
Enthusiast
Enthusiast

Disk performance in VC doesnt appear

Hi to all,

I am not able to see Disk performance counters in performance tab of virtual center...

And also, I am not ablee to collect any disk performance related data using SDK...

Plz help...

Thanks in Advance

Arpit M Patel

Tags (2)
0 Kudos
7 Replies
tmilner
Enthusiast
Enthusiast

Arpit,

You'll get more answers if your questions are more specific.

  • What disks are you talking about (Host, VM, datastores, etc.)?

  • What counters are you trying to get?

  • How about a code snippet -- to see what you're trying to do...

  • What version of VC are you running?

Tom

0 Kudos
arpitmpatel13
Enthusiast
Enthusiast

Hi Tom,

Thanks for replying...

Im using VC 2.5.0 build 84767

I am trying to collect Disk performance of Host and VM.....

I want to collect three counters values : 1) read 2) write 3)numberRead

Following is the code for collecting Disk Read metrics data of Virtual Machine....

public class DiskRead {

public BufferedWriter output;

int interval = 10,maxSample=10,intervalID=20;

File file;

FileWriter fw;

public int getIntervalID()

{

return this.intervalID;

}

public int getMaxSample()

{

return this.maxSample;

}

public int getInterval()

{

return this.interval;

}

public void setInterval(int i)

{

interval = i;

}

public void setMaxSample(int i)

{

maxSample = i;

}

public void setIntervalID(int i)

{

intervalID = i;

}

private static AppUtil cb = null;

private void doRealTime() throws Exception {

ManagedObjectReference vmmor = cb.getServiceUtil().getDecendentMoRef(

null, "VirtualMachine", cb.get_option("vmname"));

if (vmmor != null) {

ManagedObjectReference pmRef =

cb.getConnection().getServiceContent().getPerfManager();

PerfCounterInfo[] cInfo =

(PerfCounterInfo[]) cb.getServiceUtil().getDynamicProperty(pmRef, "perfCounter");

List vmDiskReadCounters = new ArrayList();

for (int i = 0; i < cInfo.length; ++i) {

/* if("disk".equalsIgnoreCase(cInfo[i].getGroupInfo().getKey()))

{

System.out.println(cInfo[i].getNameInfo().getLabel());

} */

if ("disk read rate".equalsIgnoreCase(cInfo[i].getNameInfo().getLabel())) {

vmDiskReadCounters.add(cInfo[i]);

}

}

Map DiskReadCounters = new HashMap();

while (true) {

int index = 0;

for (Iterator it = vmDiskReadCounters.iterator(); it.hasNext();) {

PerfCounterInfo pcInfo = (PerfCounterInfo) it.next();

System.out.println(++index + " - "

+ pcInfo.getNameInfo().getSummary());

}

/*index = cb.getUtil().getIntInput(

"Please select a counter from" + " the above list"

+ "\nEnter 0 to end: ", 1);*/

index = 1;

if (index > vmDiskReadCounters.size()) {

System.out.println("*** Value out of range!");

} else {

--index;

if (index < 0)

return;

PerfCounterInfo pcmemoryInfo = (PerfCounterInfo) vmDiskReadCounters

.get(index);

DiskReadCounters.put(new Integer(pcmemoryInfo.getKey()), pcmemoryInfo);

break;

}

}

PerfMetricId[] aMetrics = cb.getConnection().getService()

.queryAvailablePerfMetric(pmRef, vmmor, null, null,

new Integer(20));

ArrayList memorymMetrics = new ArrayList();

if (aMetrics != null) {

for (int index = 0; index < aMetrics.length; ++index) {

if (DiskReadCounters.containsKey(new Integer(aMetrics[index].getCounterId()))) {

memorymMetrics.add(aMetrics[index]);

}

}

}

monitorPerformance(pmRef, vmmor, memorymMetrics, DiskReadCounters);

} else {

System.out.println("Virtual Machine " + cb.get_option("vmname")

+ " not found");

}

}

void monitorPerformance(ManagedObjectReference pmRef,

ManagedObjectReference vmRef, ArrayList mMetrics, Map counters)

throws Exception {

PerfMetricId[] metricIds = (PerfMetricId[]) mMetrics

.toArray(new PerfMetricId[0]);

PerfQuerySpec qSpec = new PerfQuerySpec();

qSpec.setEntity(vmRef);

qSpec.setMaxSample(new Integer(maxSample));

qSpec.setMetricId(metricIds);

qSpec.setIntervalId(new Integer(intervalID));

PerfQuerySpec[] qSpecs = new PerfQuerySpec[] { qSpec };

while (true) {

PerfEntityMetricBase[] pValues = cb.getConnection().getService()

.queryPerf(pmRef, qSpecs);

if (pValues != null)

displayValues(pValues, counters);

System.out.println("Sleeping "+interval+" seconds...");

Thread.sleep(interval * 1000);

}

}

void displayValues(PerfEntityMetricBase[] values, Map counters) {

for (int i = 0; i < values.length; ++i) {

PerfMetricSeries[] vals = ((PerfEntityMetric) values[i]).getValue();

PerfSampleInfo[] infos = ((PerfEntityMetric) values[i])

.getSampleInfo();

String time[] = new String[2];

time[0] = infos[0].getTimestamp().getTime().toString();

time[1] = infos[http://infos.length -1|http://infos.length -1].getTimestamp().getTime().toString();

System.out.println("Sample Time Range: "

+ time[0] + " -- " + time[1] );

for (int vi = 0; vi < vals.length; ++vi)

{

PerfCounterInfo pci = (PerfCounterInfo) counters

.get(new Integer(vals[vi].getId().getCounterId()));

/*if (pci != null)

System.out.println(pci.getNameInfo().getSummary());

*/

if (vals[vi] instanceof PerfMetricIntSeries) {

try

{

PerfMetricIntSeries val = (PerfMetricIntSeries) vals[vi];

long[] longs = val.getValue();

output.append(time[0]);

for (int k = 0; k < getMaxSample(); ++k) {

output.append("," + longs[k]);

System.out.print(" " + longs[k] + " ");

}

output.newLine();

output.flush();

System.out.println();

}catch(Exception e){}

}

}

}

}

private static OptionSpec[] constructOptions() {

OptionSpec[] useroptions = new OptionSpec[1];

useroptions[0] = new OptionSpec("vmname", "String", 1,

"Name of the virtual machine", null);

return useroptions;

}

public static void main(String[] args) throws Exception {

// run.bat com.vmware.samples.performance.Realtime --url

// --username --password

// --vmname

args = new String[9];

args[0] = "--url";

args[1] = "[https://192.168.0.27/sdk]"; //VC sdk

args[2] = "--username";

args[3] = "191513";

args[4] = "--password";

args[5] = "[mailto:p@ssw0rd_jul]";

args[6] = "--vmname";

args[7] = "Windows2003";

// args[7] = "UbuntuVMesx1";

args[8] = "--ignorecert";

DiskRead obj = new DiskRead();

obj.setInterval(10); //time after which the data to be collected

obj.setIntervalID(20); // refresh rate of data (must be 20sec)

obj.setMaxSample(1); //number of samples to be collected within sampling period (setInterval)

obj.file = new File("C:
VMwareDynamicData
Disk
DiskRead.csv"); //Data will be stored in this file

obj.fw = new FileWriter(obj.file);

obj.output = new BufferedWriter(new FileWriter(obj.file));

obj.output.append("Time," +args[7] + "");

obj.output.newLine();

obj.output.flush();

cb = AppUtil.initialize("RealTime", DiskRead.constructOptions(), args);

cb.connect();

obj.doRealTime();

cb.disConnect();

}

}

0 Kudos
tmilner
Enthusiast
Enthusiast

Arpit,

Much better. One comment I can make is that in general you shouldn't use the label to identify a counter (I learned the hard way). Here's a reference that shows how to identify the counters: http://www.vmware.com/vmtn/technology/developer/webinars/vi-api-performance-mgmt_webcast_2006-11-15..... Look on page 16. I created this page for our team: http://nworks.com/vmware/counters_vc2.5.xml (The IDs very, of course, w/ each release and ESX vs. VC).

I see where you're trying to read "Disk Read Rate" but nothing else. I cannot see anything wrong with your code. I'm assuming that your ESX server is not a ESX 2.x or 3.0 box? The older systems did not support the 20-second intervals.

I'm not sure how the cb.get_option("vmname") selects a valid VM, but are you sure it picked one that was running?

Tom

0 Kudos
arpitmpatel13
Enthusiast
Enthusiast

Hi Tom,

Your last mail is really very helpful to me...

I am now clear about counter id...

I had use CPU, memory and network counters to collect the data, which were working fine..I am able to collect all perfomance counter values for both VM and Host Machine.

But when I am trying to collect data related to disk performance it is not showing any results...

Follwing shows the couters availble from method " PerfMetricId[] queryAvailablePerfMetric() " of class ServiceConnection.

It doesnt show any counter related to Disk. And in Virtual Center GUI itself, the performance tab of both VM and Host doesnt show any counter of disk. It shows only for CPU, Memory, Net and system.

Available perfMetrics:

97 Network Usage (Minimum)

153 Group CPU Sample Count

103 Uptime

105 CPU Fairness

148 CPU Throttled (1 min. average)

2 CPU Usage (Minimum)

150 CPU Throttled (5 min. average)

69 Memory Swap In (Minimum)

6 CPU Usage in MHz (Minimum)

81 Memory Balloon Target (Minimum)

149 CPU Running (5 min. peak)

146 CPU Running (15 min. average)

151 CPU Running (15 min. peak)

13 CPU Guaranteed

147 CPU Running (1 min. peak)

104 Heartbeat

77 Memory Balloon (Minimum)

73 Memory Swap Out (Minimum)

16 Memory Usage (Minimum)

14 Memory Usage (None)

12 CPU Used

85 Memory Overhead (Minimum)

154 Group CPU Sample Period

139 CPU Running (1 min. average)

140 CPU Active (5 min. average)

143 CPU Running (5 min. average)

144 CPU Active (15 min. average)

32 Memory Zero (Minimum)

152 CPU Throttled (15 min. average)

24 Memory Active (Minimum)

28 Memory Shared (Minimum)

20 Memory Granted (Minimum)

157 Memory Consumed (Maximum)

101 Network Data Receive Rate

11 CPU Extra

9 CPU Wait

155 Memory Consumed (None)

138 CPU Active (1 min. peak)

100 Network Packets Transmitted

6 CPU Usage in MHz (Minimum)

141 Memory Reserved Capacity

65 Memory Swap Target (Minimum)

102 Network Data Transmit Rate

61 Memory Swapped (Minimum)

145 CPU Active (15 min. peak)

10 CPU Ready

0 Kudos
arpitmpatel13
Enthusiast
Enthusiast

Hi Tom,

Regarding get_option("vmname")

It selects valid Virtual Machine when I am trying to get data from Virtual Machine...

0 Kudos
tmilner
Enthusiast
Enthusiast

Arpit,

You might check the performance statistics level of your VC (from the Admin / VirtualCenter Management Server Config / Statistic menu). I believe that all of the disk counters are level 2 and above, so if your VC shows level 1 you may not get these counters for 5-min / hourly / etc. intervals. I'm not sure it applies to your program because you are using realtime stats, not summarized data, but it may explain why they don't appear under VC. I do have one word of caution. If you set the performance stat level above 1 your database will grow faster than previously.

Tom

0 Kudos
arpitmpatel13
Enthusiast
Enthusiast

<p>

Hi Tom,

</p>

<p>

ya..thats help me alot. ...

</p>

<p>

now I am able to collect information, what I require....

</p>

<p>

Thanks alot dude...

</p>

<p>

</p>

0 Kudos