[svn] r5921 - trunk/tools/dstat/plugins
packagers at lists.rpmforge.net
packagers at lists.rpmforge.net
Mon Oct 15 02:28:21 CEST 2007
Author: dag
Date: 2007-10-15 02:28:21 +0200 (Mon, 15 Oct 2007)
New Revision: 5921
Modified:
trunk/tools/dstat/plugins/dstat_topbio.py
trunk/tools/dstat/plugins/dstat_topcpu.py
trunk/tools/dstat/plugins/dstat_topio.py
trunk/tools/dstat/plugins/dstat_topmem.py
trunk/tools/dstat/plugins/dstat_topoom.py
Log:
More updates
Modified: trunk/tools/dstat/plugins/dstat_topbio.py
===================================================================
--- trunk/tools/dstat/plugins/dstat_topbio.py 2007-10-15 00:06:45 UTC (rev 5920)
+++ trunk/tools/dstat/plugins/dstat_topbio.py 2007-10-15 00:28:21 UTC (rev 5921)
@@ -9,7 +9,7 @@
class dstat_topbio(dstat):
def __init__(self):
self.name = 'most expensive'
- self.format = ('s', 22, 1024)
+ self.format = ('s', 22, 0)
self.nick = ('block i/o process',)
self.vars = self.nick
self.pid = str(os.getpid())
Modified: trunk/tools/dstat/plugins/dstat_topcpu.py
===================================================================
--- trunk/tools/dstat/plugins/dstat_topcpu.py 2007-10-15 00:06:45 UTC (rev 5920)
+++ trunk/tools/dstat/plugins/dstat_topcpu.py 2007-10-15 00:28:21 UTC (rev 5921)
@@ -9,7 +9,7 @@
class dstat_topcpu(dstat):
def __init__(self):
self.name = 'most expensive'
- self.format = ('s', 16, 34)
+ self.format = ('s', 16, 0)
self.nick = ('cpu process',)
self.vars = self.nick
self.pid = str(os.getpid())
@@ -39,6 +39,9 @@
### Is it a new topper ?
if usage < self.val['max']: continue
+ ### Extract name
+ name = l[1][1:-1]
+
### Get commandline
m = string.split(open('/proc/%s/cmdline' % pid).read(), '\0')
if len(m) > 1:
@@ -49,11 +52,10 @@
except IOError:
continue
- ### Get the process that spends the most jiffies
+ self.val['cmd'] = cmd
self.val['max'] = usage
- self.val['name'] = l[1][1:-1]
+ self.val['name'] = name
self.val['pid'] = pid
- self.val['cmd'] = cmd
# st = os.stat("/proc/%s" % pid)
# if st:
# pw = pwd.getpwuid(st.st_uid)
@@ -69,7 +71,7 @@
else:
### If the name is a known interpreter, take the second argument from the cmdline
if self.val['name'] in ('bash', 'csh', 'ksh', 'perl', 'python', 'sh'):
- self.val['process'] = os.path.basename(cmd)
+ self.val['process'] = self.val['cmd']
else:
self.val['process'] = self.val['name']
Modified: trunk/tools/dstat/plugins/dstat_topio.py
===================================================================
--- trunk/tools/dstat/plugins/dstat_topio.py 2007-10-15 00:06:45 UTC (rev 5920)
+++ trunk/tools/dstat/plugins/dstat_topio.py 2007-10-15 00:28:21 UTC (rev 5921)
@@ -9,7 +9,7 @@
class dstat_topio(dstat):
def __init__(self):
self.name = 'most expensive'
- self.format = ('s', 22, 1024)
+ self.format = ('s', 22, 0)
self.nick = ('i/o process',)
self.vars = self.nick
self.pid = str(os.getpid())
@@ -72,10 +72,8 @@
### If the name is a known interpreter, take the second argument from the cmdline
if self.val['name'] in ('bash', 'csh', 'ksh', 'perl', 'python', 'sh'):
### Using dopen() will cause too many open files
-# l = string.split(dopen('/proc/%s/cmdline' % self.val['pid']).read(), '\0')
l = string.split(open('/proc/%s/cmdline' % self.val['pid']).read(), '\0')
- if len(l) > 2:
- self.val['process'] = os.path.basename(l[1])
+ self.val['process'] = os.path.basename(l[len(l)-1])
else:
self.val['process'] = self.val['name']
Modified: trunk/tools/dstat/plugins/dstat_topmem.py
===================================================================
--- trunk/tools/dstat/plugins/dstat_topmem.py 2007-10-15 00:06:45 UTC (rev 5920)
+++ trunk/tools/dstat/plugins/dstat_topmem.py 2007-10-15 00:28:21 UTC (rev 5921)
@@ -37,7 +37,7 @@
name = l[1][1:-1]
### Get commandline
- m = string.split(open('/proc/%s/cmdline' % pid).read(),'\0')
+ m = string.split(open('/proc/%s/cmdline' % pid).read(), '\0')
if len(m) > 1:
cmd = os.path.basename(m[1])
@@ -46,7 +46,7 @@
except IOError:
continue
- ### Get the process that uses the most memory
+ self.val['cmd'] = cmd
self.val['max'] = usage
self.val['name'] = name
self.val['pid'] = pid
@@ -56,7 +56,7 @@
else:
### If the name is a known interpreter, take the second argument from the cmdline
if self.val['name'] in ('bash', 'csh', 'ksh', 'perl', 'python', 'sh'):
- self.val['process'] = os.path.basename(cmd)
+ self.val['process'] = self.val['cmd']
else:
self.val['process'] = self.val['name']
Modified: trunk/tools/dstat/plugins/dstat_topoom.py
===================================================================
--- trunk/tools/dstat/plugins/dstat_topoom.py 2007-10-15 00:06:45 UTC (rev 5920)
+++ trunk/tools/dstat/plugins/dstat_topoom.py 2007-10-15 00:28:21 UTC (rev 5921)
@@ -9,7 +9,7 @@
class dstat_topoom(dstat):
def __init__(self):
self.name = 'out of memory'
- self.format = ('s', 18, 1000)
+ self.format = ('s', 18, 0)
self.nick = ('kill score',)
self.vars = self.nick
self.pid = str(os.getpid())
@@ -36,7 +36,7 @@
oom_score = int(l[0])
### Is it a new topper ?
- if oom_score < self.val['max']: continue
+ if oom_score < self.val['max']: continue
### Extract name
l = string.split(open('/proc/%s/stat' % pid).read())
@@ -52,23 +52,22 @@
except IOError:
continue
- ### Get the process that spends the most jiffies
+ self.val['cmd'] = cmd
self.val['max'] = oom_score
self.val['name'] = name
self.val['pid'] = pid
- self.val['cmd'] = cmd
if self.val['max'] == 0.0:
self.val['process'] = ''
else:
### If the name is a known interpreter, take the second argument from the cmdline
if self.val['name'] in ('bash', 'csh', 'ksh', 'perl', 'python', 'sh'):
- self.val['process'] = os.path.basename(cmd)
+ self.val['process'] = self.val['cmd']
else:
self.val['process'] = self.val['name']
### Debug (show PID)
-# self.val['process'] = '%*s %-*s' % (5, self.val['pid'], self.format[1]-6, self.val['name'])
+# self.val['process'] = '%*s %-*s' % (5, self.val['pid'], self.format[1]-6, self.val['name'])
def show(self):
if self.val['max'] == 0.0:
More information about the svn-commits
mailing list