Skip to content
This repository has been archived by the owner on Nov 26, 2020. It is now read-only.

Commit

Permalink
More updates
Browse files Browse the repository at this point in the history
  • Loading branch information
dagwieers committed Oct 15, 2007
1 parent 0ab84bf commit 1a00a4b
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion plugins/dstat_topbio.py
Expand Up @@ -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())
Expand Down
12 changes: 7 additions & 5 deletions plugins/dstat_topcpu.py
Expand Up @@ -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())
Expand Down Expand Up @@ -39,6 +39,9 @@ def extract(self):
### 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:
Expand All @@ -49,11 +52,10 @@ def extract(self):
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)
Expand All @@ -69,7 +71,7 @@ def extract(self):
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']

Expand Down
6 changes: 2 additions & 4 deletions plugins/dstat_topio.py
Expand Up @@ -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())
Expand Down Expand Up @@ -72,10 +72,8 @@ def extract(self):
### 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']

Expand Down
6 changes: 3 additions & 3 deletions plugins/dstat_topmem.py
Expand Up @@ -37,7 +37,7 @@ def extract(self):
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])

Expand All @@ -46,7 +46,7 @@ def extract(self):
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
Expand All @@ -56,7 +56,7 @@ def extract(self):
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']

Expand Down
11 changes: 5 additions & 6 deletions plugins/dstat_topoom.py
Expand Up @@ -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())
Expand All @@ -36,7 +36,7 @@ def extract(self):
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())
Expand All @@ -52,23 +52,22 @@ def extract(self):
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:
Expand Down

0 comments on commit 1a00a4b

Please sign in to comment.