[SVN] r3020 - trunk/tools/dstat

svn-commits at rpmforge.net svn-commits at rpmforge.net
Wed Mar 16 01:28:22 CET 2005


Author: dag
Date: 2005-03-16 01:28:19 +0100 (Wed, 16 Mar 2005)
New Revision: 3020

Modified:
   trunk/tools/dstat/ChangeLog
   trunk/tools/dstat/dstat
   trunk/tools/dstat/dstat.spec
Log:
Updates

Modified: trunk/tools/dstat/ChangeLog
===================================================================
--- trunk/tools/dstat/ChangeLog	2005-03-15 13:27:58 UTC (rev 3019)
+++ trunk/tools/dstat/ChangeLog	2005-03-16 00:28:19 UTC (rev 3020)
@@ -1,3 +1,7 @@
+* 0.5.9
+- Make default list total lists (cpu, disk, net)
+- Fix clearline ANSI to work on older rxvt (0.6.4) (Joshua Rodman)
+
 * 0.5.8
 - Added user stats using python-utmp
 - Bail out if all requested stats fail

Modified: trunk/tools/dstat/dstat
===================================================================
--- trunk/tools/dstat/dstat	2005-03-15 13:27:58 UTC (rev 3019)
+++ trunk/tools/dstat/dstat	2005-03-16 00:28:19 UTC (rev 3020)
@@ -19,7 +19,7 @@
 import os, sys, re, getopt, time, termios
 import ConfigParser, urlparse, signal, resource
 
-VERSION = '0.5.8'
+VERSION = '0.5.9'
 
 enable = ('yes', 'on', 'true', '1')
 disable = ('no', 'off', 'false', '0')
@@ -405,7 +405,15 @@
 		if op.cpulist:
 			list = op.cpulist
 		else:
-			list = ('', )
+			if not op.full:
+				list = ('', )
+			else:
+				list = []
+				cpu = 0
+				while cpu < cpunr:
+					list.append(str(cpu))
+					cpu = cpu + 1
+				if len(list) > 2: list = list[0:2]
 		for name in list:
 			if name in self.discover(''):
 				ret.append(name)
@@ -456,7 +464,15 @@
 		if op.cpulist:
 			list = op.cpulist
 		else:
-			list = ('',)
+			if not op.full:
+				list = ('', )
+			else:
+				list = []
+				cpu = 0
+				while cpu < cpunr:
+					list.append(str(cpu))
+					cpu = cpu + 1
+				if len(list) > 2: list = list[0:2]
 		for name in list:
 			if name in self.discover(''):
 				ret.append(name)
@@ -513,9 +529,12 @@
 		if op.disklist:
 			list = op.disklist
 		else:
-			list = self.discover()
-			if not op.full and len(list) > 2: list = list[0:2]
-			list.sort()
+			if not op.full:
+				list = ('total', )
+			else:
+				list = self.discover()
+				if len(list) > 2: list = list[0:2]
+				list.sort()
 		for name in list:
 			if name in self.discover('total') + self.diskset.keys():
 				ret.append(name)
@@ -561,9 +580,12 @@
 		if op.disklist:
 			list = op.disklist
 		else:
-			list = self.discover()
-			if not op.full and len(list) > 2: list = list[0:2]
-			list.sort()
+			if not op.full:
+				list = ('total', )
+			else:
+				list = self.discover()
+				if len(list) > 2: list = list[0:2]
+				list.sort()
 		for name in list:
 			if name in self.discover('total') + self.diskset.keys():
 				ret.append(name)
@@ -703,7 +725,7 @@
 		if os.path.exists('/proc/interrupts'):
 			for line in open('/proc/interrupts', 'r').readlines():
 				l = line.split()
-				if len(l) < procs+1: continue
+				if len(l) < cpunr+1: continue
 				name = l[0].split(':')[0]
 				if long(l[1]) > 10:
 					ret.append(name)
@@ -735,15 +757,15 @@
 	def stats(self):
 		for line in open('/proc/interrupts', 'r').readlines():
 			l = line.split()
-			if len(l) < procs+1: continue
+			if len(l) < cpunr+1: continue
 			name = l[0].split(':')[0]
 			if name in self.vars:
 				self.cn2[name] = 0
-				for i in l[1:1+procs]:
+				for i in l[1:1+cpunr]:
 					self.cn2[name] = self.cn2[name] + long(i)
-#			elif len(l) > 2 + procs:
+#			elif len(l) > 2 + cpunr:
 #				for hw in self.vars:
-#					for mod in l[2+procs:]:
+#					for mod in l[2+cpunr:]:
 #						self.cn2[mod] = long(l[1])
 		if update:
 			for name in self.cn2.keys():
@@ -830,8 +852,12 @@
 		if op.netlist:
 			list = op.netlist
 		else:
-			list = self.discover()
-			if not op.full and len(list) > 2: list = list[0:2]
+			if not op.full:
+				list = ('total', )
+			else:
+				list = self.discover()
+				if len(list) > 2: list = list[0:2]
+				list.sort()
 		for name in list:
 			if name in self.discover('total'):
 				ret.append(name)
@@ -1122,7 +1148,8 @@
 	'underline': '\033[4m',
 
 	'clear': '\033[2J',
-	'clearline': '\033[K',
+#	'clearline': '\033[K',
+	'clearline': '\033[2K',
 #	'save': '\033[s',
 #	'restore': '\033[u',
 	'save': '\0337',
@@ -1242,11 +1269,11 @@
 			return 25, 80
 
 def getcpunr():
-	procs = -1
+	cpunr = -1
 	for line in open('/proc/stat', 'r').readlines():
 		if line[0:3] == 'cpu':
-			procs = procs + 1
-	return procs
+			cpunr = cpunr + 1
+	return cpunr
 
 def scsidev(nr):
 	if nr < 26:
@@ -1277,12 +1304,12 @@
 	signal.alarm(interval)
 
 def main():
-	global update, loop, step, pagesize, procs, ansi, interval, outputfile
+	global update, loop, step, pagesize, cpunr, ansi, interval, outputfile
 
 	loop = update = 0
 	step = op.delay
 	pagesize = resource.getpagesize()
-	procs = getcpunr()
+	cpunr = getcpunr()
 #	hz = os.sysconf('SC_CLK_TCK')
 	interval = 1
 

Modified: trunk/tools/dstat/dstat.spec
===================================================================
--- trunk/tools/dstat/dstat.spec	2005-03-15 13:27:58 UTC (rev 3019)
+++ trunk/tools/dstat/dstat.spec	2005-03-16 00:28:19 UTC (rev 3020)
@@ -9,7 +9,7 @@
 
 Summary: Versatile vmstat, iostat and ifstat replacement
 Name: dstat
-Version: 0.5.8
+Version: 0.5.9
 Release: 1
 License: GPL
 Group: System Environment/Base




More information about the commits mailing list