Quantcast
Channel: VMware Communities : All Content - VMware vCenter™
Viewing all articles
Browse latest Browse all 24426

disk I/O

$
0
0

i used this program to find memory usage as well as cpu usage

but i need additional code to calculate disk I/O and Ethernet data rate in vm and esxi, i hope if any one can help me.

 

package vim25.samples.mo.perf;

 

import java.net.URL;

 

import com.vmware.vim25.DatastoreSummary;

import com.vmware.vim25.HostListSummaryQuickStats;

import com.vmware.vim25.mo.Datastore;

import com.vmware.vim25.HostHardwareSummary;

import com.vmware.vim25.HostListSummary;

import com.vmware.vim25.mo.HostSystem;

import com.vmware.vim25.mo.ManagedEntity;

import com.vmware.vim25.mo.ServiceInstance;

import com.vmware.vim25.mo.InventoryNavigator;

 

public class Test2 {

 

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

  try {

   ServiceInstance si = new ServiceInstance(new URL(args[0]), args[1], args[2], true);

           System.out.println("host :"+args[3]+"---"+si.getAboutInfo().getFullName());

 

   System.out.println(" Version is .. " +si.getAboutInfo().version);

   System.out.println(" os type is .. " +si.getAboutInfo().osType);

   System.out.println("Vendor is .. " + si.getAboutInfo().vendor);

   System.out.println("name is" + si.getAboutInfo().name);

 

   ManagedEntity[] managedEntities = new InventoryNavigator(

       si.getRootFolder()).searchManagedEntities("VirtualMachine");

       ManagedEntity[] hostmanagedEntities = new InventoryNavigator(

       si.getRootFolder()).searchManagedEntities("HostSystem");

 

   for (ManagedEntity hostmanagedEntity : hostmanagedEntities) {

               HostSystem hostsys = (HostSystem) hostmanagedEntity;

 

               String ESXhostname = hostsys.getName();

 

               HostListSummary hls = hostsys.getSummary();

               HostHardwareSummary hosthwi = hls.getHardware();

               HostListSummaryQuickStats hqs = hls.getQuickStats();

               Datastore[] HDS = hostsys.getDatastores();

               StringBuilder DS = new StringBuilder();

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

                   DatastoreSummary dsm =HDS[i].getSummary();

 

                   DS.append(dsm.name+":"+dsm.capacity+":"+dsm.freeSpace+"-");

               }

 

       int MEM=hqs.overallMemoryUsage;

       int UPT=hqs.getUptime();

       int CPU=hqs.overallCpuUsage;  

 

       String esxkey = "ESXRealInfo";

       String esxvalue = "ESXhostname-" + ESXhostname

               + ";CPU Usage-" + CPU + ";MEM Usage-"

               + MEM + ";UPTIME-" + UPT+"; Datastores -"+DS;

       System.out.println(esxvalue);

       }

 

 

   }

   catch (Exception e){ e.printStackTrace();}

}

 

}


Viewing all articles
Browse latest Browse all 24426

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>