You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2021/11/02 12:15:27 UTC

[GitHub] [cloudstack] sureshanaparti commented on a change in pull request #5633: Fix metrics stats for VMs not running

sureshanaparti commented on a change in pull request #5633:
URL: https://github.com/apache/cloudstack/pull/5633#discussion_r740997586



##########
File path: server/src/main/java/com/cloud/server/StatsCollector.java
##########
@@ -1485,6 +1487,32 @@ private void storeVirtualMachineStatsInMemory(VmStatsEntry statsForCurrentIterat
         }
     }
 
+    /**
+     * Removes stats for a given virtual machine.
+     * @param vmId ID of the virtual machine to remove stats.
+     */
+    public void removeVirtualMachineStats(Long vmId) {
+        s_logger.debug(String.format("Removing stats from VM with ID: %s .",vmId));
+        _VmStats.remove(vmId);
+    }
+
+    /**
+     * Removes stats of virtual machines that are not running from memory.
+     */
+    protected void cleanUpVirtualMachineStats() {
+        List<Long> allRunningVmIds = new ArrayList<Long>();
+        for (UserVmVO vm : _userVmDao.listAllRunning()) {

Review comment:
       VM stats are captured for running VMs only
   https://github.com/apache/cloudstack/blob/a78af608144f80649c409ebd933265d2d755f289/server/src/main/java/com/cloud/server/StatsCollector.java#L579
   
    _removeVirtualMachineStats()_  removes the vm stat if the VM is stopped/destroyed after adding to the stats, so no need for this cleanup method.
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org