Tomoki Sekiyama has uploaded a new change for review.

Change subject: GuestMemory: Start memory stats collection on initialization
......................................................................

GuestMemory: Start memory stats collection on initialization

Specify update rate of memory stats of virtio balloon driver using
new libvirt API virDomainSetMemoryStatsPeriod.

Change-Id: If90ff472d57d54edc6f22baf2a41322cb9e79448
Signed-off-by: Tomoki Sekiyama <[email protected]>
---
M mom/Collectors/GuestMemory.py
M mom/HypervisorInterfaces/HypervisorInterface.py
M mom/HypervisorInterfaces/libvirtInterface.py
3 files changed, 20 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/mom refs/changes/99/19199/1

diff --git a/mom/Collectors/GuestMemory.py b/mom/Collectors/GuestMemory.py
index 02ab4d4..a96bfa0 100644
--- a/mom/Collectors/GuestMemory.py
+++ b/mom/Collectors/GuestMemory.py
@@ -29,6 +29,7 @@
         self.hypervisor_iface = properties['hypervisor_iface']
         self.uuid = properties['uuid']
         self.logger = logging.getLogger('mom.Collectors.GuestMemory')
+        self.hypervisor_iface.startVmMemoryStats(self.uuid)
         self.memstats_available = True
 
     def stats_error(self, msg):
diff --git a/mom/HypervisorInterfaces/HypervisorInterface.py 
b/mom/HypervisorInterfaces/HypervisorInterface.py
index d4e0e89..430dba8 100644
--- a/mom/HypervisorInterfaces/HypervisorInterface.py
+++ b/mom/HypervisorInterfaces/HypervisorInterface.py
@@ -35,6 +35,12 @@
         """
         pass
 
+    def startVmMemoryStats(self, uuid):
+        """
+        This method activates the memory statistics of a given guest.
+        """
+        pass
+
     def getVmMemoryStats(self, uuid):
         """
         This method returns the memory statistics of a given guest. The stat
diff --git a/mom/HypervisorInterfaces/libvirtInterface.py 
b/mom/HypervisorInterfaces/libvirtInterface.py
index d5df85d..7312e41 100644
--- a/mom/HypervisorInterfaces/libvirtInterface.py
+++ b/mom/HypervisorInterfaces/libvirtInterface.py
@@ -31,6 +31,7 @@
     def __init__(self, config):
         self.conn = None
         self.uri = config.get('main', 'libvirt-hypervisor-uri')
+        self.interval = config.getint('main', 'guest-monitor-interval')
         self.logger = logging.getLogger('mom.libvirtInterface')
         libvirt.registerErrorHandler(self._error_handler, None)
         self._connect()
@@ -132,6 +133,14 @@
             return None
         return int(matches[0])
 
+    def _domainSetMemoryStatsPeriod(self, domain, period):
+        try:
+            domain.setMemoryStatsPeriod(period)
+        except libvirt.libvirtError, e:
+            self._handleException(e)
+        except AttributeError, e:
+            pass # Older versions of libvirt don't have the method
+
     def _domainGetMemoryStats(self, domain):
         try:
             stats = domain.memoryStats()
@@ -179,6 +188,10 @@
             return None
         return data
 
+    def startVmMemoryStats(self, uuid):
+        domain = self._getDomainFromUUID(uuid)
+        self._domainSetMemoryStatsPeriod(domain, self.interval)
+
     def getVmMemoryStats(self, uuid):
         domain = self._getDomainFromUUID(uuid)
         # Try to collect memory stats.  This function may not be available


-- 
To view, visit http://gerrit.ovirt.org/19199
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If90ff472d57d54edc6f22baf2a41322cb9e79448
Gerrit-PatchSet: 1
Gerrit-Project: mom
Gerrit-Branch: master
Gerrit-Owner: Tomoki Sekiyama <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to