Commit 0dd6ed5e authored by Antoine Millet's avatar Antoine Millet
Browse files

Implemented memallocratio tag

parent dbd39755
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -125,7 +125,7 @@ class Handler(HostHandler):

        # we must refresh those tags only when domains tags are registered to
        # have the calculated values
        for tag in ('cpualloc', 'cpurunning', 'cpuremaining', 'cpuallocratio', 'memalloc', 'memrunning', 'memremaining'):
        for tag in ('cpualloc', 'cpurunning', 'cpuremaining', 'cpuallocratio', 'memalloc', 'memrunning', 'memremaining', 'memallocratio'):
            self.tag_db['__main__'][tag].update_value()

        # register libvirt handlers
+9 −1
Original line number Diff line number Diff line
@@ -200,3 +200,11 @@ def memremaining(handl):
    mem = int(handl.tag_db['__main__']['mem'].value)
    memalloc = int(handl.tag_db['__main__']['memalloc'].value)
    return mem - memalloc


@_check_virt_connected
def memallocratio(handl):
    """Allocated memory ratio on the hypervisor."""
    mem = float(handl.tag_db['__main__']['mem'].value)
    memalloc = float(handl.tag_db['__main__']['memalloc'].value)
    return '%0.2f' % (memalloc / mem)
 No newline at end of file