mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	Merge pull request #1444 from rafaelweingartner/workAroundPR780
CLOUDSTACK-8800 : Improved the listVirtualMachines API call to include memory utilization information for a VMThis PR introduces the changes proposed in PR #780 with some work to make the code null safe. During this PR, I have also removed some unused code. * pr/1444: Removed unnecessary check when creating the “userVmResponse” object. Fixed issues from CLOUDSTACK-8800 that were introduced in PR 780 CLOUDSTACK-8800 : Improved the listVirtualMachines API call to include memory utilization information for a VM for xenserver,kvm and for vmware. Signed-off-by: Will Stevens <williamstevens@gmail.com>
This commit is contained in:
		
						commit
						8c3722d953
					
				| @ -32,4 +32,10 @@ public interface VmStats { | |||||||
| 
 | 
 | ||||||
|     public double getDiskWriteKBs(); |     public double getDiskWriteKBs(); | ||||||
| 
 | 
 | ||||||
|  |     public double getMemoryKBs(); | ||||||
|  | 
 | ||||||
|  |     public double getIntFreeMemoryKBs(); | ||||||
|  | 
 | ||||||
|  |     public double getTargetMemoryKBs(); | ||||||
|  | 
 | ||||||
| } | } | ||||||
|  | |||||||
| @ -196,6 +196,18 @@ public class UserVmResponse extends BaseResponseWithTagInformation implements Co | |||||||
|     @Param(description = "the write (bytes) of disk on the vm") |     @Param(description = "the write (bytes) of disk on the vm") | ||||||
|     private Long diskKbsWrite; |     private Long diskKbsWrite; | ||||||
| 
 | 
 | ||||||
|  |     @SerializedName("memorykbs") | ||||||
|  |     @Param(description = "the memory used by the vm") | ||||||
|  |     private Long memoryKBs; | ||||||
|  | 
 | ||||||
|  |     @SerializedName("memoryintfreekbs") | ||||||
|  |     @Param(description = "the internal memory thats free in vm") | ||||||
|  |     private Long memoryIntFreeKBs; | ||||||
|  | 
 | ||||||
|  |     @SerializedName("memorytargetkbs") | ||||||
|  |     @Param(description = "the target memory in vm") | ||||||
|  |     private Long memoryTargetKBs; | ||||||
|  | 
 | ||||||
