[svn] r9738 - in /trunk/tools/dstat: ChangeLog dstat plugins/dstat_mem_adv.py

Dag Wieers dag at wieers.com
Fri Mar 4 16:25:40 CET 2011


Author: dag
Date: Fri Mar  4 15:25:40 2011
New Revision: 9738

URL: http://svn.rpmforge.net/viewvc/rpmforge?rev=9738&view=rev
Log:
Allow more variables (self.vars) than nicknames (self.nick) to simplify plugins

Modified:
    trunk/tools/dstat/ChangeLog
    trunk/tools/dstat/dstat
    trunk/tools/dstat/plugins/dstat_mem_adv.py

Modified: trunk/tools/dstat/ChangeLog
URL: http://svn.rpmforge.net/viewvc/rpmforge/trunk/tools/dstat/ChangeLog?rev=9738&r1=9737&r2=9738&view=diff
==============================================================================
--- trunk/tools/dstat/ChangeLog (original)
+++ trunk/tools/dstat/ChangeLog Fri Mar  4 15:25:40 2011
@@ -10,6 +10,7 @@
 - Fix warning message when colors are disabled because TERM is not found (Ulp 660181)
 - Fix typo in dstat_nfs3_ops and dstat_nfsd3_ops (Chris Larsson)
 - Added external dstat_mem_adv plugin so show advanced memory counters (Damon Snyder)
+- Allow more variables (self.vars) than nicknames (self.nick) to simplify plugins
 
 * 0.7.2 - Real soon now - release 15/06/2010
 - Added external dstat_disk_tps plugin to show transactions per second

Modified: trunk/tools/dstat/dstat
URL: http://svn.rpmforge.net/viewvc/rpmforge/trunk/tools/dstat/dstat?rev=9738&r1=9737&r2=9738&view=diff
==============================================================================
--- trunk/tools/dstat/dstat (original)
+++ trunk/tools/dstat/dstat Fri Mar  4 15:25:40 2011
@@ -509,6 +509,8 @@
         if hasattr(self, 'output'):
             return cprint(self.output, self.type, self.width, self.scale)
         for i, name in enumerate(self.vars):
+            ### Make sure we don't show more values than we have nicknames
+            if i >= len(self.nick): break
             if isinstance(self.val[name], types.TupleType) or isinstance(self.val[name], types.ListType):
                 line = line + cprintlist(self.val[name], self.type, self.width, self.scale)
                 sep = theme['frame'] + char['colon']

Modified: trunk/tools/dstat/plugins/dstat_mem_adv.py
URL: http://svn.rpmforge.net/viewvc/rpmforge/trunk/tools/dstat/plugins/dstat_mem_adv.py?rev=9738&r1=9737&r2=9738&view=diff
==============================================================================
--- trunk/tools/dstat/plugins/dstat_mem_adv.py (original)
+++ trunk/tools/dstat/plugins/dstat_mem_adv.py Fri Mar  4 15:25:40 2011
@@ -10,13 +10,13 @@
     def __init__(self):
         self.name = 'advanced memory usage'
         self.nick = ('used', 'buff', 'cach', 'free', 'dirty')
-        self.vars = ('MemUsed', 'Buffers', 'Cached', 'MemFree', 'Dirty')
+        self.vars = ('MemUsed', 'Buffers', 'Cached', 'MemFree', 'Dirty', 'MemTotal')
         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', ):
+            if name in self.vars:
                 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