Commit aeb2a583 authored by Antoine Millet's avatar Antoine Millet

Fixed tags with psutil 3 new API

parent 7fd823b1
......@@ -66,35 +66,51 @@ def cpuuse():
# memory related tags
def mem():
"""Total physical memory available on system."""
return unicode(psutil.avail_phymem() + psutil.used_phymem())
if hasattr(psutil, 'avail_phymem') and hasattr(psutil, 'used_phymem'):
return unicode(psutil.avail_phymem() + psutil.used_phymem())
else:
memory = psutil.virtual_memory()
return unicode(memory.available + memory.used)
@ttl(5)
@refresh(10)
def memfree():
"""Available physical memory on system."""
return unicode(psutil.avail_phymem())
if hasattr(psutil, 'avail_phymem'):
return unicode(psutil.avail_phymem())
else:
return unicode(psutil.virtual_memory().available)
@ttl(5)
@refresh(10)
def memused():
"""Used physical memory on system."""
return unicode(psutil.used_phymem())
if hasattr(psutil, 'used_phymem'):
return unicode(psutil.used_phymem())
else:
return unicode(psutil.virtual_memory().used)
@ttl(5)
@refresh(10)
def membuffers():
"""Buffers memory use."""
return unicode(psutil.phymem_buffers())
if hasattr(psutil, 'phymem_buffers'):
return unicode(psutil.phymem_buffers())
else:
return unicode(psutil.virtual_memory().buffers)
@ttl(5)
@refresh(10)
def memcache():
"""Caches memory use."""
return unicode(psutil.cached_phymem())
if hasattr(psutil, 'cached_phymem'):
return unicode(psutil.cached_phymem())
else:
return unicode(psutil.virtual_memory().cached)
# disks related tags
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment