[svn] r9737 - /trunk/tools/dstat/plugins/dstat_mem_adv.py

Dag Wieers dag at wieers.com
Fri Mar 4 11:39:07 CET 2011


Author: dag
Date: Fri Mar  4 10:39:07 2011
New Revision: 9737

URL: http://svn.rpmforge.net/viewvc/rpmforge?rev=9737&view=rev
Log:
Added external dstat_mem_adv plugin so show advanced memory counters (Damon Snyder)

Added:
    trunk/tools/dstat/plugins/dstat_mem_adv.py

Added: trunk/tools/dstat/plugins/dstat_mem_adv.py
URL: http://svn.rpmforge.net/viewvc/rpmforge/trunk/tools/dstat/plugins/dstat_mem_adv.py?rev=9737&view=markup
==============================================================================
--- trunk/tools/dstat/plugins/dstat_mem_adv.py (added)
+++ trunk/tools/dstat/plugins/dstat_mem_adv.py Fri Mar  4 10:39:07 2011
@@ -1,0 +1,22 @@
+### Authority: Damon Snyder <drsnyder$gmail,com>
+
+class dstat_plugin(dstat):
+    """
+    Advanced memory statistics
+
+    Displays various advanced memory counters from /proc/meminfo.
+    """
+
+    def __init__(self):
+        self.name = 'advanced memory usage'
+        self.nick = ('used', 'buff', 'cach', 'free', 'dirty')
+        self.vars = ('MemUsed', 'Buffers', 'Cached', 'MemFree', 'Dirty')
+        self.open('/proc/meminfo')
+
+    def extract(self):
+        for l in self.splitlines():
+            if len(l) < 2: continue
+            name = l[0].split(':')[0]
+            if name in self.vars + ('MemTotal', ):
+                self.val[name] = long(l[1]) * 1024.0
+        self.val['MemUsed'] = self.val['MemTotal'] - self.val['MemFree'] - self.val['Buffers'] - self.val['Cached']




More information about the commits mailing list