|     @SerializedName("diskioread") |     @SerializedName("diskioread") | ||||||
|     @Param(description = "the read (io) of disk on the vm") |     @Param(description = "the read (io) of disk on the vm") | ||||||
|     private Long diskIORead; |     private Long diskIORead; | ||||||
| @ -462,6 +474,18 @@ public class UserVmResponse extends BaseResponseWithTagInformation implements Co | |||||||
|         return diskKbsWrite; |         return diskKbsWrite; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     public Long getMemoryKBs() { | ||||||
|  |         return memoryKBs; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public Long getMemoryIntFreeKBs() { | ||||||
|  |         return memoryIntFreeKBs; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public Long getMemoryTargetKBs() { | ||||||
|  |         return memoryTargetKBs; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     public Long getDiskIORead() { |     public Long getDiskIORead() { | ||||||
|         return diskIORead; |         return diskIORead; | ||||||
|     } |     } | ||||||
| @ -637,6 +661,18 @@ public class UserVmResponse extends BaseResponseWithTagInformation implements Co | |||||||
|         this.diskIORead = diskIORead; |         this.diskIORead = diskIORead; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     public void setMemoryKBs(Long memoryKBs) { | ||||||
|  |         this.memoryKBs = memoryKBs; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setMemoryIntFreeKBs(Long memoryIntFreeKBs) { | ||||||
|  |         this.memoryIntFreeKBs = memoryIntFreeKBs; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setMemoryTargetKBs(Long memoryTargetKBs) { | ||||||
|  |         this.memoryTargetKBs = memoryTargetKBs; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     public void setDiskIOWrite(Long diskIOWrite) { |     public void setDiskIOWrite(Long diskIOWrite) { | ||||||
|         this.diskIOWrite = diskIOWrite; |         this.diskIOWrite = diskIOWrite; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -30,13 +30,19 @@ public class VmStatsEntry implements VmStats { | |||||||
|     double diskWriteIOs; |     double diskWriteIOs; | ||||||
|     double diskReadKBs; |     double diskReadKBs; | ||||||
|     double diskWriteKBs; |     double diskWriteKBs; | ||||||
|  |     double memoryKBs; | ||||||
|  |     double intfreememoryKBs; | ||||||
|  |     double targetmemoryKBs; | ||||||
|     int numCPUs; |     int numCPUs; | ||||||
|     String entityType; |     String entityType; | ||||||
| 
 | 
 | ||||||
|     public VmStatsEntry() { |     public VmStatsEntry() { | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public VmStatsEntry(double cpuUtilization, double networkReadKBs, double networkWriteKBs, int numCPUs, String entityType) { |     public VmStatsEntry(double memoryKBs,double intfreememoryKBs,double targetmemoryKBs, double cpuUtilization, double networkReadKBs, double networkWriteKBs, int numCPUs, String entityType) { | ||||||
|  |         this.memoryKBs = memoryKBs; | ||||||
|  |         this.intfreememoryKBs = intfreememoryKBs; | ||||||
|  |         this.targetmemoryKBs = targetmemoryKBs; | ||||||
|         this.cpuUtilization = cpuUtilization; |         this.cpuUtilization = cpuUtilization; | ||||||
|         this.networkReadKBs = networkReadKBs; |         this.networkReadKBs = networkReadKBs; | ||||||
|         this.networkWriteKBs = networkWriteKBs; |         this.networkWriteKBs = networkWriteKBs; | ||||||
| @ -117,6 +123,33 @@ public class VmStatsEntry implements VmStats { | |||||||
|         this.diskWriteKBs = diskWriteKBs; |         this.diskWriteKBs = diskWriteKBs; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     @Override | ||||||
|  |     public double getMemoryKBs() { | ||||||
|  |         return memoryKBs; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setMemoryKBs(double memoryKBs) { | ||||||
|  |         this.memoryKBs = memoryKBs; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Override | ||||||
|  |     public double getIntFreeMemoryKBs() { | ||||||
|  |         return intfreememoryKBs; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setIntFreeMemoryKBs(double intfreememoryKBs) { | ||||||
|  |         this.intfreememoryKBs = intfreememoryKBs; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Override | ||||||
|  |     public double getTargetMemoryKBs() { | ||||||
|  |         return targetmemoryKBs; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setTargetMemoryKBs(double targetmemoryKBs) { | ||||||
|  |         this.targetmemoryKBs = targetmemoryKBs; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     public int getNumCPUs() { |     public int getNumCPUs() { | ||||||
|         return numCPUs; |         return numCPUs; | ||||||
|     } |     } | ||||||
|  | |||||||
							
								
								
									
										38
									
								
								plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							
							
						
						
									
										38
									
								
								plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							| @ -52,6 +52,8 @@ import org.apache.cloudstack.utils.linux.MemStat; | |||||||
| import org.apache.cloudstack.utils.qemu.QemuImg.PhysicalDiskFormat; | import org.apache.cloudstack.utils.qemu.QemuImg.PhysicalDiskFormat; | ||||||
| import org.apache.commons.io.FileUtils; | import org.apache.commons.io.FileUtils; | ||||||
| import org.apache.commons.io.IOUtils; | import org.apache.commons.io.IOUtils; | ||||||
|  | import org.apache.commons.lang.ArrayUtils; | ||||||
|  | import org.apache.commons.lang.math.NumberUtils; | ||||||
| import org.apache.log4j.Logger; | import org.apache.log4j.Logger; | ||||||
| import org.libvirt.Connect; | import org.libvirt.Connect; | ||||||
| import org.libvirt.Domain; | import org.libvirt.Domain; | ||||||
| @ -60,6 +62,7 @@ import org.libvirt.DomainInfo; | |||||||
| import org.libvirt.DomainInfo.DomainState; | import org.libvirt.DomainInfo.DomainState; | ||||||
| import org.libvirt.DomainInterfaceStats; | import org.libvirt.DomainInterfaceStats; | ||||||
| import org.libvirt.LibvirtException; | import org.libvirt.LibvirtException; | ||||||
|  | import org.libvirt.MemoryStatistic; | ||||||
| import org.libvirt.NodeInfo; | import org.libvirt.NodeInfo; | ||||||
| 
 | 
 | ||||||
| import com.cloud.agent.api.Answer; | import com.cloud.agent.api.Answer; | ||||||
| @ -188,8 +191,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv | |||||||
|     private String _clusterId; |     private String _clusterId; | ||||||
| 
 | 
 | ||||||
|     private long _hvVersion; |     private long _hvVersion; | ||||||
|     private long _kernelVersion; |  | ||||||
|     private int _timeout; |     private int _timeout; | ||||||
|  |     private static final int NUMMEMSTATS =2; | ||||||
| 
 | 
 | ||||||
|     private KVMHAMonitor _monitor; |     private KVMHAMonitor _monitor; | ||||||
|     public static final String SSHKEYSPATH = "/root/.ssh"; |     public static final String SSHKEYSPATH = "/root/.ssh"; | ||||||
| @ -956,13 +959,6 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv | |||||||
|         storageProcessor.configure(name, params); |         storageProcessor.configure(name, params); | ||||||
|         storageHandler = new StorageSubsystemCommandHandlerBase(storageProcessor); |         storageHandler = new StorageSubsystemCommandHandlerBase(storageProcessor); | ||||||
| 
 | 
 | ||||||
|         final String unameKernelVersion = Script.runSimpleBashScript("uname -r"); |  | ||||||
|         final String[] kernelVersions = unameKernelVersion.split("[\\.\\-]"); |  | ||||||
|         _kernelVersion = Integer.parseInt(kernelVersions[0]) * 1000 * 1000 + (long)Integer.parseInt(kernelVersions[1]) * 1000 + Integer.parseInt(kernelVersions[2]); |  | ||||||
| 
 |  | ||||||
|         /* Disable this, the code using this is pretty bad and non portable |  | ||||||
|          * getOsVersion(); |  | ||||||
|          */ |  | ||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -3025,12 +3021,19 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv | |||||||
|         Domain dm = null; |         Domain dm = null; | ||||||
|         try { |         try { | ||||||
|             dm = getDomain(conn, vmName); |             dm = getDomain(conn, vmName); | ||||||
|             final DomainInfo info = dm.getInfo(); |             if (dm == null) { | ||||||
| 
 |                 return null; | ||||||
|  |             } | ||||||
|  |             DomainInfo info = dm.getInfo(); | ||||||
|             final VmStatsEntry stats = new VmStatsEntry(); |             final VmStatsEntry stats = new VmStatsEntry(); | ||||||
|  | 
 | ||||||
|             stats.setNumCPUs(info.nrVirtCpu); |             stats.setNumCPUs(info.nrVirtCpu); | ||||||
|             stats.setEntityType("vm"); |             stats.setEntityType("vm"); | ||||||
| 
 | 
 | ||||||
|  |             stats.setMemoryKBs(info.maxMem); | ||||||
|  |             stats.setTargetMemoryKBs(info.memory); | ||||||
|  |             stats.setIntFreeMemoryKBs(getMemoryFreeInKBs(dm)); | ||||||
|  | 
 | ||||||
|             /* get cpu utilization */ |             /* get cpu utilization */ | ||||||
|             VmStats oldStats = null; |             VmStats oldStats = null; | ||||||
| 
 | 
 | ||||||
| @ -3124,6 +3127,21 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     /** | ||||||
|  |     * This method retrieves the memory statistics from the domain given as parameters. | ||||||
|  |     * If no memory statistic is found, it will return {@link NumberUtils#LONG_ZERO} as the value of free memory in the domain. | ||||||
|  |     * If it can retrieve the domain memory statistics, it will return the free memory statistic; that means, it returns the value at the first position of the array returned by {@link Domain#memoryStats(int)}. | ||||||
|  |     * | ||||||
|  |     * @return the amount of free memory in KBs | ||||||
|  |     */ | ||||||
|  |     protected long getMemoryFreeInKBs(Domain dm) throws LibvirtException { | ||||||
|  |         MemoryStatistic[] mems = dm.memoryStats(NUMMEMSTATS); | ||||||
|  |         if (ArrayUtils.isEmpty(mems)) { | ||||||
|  |             return NumberUtils.LONG_ZERO; | ||||||
|  |         } | ||||||
|  |         return mems[0].getValue(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     private boolean canBridgeFirewall(final String prvNic) { |     private boolean canBridgeFirewall(final String prvNic) { | ||||||
|         final Script cmd = new Script(_securityGroupPath, _timeout, s_logger); |         final Script cmd = new Script(_securityGroupPath, _timeout, s_logger); | ||||||
|         cmd.add("can_bridge_firewall"); |         cmd.add("can_bridge_firewall"); | ||||||
|  | |||||||
| @ -65,8 +65,10 @@ import org.libvirt.DomainInfo; | |||||||
| import org.libvirt.DomainInfo.DomainState; | import org.libvirt.DomainInfo.DomainState; | ||||||
| import org.libvirt.DomainInterfaceStats; | import org.libvirt.DomainInterfaceStats; | ||||||
| import org.libvirt.LibvirtException; | import org.libvirt.LibvirtException; | ||||||
|  | import org.libvirt.MemoryStatistic; | ||||||
| import org.libvirt.NodeInfo; | import org.libvirt.NodeInfo; | ||||||
| import org.libvirt.StorageVol; | import org.libvirt.StorageVol; | ||||||
|  | import org.libvirt.jna.virDomainMemoryStats; | ||||||
| import org.mockito.Matchers; | import org.mockito.Matchers; | ||||||
| import org.mockito.Mock; | import org.mockito.Mock; | ||||||
| import org.mockito.Mockito; | import org.mockito.Mockito; | ||||||
| @ -180,8 +182,8 @@ public class LibvirtComputingResourceTest { | |||||||
|     @Mock |     @Mock | ||||||
|     private LibvirtComputingResource libvirtComputingResource; |     private LibvirtComputingResource libvirtComputingResource; | ||||||
| 
 | 
 | ||||||
|     String _hyperVisorType = "kvm"; |     String hyperVisorType = "kvm"; | ||||||
|     Random _random = new Random(); |     Random random = new Random(); | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|         This test tests if the Agent can handle a vmSpec coming |         This test tests if the Agent can handle a vmSpec coming | ||||||
| @ -192,10 +194,10 @@ public class LibvirtComputingResourceTest { | |||||||
|      */ |      */ | ||||||
|     @Test |     @Test | ||||||
|     public void testCreateVMFromSpecLegacy() { |     public void testCreateVMFromSpecLegacy() { | ||||||
|         final int id = _random.nextInt(65534); |         final int id = random.nextInt(65534); | ||||||
|         final String name = "test-instance-1"; |         final String name = "test-instance-1"; | ||||||
| 
 | 
 | ||||||
|         final int cpus = _random.nextInt(2) + 1; |         final int cpus = random.nextInt(2) + 1; | ||||||
|         final int speed = 1024; |         final int speed = 1024; | ||||||
|         final int minRam = 256 * 1024; |         final int minRam = 256 * 1024; | ||||||
|         final int maxRam = 512 * 1024; |         final int maxRam = 512 * 1024; | ||||||
| @ -211,7 +213,7 @@ public class LibvirtComputingResourceTest { | |||||||
|         to.setUuid("b0f0a72d-7efb-3cad-a8ff-70ebf30b3af9"); |         to.setUuid("b0f0a72d-7efb-3cad-a8ff-70ebf30b3af9"); | ||||||
| 
 | 
 | ||||||
|         final LibvirtVMDef vm = lcr.createVMFromSpec(to); |         final LibvirtVMDef vm = lcr.createVMFromSpec(to); | ||||||
|         vm.setHvsType(_hyperVisorType); |         vm.setHvsType(hyperVisorType); | ||||||
| 
 | 
 | ||||||
|         verifyVm(to, vm); |         verifyVm(to, vm); | ||||||
|     } |     } | ||||||
| @ -221,7 +223,7 @@ public class LibvirtComputingResourceTest { | |||||||
|      */ |      */ | ||||||
|     @Test |     @Test | ||||||
|     public void testCreateVMFromSpecWithTopology6() { |     public void testCreateVMFromSpecWithTopology6() { | ||||||
|         final int id = _random.nextInt(65534); |         final int id = random.nextInt(65534); | ||||||
|         final String name = "test-instance-1"; |         final String name = "test-instance-1"; | ||||||
| 
 | 
 | ||||||
|         final int cpus = 12; |         final int cpus = 12; | ||||||
| @ -241,7 +243,7 @@ public class LibvirtComputingResourceTest { | |||||||
|         to.setUuid("b0f0a72d-7efb-3cad-a8ff-70ebf30b3af9"); |         to.setUuid("b0f0a72d-7efb-3cad-a8ff-70ebf30b3af9"); | ||||||
| 
 | 
 | ||||||
|         final LibvirtVMDef vm = lcr.createVMFromSpec(to); |         final LibvirtVMDef vm = lcr.createVMFromSpec(to); | ||||||
|         vm.setHvsType(_hyperVisorType); |         vm.setHvsType(hyperVisorType); | ||||||
| 
 | 
 | ||||||
|         verifyVm(to, vm); |         verifyVm(to, vm); | ||||||
|     } |     } | ||||||
| @ -251,7 +253,7 @@ public class LibvirtComputingResourceTest { | |||||||
|      */ |      */ | ||||||
|     @Test |     @Test | ||||||
|     public void testCreateVMFromSpecWithTopology4() { |     public void testCreateVMFromSpecWithTopology4() { | ||||||
|         final int id = _random.nextInt(65534); |         final int id = random.nextInt(65534); | ||||||
|         final String name = "test-instance-1"; |         final String name = "test-instance-1"; | ||||||
| 
 | 
 | ||||||
|         final int cpus = 8; |         final int cpus = 8; | ||||||
| @ -271,7 +273,7 @@ public class LibvirtComputingResourceTest { | |||||||
|         to.setUuid("b0f0a72d-7efb-3cad-a8ff-70ebf30b3af9"); |         to.setUuid("b0f0a72d-7efb-3cad-a8ff-70ebf30b3af9"); | ||||||
| 
 | 
 | ||||||
|         final LibvirtVMDef vm = lcr.createVMFromSpec(to); |         final LibvirtVMDef vm = lcr.createVMFromSpec(to); | ||||||
|         vm.setHvsType(_hyperVisorType); |         vm.setHvsType(hyperVisorType); | ||||||
| 
 | 
 | ||||||
|         verifyVm(to, vm); |         verifyVm(to, vm); | ||||||
|     } |     } | ||||||
| @ -285,10 +287,10 @@ public class LibvirtComputingResourceTest { | |||||||
|      */ |      */ | ||||||
|     @Test |     @Test | ||||||
|     public void testCreateVMFromSpec() { |     public void testCreateVMFromSpec() { | ||||||
|         final int id = _random.nextInt(65534); |         final int id = random.nextInt(65534); | ||||||
|         final String name = "test-instance-1"; |         final String name = "test-instance-1"; | ||||||
| 
 | 
 | ||||||
|         final int cpus = _random.nextInt(2) + 1; |         final int cpus = random.nextInt(2) + 1; | ||||||
|         final int minSpeed = 1024; |         final int minSpeed = 1024; | ||||||
|         final int maxSpeed = 2048; |         final int maxSpeed = 2048; | ||||||
|         final int minRam = 256 * 1024; |         final int minRam = 256 * 1024; | ||||||
| @ -306,7 +308,7 @@ public class LibvirtComputingResourceTest { | |||||||
|         to.setUuid("b0f0a72d-7efb-3cad-a8ff-70ebf30b3af9"); |         to.setUuid("b0f0a72d-7efb-3cad-a8ff-70ebf30b3af9"); | ||||||
| 
 | 
 | ||||||
|         final LibvirtVMDef vm = lcr.createVMFromSpec(to); |         final LibvirtVMDef vm = lcr.createVMFromSpec(to); | ||||||
|         vm.setHvsType(_hyperVisorType); |         vm.setHvsType(hyperVisorType); | ||||||
| 
 | 
 | ||||||
|         verifyVm(to, vm); |         verifyVm(to, vm); | ||||||
|     } |     } | ||||||
| @ -418,7 +420,10 @@ public class LibvirtComputingResourceTest { | |||||||
|         final Connect connect = Mockito.mock(Connect.class); |         final Connect connect = Mockito.mock(Connect.class); | ||||||
|         final Domain domain = Mockito.mock(Domain.class); |         final Domain domain = Mockito.mock(Domain.class); | ||||||
|         final DomainInfo domainInfo = new DomainInfo(); |         final DomainInfo domainInfo = new DomainInfo(); | ||||||
|  |         final MemoryStatistic[] domainMem = new MemoryStatistic[2]; | ||||||
|  |         domainMem[0] = Mockito.mock(MemoryStatistic.class); | ||||||
|         Mockito.when(domain.getInfo()).thenReturn(domainInfo); |         Mockito.when(domain.getInfo()).thenReturn(domainInfo); | ||||||
|  |         Mockito.when(domain.memoryStats(2)).thenReturn(domainMem); | ||||||
|         Mockito.when(connect.domainLookupByName(VMNAME)).thenReturn(domain); |         Mockito.when(connect.domainLookupByName(VMNAME)).thenReturn(domain); | ||||||
|         final NodeInfo nodeInfo = new NodeInfo(); |         final NodeInfo nodeInfo = new NodeInfo(); | ||||||
|         nodeInfo.cpus = 8; |         nodeInfo.cpus = 8; | ||||||
| @ -485,6 +490,10 @@ public class LibvirtComputingResourceTest { | |||||||
|         // IO traffic as generated by the logic above, must be greater than zero |         // IO traffic as generated by the logic above, must be greater than zero | ||||||
|         Assert.assertTrue(vmStat.getDiskReadKBs() > 0); |         Assert.assertTrue(vmStat.getDiskReadKBs() > 0); | ||||||
|         Assert.assertTrue(vmStat.getDiskWriteKBs() > 0); |         Assert.assertTrue(vmStat.getDiskWriteKBs() > 0); | ||||||
|  |         // Memory limit of VM must be greater than zero | ||||||
|  |         Assert.assertTrue(vmStat.getIntFreeMemoryKBs() >= 0); | ||||||
|  |         Assert.assertTrue(vmStat.getMemoryKBs() >= 0); | ||||||
|  |         Assert.assertTrue(vmStat.getTargetMemoryKBs() >= vmStat.getMemoryKBs()); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Test |     @Test | ||||||
| @ -709,10 +718,9 @@ public class LibvirtComputingResourceTest { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @SuppressWarnings("unchecked") |  | ||||||
|     @Test |     @Test | ||||||
|  |     @SuppressWarnings("unchecked") | ||||||
|     public void testGetVmDiskStatsCommandException() { |     public void testGetVmDiskStatsCommandException() { | ||||||
|         Mockito.mock(Connect.class); |  | ||||||
|         final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); |         final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); | ||||||
| 
 | 
 | ||||||
|         final String vmName = "Test"; |         final String vmName = "Test"; | ||||||
| @ -932,7 +940,6 @@ public class LibvirtComputingResourceTest { | |||||||
|     public void testGetHostStatsCommand() { |     public void testGetHostStatsCommand() { | ||||||
|         // A bit difficult to test due to the logger being passed and the parser itself relying on the connection. |         // A bit difficult to test due to the logger being passed and the parser itself relying on the connection. | ||||||
|         // Have to spend some more time afterwards in order to refactor the wrapper itself. |         // Have to spend some more time afterwards in order to refactor the wrapper itself. | ||||||
|         Mockito.mock(LibvirtUtilitiesHelper.class); |  | ||||||
|         final CPUStat cpuStat = Mockito.mock(CPUStat.class); |         final CPUStat cpuStat = Mockito.mock(CPUStat.class); | ||||||
|         final MemStat memStat = Mockito.mock(MemStat.class); |         final MemStat memStat = Mockito.mock(MemStat.class); | ||||||
| 
 | 
 | ||||||
| @ -3522,7 +3529,6 @@ public class LibvirtComputingResourceTest { | |||||||
|         verify(libvirtComputingResource, times(1)).configureVPCNetworkUsage(command.getPrivateIP(), command.getGatewayIP(), command.getOption(), command.getVpcCIDR()); |         verify(libvirtComputingResource, times(1)).configureVPCNetworkUsage(command.getPrivateIP(), command.getGatewayIP(), command.getOption(), command.getVpcCIDR()); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @SuppressWarnings("unchecked") |  | ||||||
|     @Test |     @Test | ||||||
|     public void testCreatePrivateTemplateFromVolumeCommand() { |     public void testCreatePrivateTemplateFromVolumeCommand() { | ||||||
|         //Simple test used to make sure the flow (LibvirtComputingResource => Request => CommandWrapper) is working. |         //Simple test used to make sure the flow (LibvirtComputingResource => Request => CommandWrapper) is working. | ||||||
| @ -5031,4 +5037,40 @@ public class LibvirtComputingResourceTest { | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     @Test | ||||||
|  |     public void testMemoryFreeInKBsDomainReturningOfSomeMemoryStatistics() throws LibvirtException { | ||||||
|  |         LibvirtComputingResource libvirtComputingResource = new LibvirtComputingResource(); | ||||||
|  | 
 | ||||||
|  |         MemoryStatistic[] mem = createMemoryStatisticFreeMemory100(); | ||||||
|  |         Domain domainMock = getDomainConfiguredToReturnMemoryStatistic(mem); | ||||||
|  |         long memoryFreeInKBs = libvirtComputingResource.getMemoryFreeInKBs(domainMock); | ||||||
|  | 
 | ||||||
|  |         Assert.assertEquals(100, memoryFreeInKBs); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Test | ||||||
|  |     public void testMemoryFreeInKBsDomainReturningNoMemoryStatistics() throws LibvirtException { | ||||||
|  |         LibvirtComputingResource libvirtComputingResource = new LibvirtComputingResource(); | ||||||
|  | 
 | ||||||
|  |         Domain domainMock = getDomainConfiguredToReturnMemoryStatistic(null); | ||||||
|  |         long memoryFreeInKBs = libvirtComputingResource.getMemoryFreeInKBs(domainMock); | ||||||
|  | 
 | ||||||
|  |         Assert.assertEquals(0, memoryFreeInKBs); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     private MemoryStatistic[] createMemoryStatisticFreeMemory100() { | ||||||
|  |         virDomainMemoryStats stat = new virDomainMemoryStats(); | ||||||
|  |         stat.val = 100; | ||||||
|  | 
 | ||||||
|  |         MemoryStatistic[] mem = new MemoryStatistic[2]; | ||||||
|  |         mem[0] = new MemoryStatistic(stat); | ||||||
|  |         return mem; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     private Domain getDomainConfiguredToReturnMemoryStatistic(MemoryStatistic[] mem) throws LibvirtException { | ||||||
|  |         Domain domainMock = Mockito.mock(Domain.class); | ||||||
|  |         when(domainMock.memoryStats(2)).thenReturn(mem); | ||||||
|  |         return domainMock; | ||||||
|  |     } | ||||||
| } | } | ||||||
| @ -319,7 +319,7 @@ public class MockVmManagerImpl extends ManagerBase implements MockVmManager { | |||||||
|         final HashMap<String, VmStatsEntry> vmStatsNameMap = new HashMap<String, VmStatsEntry>(); |         final HashMap<String, VmStatsEntry> vmStatsNameMap = new HashMap<String, VmStatsEntry>(); | ||||||
|         final List<String> vmNames = cmd.getVmNames(); |         final List<String> vmNames = cmd.getVmNames(); | ||||||
|         for (final String vmName : vmNames) { |         for (final String vmName : vmNames) { | ||||||
|             final VmStatsEntry entry = new VmStatsEntry(0, 0, 0, 0, "vm"); |             final VmStatsEntry entry = new VmStatsEntry(0, 0, 0, 0, 0, 0, 0, "vm"); | ||||||
|             entry.setNetworkReadKBs(32768); // default values 256 KBps |             entry.setNetworkReadKBs(32768); // default values 256 KBps | ||||||
|             entry.setNetworkWriteKBs(16384); |             entry.setNetworkWriteKBs(16384); | ||||||
|             entry.setCPUUtilization(10); |             entry.setCPUUtilization(10); | ||||||
|  | |||||||
| @ -100,6 +100,7 @@ import com.vmware.vim25.VmwareDistributedVirtualSwitchVlanIdSpec; | |||||||
| import org.apache.cloudstack.storage.command.StorageSubSystemCommand; | import org.apache.cloudstack.storage.command.StorageSubSystemCommand; | ||||||
| import org.apache.cloudstack.storage.to.TemplateObjectTO; | import org.apache.cloudstack.storage.to.TemplateObjectTO; | ||||||
| import org.apache.cloudstack.storage.to.VolumeObjectTO; | import org.apache.cloudstack.storage.to.VolumeObjectTO; | ||||||
|  | import org.apache.commons.lang.math.NumberUtils; | ||||||
| 
 | 
 | ||||||
| import com.cloud.agent.IAgentControl; | import com.cloud.agent.IAgentControl; | ||||||
| import com.cloud.agent.api.Answer; | import com.cloud.agent.api.Answer; | ||||||
| @ -4966,8 +4967,14 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa | |||||||
|         } |         } | ||||||
|         String instanceNameCustomField = "value[" + key + "]"; |         String instanceNameCustomField = "value[" + key + "]"; | ||||||
| 
 | 
 | ||||||
|  |         final String numCpuStr = "summary.config.numCpu"; | ||||||
|  |         final String cpuUseStr = "summary.quickStats.overallCpuUsage"; | ||||||
|  |         final String guestMemUseStr = "summary.quickStats.guestMemoryUsage"; | ||||||
|  |         final String memLimitStr = "resourceConfig.memoryAllocation.limit"; | ||||||
|  |         final String memMbStr = "config.hardware.memoryMB"; | ||||||
|  | 
 | ||||||
|         ObjectContent[] ocs = |         ObjectContent[] ocs = | ||||||
|                 hyperHost.getVmPropertiesOnHyperHost(new String[] {"name", "summary.config.numCpu", "summary.quickStats.overallCpuUsage", instanceNameCustomField}); |                 hyperHost.getVmPropertiesOnHyperHost(new String[] {"name", numCpuStr, cpuUseStr ,guestMemUseStr ,memLimitStr ,memMbStr, instanceNameCustomField}); | ||||||
|         if (ocs != null && ocs.length > 0) { |         if (ocs != null && ocs.length > 0) { | ||||||
|             for (ObjectContent oc : ocs) { |             for (ObjectContent oc : ocs) { | ||||||
|                 List<DynamicProperty> objProps = oc.getPropSet(); |                 List<DynamicProperty> objProps = oc.getPropSet(); | ||||||
| @ -4975,6 +4982,9 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa | |||||||
|                     String name = null; |                     String name = null; | ||||||
|                     String numberCPUs = null; |                     String numberCPUs = null; | ||||||
|                     String maxCpuUsage = null; |                     String maxCpuUsage = null; | ||||||
|  |                     String memlimit = null; | ||||||
|  |                     String memkb = null; | ||||||
|  |                     String guestMemusage = null; | ||||||
|                     String vmNameOnVcenter = null; |                     String vmNameOnVcenter = null; | ||||||
|                     String vmInternalCSName = null; |                     String vmInternalCSName = null; | ||||||
|                     for (DynamicProperty objProp : objProps) { |                     for (DynamicProperty objProp : objProps) { | ||||||
| @ -4983,10 +4993,16 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa | |||||||
|                         } else if (objProp.getName().contains(instanceNameCustomField)) { |                         } else if (objProp.getName().contains(instanceNameCustomField)) { | ||||||
|                             if (objProp.getVal() != null) |                             if (objProp.getVal() != null) | ||||||
|                                 vmInternalCSName = ((CustomFieldStringValue)objProp.getVal()).getValue(); |                                 vmInternalCSName = ((CustomFieldStringValue)objProp.getVal()).getValue(); | ||||||
|                         } else if (objProp.getName().equals("summary.config.numCpu")) { |                         }else if(objProp.getName().equals(guestMemusage)){ | ||||||
|  |                             guestMemusage = objProp.getVal().toString(); | ||||||
|  |                         }else if (objProp.getName().equals(numCpuStr)) { | ||||||
|                             numberCPUs = objProp.getVal().toString(); |                             numberCPUs = objProp.getVal().toString(); | ||||||
|                         } else if (objProp.getName().equals("summary.quickStats.overallCpuUsage")) { |                         } else if (objProp.getName().equals(cpuUseStr)) { | ||||||
|                             maxCpuUsage = objProp.getVal().toString(); |                             maxCpuUsage = objProp.getVal().toString(); | ||||||
|  |                         } else if (objProp.getName().equals(memLimitStr)) { | ||||||
|  |                             memlimit = objProp.getVal().toString(); | ||||||
|  |                         } else if (objProp.getName().equals(memMbStr)) { | ||||||
|  |                             memkb = objProp.getVal().toString(); | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|                     new VirtualMachineMO(hyperHost.getContext(), oc.getObj()); |                     new VirtualMachineMO(hyperHost.getContext(), oc.getObj()); | ||||||
| @ -5055,7 +5071,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa | |||||||
|                             } |                             } | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|                     vmResponseMap.put(name, new VmStatsEntry(Integer.parseInt(maxCpuUsage), networkReadKBs, networkWriteKBs, Integer.parseInt(numberCPUs), "vm")); |                     vmResponseMap.put(name, new VmStatsEntry( NumberUtils.toDouble(memkb)*1024,NumberUtils.toDouble(guestMemusage)*1024,NumberUtils.toDouble(memlimit)*1024, NumberUtils.toDouble(maxCpuUsage), networkReadKBs, networkWriteKBs, NumberUtils.toInt(numberCPUs), "vm")); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -184,6 +184,8 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     private final static int BASE_TO_CONVERT_BYTES_INTO_KILOBYTES = 1024; | ||||||
|  | 
 | ||||||
|     protected static final XenServerConnectionPool ConnPool = XenServerConnectionPool.getInstance(); |     protected static final XenServerConnectionPool ConnPool = XenServerConnectionPool.getInstance(); | ||||||
|     // static min values for guests on xenserver |     // static min values for guests on xenserver | ||||||
|     private static final long mem_128m = 134217728L; |     private static final long mem_128m = 134217728L; | ||||||
| @ -3276,7 +3278,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe | |||||||
|         final HashMap<String, VmStatsEntry> vmResponseMap = new HashMap<String, VmStatsEntry>(); |         final HashMap<String, VmStatsEntry> vmResponseMap = new HashMap<String, VmStatsEntry>(); | ||||||
| 
 | 
 | ||||||
|         for (final String vmUUID : vmUUIDs) { |         for (final String vmUUID : vmUUIDs) { | ||||||
|             vmResponseMap.put(vmUUID, new VmStatsEntry(0, 0, 0, 0, "vm")); |             vmResponseMap.put(vmUUID, new VmStatsEntry(0,0,0,0, 0, 0, 0, "vm")); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         final Object[] rrdData = getRRDData(conn, 2); // call rrddata with 2 for |         final Object[] rrdData = getRRDData(conn, 2); // call rrddata with 2 for | ||||||
| @ -3323,14 +3325,21 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe | |||||||
|                     vmStatsAnswer.setNumCPUs(vmStatsAnswer.getNumCPUs() + 1); |                     vmStatsAnswer.setNumCPUs(vmStatsAnswer.getNumCPUs() + 1); | ||||||
|                     vmStatsAnswer.setCPUUtilization(vmStatsAnswer.getCPUUtilization() + getDataAverage(dataNode, col, numRows)); |                     vmStatsAnswer.setCPUUtilization(vmStatsAnswer.getCPUUtilization() + getDataAverage(dataNode, col, numRows)); | ||||||
|                 } else if (param.matches("vif_\\d*_rx")) { |                 } else if (param.matches("vif_\\d*_rx")) { | ||||||
|                     vmStatsAnswer.setNetworkReadKBs(vmStatsAnswer.getNetworkReadKBs() + getDataAverage(dataNode, col, numRows) / 1000); |                     vmStatsAnswer.setNetworkReadKBs(vmStatsAnswer.getNetworkReadKBs() + getDataAverage(dataNode, col, numRows) / BASE_TO_CONVERT_BYTES_INTO_KILOBYTES); | ||||||
|                 } else if (param.matches("vif_\\d*_tx")) { |                 } else if (param.matches("vif_\\d*_tx")) { | ||||||
|                     vmStatsAnswer.setNetworkWriteKBs(vmStatsAnswer.getNetworkWriteKBs() + getDataAverage(dataNode, col, numRows) / 1000); |                     vmStatsAnswer.setNetworkWriteKBs(vmStatsAnswer.getNetworkWriteKBs() + getDataAverage(dataNode, col, numRows) / BASE_TO_CONVERT_BYTES_INTO_KILOBYTES); | ||||||
|                 } else if (param.matches("vbd_.*_read")) { |                 } else if (param.matches("vbd_.*_read")) { | ||||||
|                     vmStatsAnswer.setDiskReadKBs(vmStatsAnswer.getDiskReadKBs() + getDataAverage(dataNode, col, numRows) / 1000); |                     vmStatsAnswer.setDiskReadKBs(vmStatsAnswer.getDiskReadKBs() + getDataAverage(dataNode, col, numRows) / BASE_TO_CONVERT_BYTES_INTO_KILOBYTES); | ||||||
|                 } else if (param.matches("vbd_.*_write")) { |                 } else if (param.matches("vbd_.*_write")) { | ||||||
|                     vmStatsAnswer.setDiskWriteKBs(vmStatsAnswer.getDiskWriteKBs() + getDataAverage(dataNode, col, numRows) / 1000); |                     vmStatsAnswer.setDiskWriteKBs(vmStatsAnswer.getDiskWriteKBs() + getDataAverage(dataNode, col, numRows) / BASE_TO_CONVERT_BYTES_INTO_KILOBYTES); | ||||||
|  |                 } else if (param.contains("memory_internal_free")) { | ||||||
|  |                     vmStatsAnswer.setIntFreeMemoryKBs(vmStatsAnswer.getIntFreeMemoryKBs() + getDataAverage(dataNode, col, numRows) / BASE_TO_CONVERT_BYTES_INTO_KILOBYTES); | ||||||
|  |                 } else if (param.contains("memory_target")) { | ||||||
|  |                     vmStatsAnswer.setTargetMemoryKBs(vmStatsAnswer.getTargetMemoryKBs() + getDataAverage(dataNode, col, numRows) / BASE_TO_CONVERT_BYTES_INTO_KILOBYTES); | ||||||
|  |                 } else if (param.contains("memory")) { | ||||||
|  |                     vmStatsAnswer.setMemoryKBs(vmStatsAnswer.getMemoryKBs() + getDataAverage(dataNode, col, numRows) / BASE_TO_CONVERT_BYTES_INTO_KILOBYTES); | ||||||
|                 } |                 } | ||||||
|  | 
 | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -3346,6 +3355,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe | |||||||
|                 s_logger.debug("Vm cpu utilization " + vmStatsAnswer.getCPUUtilization()); |                 s_logger.debug("Vm cpu utilization " + vmStatsAnswer.getCPUUtilization()); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  | 
 | ||||||
|         return vmResponseMap; |         return vmResponseMap; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -27,9 +27,6 @@ import java.util.Set; | |||||||
| 
 | 
 | ||||||
| import javax.inject.Inject; | import javax.inject.Inject; | ||||||
| 
 | 
 | ||||||
| import org.apache.log4j.Logger; |  | ||||||
| import org.springframework.stereotype.Component; |  | ||||||
| 
 |  | ||||||
| import org.apache.cloudstack.affinity.AffinityGroupResponse; | import org.apache.cloudstack.affinity.AffinityGroupResponse; | ||||||
| import org.apache.cloudstack.api.ApiConstants.VMDetails; | import org.apache.cloudstack.api.ApiConstants.VMDetails; | ||||||
| import org.apache.cloudstack.api.ResponseObject.ResponseView; | import org.apache.cloudstack.api.ResponseObject.ResponseView; | ||||||
| @ -38,11 +35,12 @@ import org.apache.cloudstack.api.response.NicSecondaryIpResponse; | |||||||
| import org.apache.cloudstack.api.response.SecurityGroupResponse; | import org.apache.cloudstack.api.response.SecurityGroupResponse; | ||||||
| import org.apache.cloudstack.api.response.UserVmResponse; | import org.apache.cloudstack.api.response.UserVmResponse; | ||||||
| import org.apache.cloudstack.framework.config.dao.ConfigurationDao; | import org.apache.cloudstack.framework.config.dao.ConfigurationDao; | ||||||
|  | import org.apache.log4j.Logger; | ||||||
|  | import org.springframework.stereotype.Component; | ||||||
| 
 | 
 | ||||||
| import com.cloud.api.ApiDBUtils; | import com.cloud.api.ApiDBUtils; | ||||||
| import com.cloud.api.query.vo.UserVmJoinVO; | import com.cloud.api.query.vo.UserVmJoinVO; | ||||||
| import com.cloud.gpu.GPU; | import com.cloud.gpu.GPU; | ||||||
| import com.cloud.hypervisor.Hypervisor.HypervisorType; |  | ||||||
| import com.cloud.service.ServiceOfferingDetailsVO; | import com.cloud.service.ServiceOfferingDetailsVO; | ||||||
| import com.cloud.user.Account; | import com.cloud.user.Account; | ||||||
| import com.cloud.user.AccountManager; | import com.cloud.user.AccountManager; | ||||||
| @ -200,20 +198,16 @@ public class UserVmJoinDaoImpl extends GenericDaoBaseWithTagInformation<UserVmJo | |||||||
|             VmStats vmStats = ApiDBUtils.getVmStatistics(userVm.getId()); |             VmStats vmStats = ApiDBUtils.getVmStatistics(userVm.getId()); | ||||||
|             if (vmStats != null) { |             if (vmStats != null) { | ||||||
|                 userVmResponse.setCpuUsed(new DecimalFormat("#.##").format(vmStats.getCPUUtilization()) + "%"); |                 userVmResponse.setCpuUsed(new DecimalFormat("#.##").format(vmStats.getCPUUtilization()) + "%"); | ||||||
| 
 |  | ||||||
|                 userVmResponse.setNetworkKbsRead((long)vmStats.getNetworkReadKBs()); |                 userVmResponse.setNetworkKbsRead((long)vmStats.getNetworkReadKBs()); | ||||||
| 
 |  | ||||||
|                 userVmResponse.setNetworkKbsWrite((long)vmStats.getNetworkWriteKBs()); |                 userVmResponse.setNetworkKbsWrite((long)vmStats.getNetworkWriteKBs()); | ||||||
|  |                 userVmResponse.setDiskKbsRead((long)vmStats.getDiskReadKBs()); | ||||||
|  |                 userVmResponse.setDiskKbsWrite((long)vmStats.getDiskWriteKBs()); | ||||||
|  |                 userVmResponse.setDiskIORead((long)vmStats.getDiskReadIOs()); | ||||||
|  |                 userVmResponse.setDiskIOWrite((long)vmStats.getDiskWriteIOs()); | ||||||
|  |                 userVmResponse.setMemoryKBs((long)vmStats.getMemoryKBs()); | ||||||
|  |                 userVmResponse.setMemoryIntFreeKBs((long)vmStats.getIntFreeMemoryKBs()); | ||||||
|  |                 userVmResponse.setMemoryTargetKBs((long)vmStats.getTargetMemoryKBs()); | ||||||
| 
 | 
 | ||||||
|                 if ((userVm.getHypervisorType() != null) && (userVm.getHypervisorType().equals(HypervisorType.KVM) || userVm.getHypervisorType().equals(HypervisorType.XenServer))) { // support KVM and XenServer only util 2013.06.25 |  | ||||||
|                     userVmResponse.setDiskKbsRead((long)vmStats.getDiskReadKBs()); |  | ||||||
| 
 |  | ||||||
|                     userVmResponse.setDiskKbsWrite((long)vmStats.getDiskWriteKBs()); |  | ||||||
| 
 |  | ||||||
|                     userVmResponse.setDiskIORead((long)vmStats.getDiskReadIOs()); |  | ||||||
| 
 |  | ||||||
|                     userVmResponse.setDiskIOWrite((long)vmStats.getDiskWriteIOs()); |  | ||||||
|                 } |  | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -510,6 +510,9 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc | |||||||
|                                     statsInMemory.setDiskReadIOs(statsInMemory.getDiskReadIOs() + statsForCurrentIteration.getDiskReadIOs()); |                                     statsInMemory.setDiskReadIOs(statsInMemory.getDiskReadIOs() + statsForCurrentIteration.getDiskReadIOs()); | ||||||
|                                     statsInMemory.setDiskWriteIOs(statsInMemory.getDiskWriteIOs() + statsForCurrentIteration.getDiskWriteIOs()); |                                     statsInMemory.setDiskWriteIOs(statsInMemory.getDiskWriteIOs() + statsForCurrentIteration.getDiskWriteIOs()); | ||||||
|                                     statsInMemory.setDiskReadKBs(statsInMemory.getDiskReadKBs() + statsForCurrentIteration.getDiskReadKBs()); |                                     statsInMemory.setDiskReadKBs(statsInMemory.getDiskReadKBs() + statsForCurrentIteration.getDiskReadKBs()); | ||||||
|  |                                     statsInMemory.setMemoryKBs(statsForCurrentIteration.getMemoryKBs()); | ||||||
|  |                                     statsInMemory.setIntFreeMemoryKBs(statsForCurrentIteration.getIntFreeMemoryKBs()); | ||||||
|  |                                     statsInMemory.setTargetMemoryKBs(statsForCurrentIteration.getTargetMemoryKBs()); | ||||||
| 
 | 
 | ||||||
|                                     _VmStats.put(vmId, statsInMemory); |                                     _VmStats.put(vmId, statsInMemory); | ||||||
|                                 } |                                 } | ||||||
| @ -530,6 +533,10 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc | |||||||
|                                     metrics.put(externalStatsPrefix + "cloudstack.stats.instances." + vmName + ".disk.read_kbs", statsForCurrentIteration.getDiskReadKBs()); |                                     metrics.put(externalStatsPrefix + "cloudstack.stats.instances." + vmName + ".disk.read_kbs", statsForCurrentIteration.getDiskReadKBs()); | ||||||
|                                     metrics.put(externalStatsPrefix + "cloudstack.stats.instances." + vmName + ".disk.write_iops", statsForCurrentIteration.getDiskWriteIOs()); |                                     metrics.put(externalStatsPrefix + "cloudstack.stats.instances." + vmName + ".disk.write_iops", statsForCurrentIteration.getDiskWriteIOs()); | ||||||
|                                     metrics.put(externalStatsPrefix + "cloudstack.stats.instances." + vmName + ".disk.read_iops", statsForCurrentIteration.getDiskReadIOs()); |                                     metrics.put(externalStatsPrefix + "cloudstack.stats.instances." + vmName + ".disk.read_iops", statsForCurrentIteration.getDiskReadIOs()); | ||||||
|  |                                     metrics.put(externalStatsPrefix + "cloudstack.stats.instances." + vmName + ".memory.total_kbs", statsForCurrentIteration.getMemoryKBs()); | ||||||
|  |                                     metrics.put(externalStatsPrefix + "cloudstack.stats.instances." + vmName + ".memory.internalfree_kbs", statsForCurrentIteration.getIntFreeMemoryKBs()); | ||||||
|  |                                     metrics.put(externalStatsPrefix + "cloudstack.stats.instances." + vmName + ".memory.target_kbs", statsForCurrentIteration.getTargetMemoryKBs()); | ||||||
|  | 
 | ||||||
|                                 } |                                 } | ||||||
| 
 | 
 | ||||||
|                             } |                             } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user