Skip to content
This repository
Browse code

Small updates

  • Loading branch information...
commit f6e972f9d08ab216cf412cb56d52138dae3b2bb9 1 parent a8b96b8
Dag Wieers authored

Showing 3 changed files with 36 additions and 43 deletions. Show diff stats Hide diff stats

  1. +1 0  ChangeLog
  2. +7 17 dstat
  3. +28 26 dstat15
1  ChangeLog
@@ -3,6 +3,7 @@
3 3 - Added -M list to show the list of available modules per path
4 4 - Fixed a bug in dpopen causing gpfs/gpfsop to fail after a while
5 5 - Change terminal title (if terminal supports it)
  6 +- Don't trim the cpulist to 2 items when -f (S�bastien Prud'homme)
6 7
7 8 * 0.6.0 - Bettiesbaai - released 29/05/2005
8 9 - Removed keyboard input prevention patch. (Dbt 304673, Marc Lehmann)
24 dstat
@@ -243,7 +243,7 @@ Dstat options:
243 243 --mods stat1,stat2
244 244
245 245 -a, --all equals -cdngy (default)
246   - -f, --full expand -D, -I and -N discovery lists
  246 + -f, --full expand -C, -D, -I and -N discovery lists
247 247 -v, --vmstat equals -pmgdsc -D total
248 248
249 249 --integer show integer values
@@ -452,7 +452,7 @@ class dstat_cpu(dstat):
452 452 while cpu < cpunr:
453 453 list.append(str(cpu))
454 454 cpu = cpu + 1
455   - if len(list) > 2: list = list[0:2]
  455 +# if len(list) > 2: list = list[0:2]
456 456 for name in list:
457 457 if name in self.discover(''):
458 458 ret.append(name)
@@ -513,7 +513,7 @@ class dstat_cpu24(dstat):
513 513 while cpu < cpunr:
514 514 list.append(str(cpu))
515 515 cpu = cpu + 1
516   - if len(list) > 2: list = list[0:2]
  516 +# if len(list) > 2: list = list[0:2]
517 517 for name in list:
518 518 if name in self.discover(''):
519 519 ret.append(name)
@@ -1488,18 +1488,16 @@ def getcpunr():
1488 1488 ### FIXME: Add scsi support too and improve
1489 1489 def sysfs_dev(device):
1490 1490 "Convert sysfs device names into device names"
1491   - ide_re = re.compile('ide/host([0-9])/bus([0-9])/target([0-9])/lun([0-9])/disc')
1492   - scsi_re = re.compile('placeholder')
1493   - m = ide_re.match(device)
  1491 + m = re.match('ide/host([0-9])/bus([0-9])/target([0-9])/lun([0-9])/disc', device)
1494 1492 if m:
1495 1493 l = m.groups()
1496 1494 # ide/host0/bus0/target0/lun0/disc -> 0 -> hda
1497 1495 # ide/host0/bus1/target0/lun0/disc -> 2 -> hdc
1498 1496 nr = int(l[1]) * 2 + int(l[3])
1499 1497 return 'hd' + chr(ord('a') + nr)
1500   - m = scsi_re.match(device)
  1498 + m = re.match('placeholder', device)
1501 1499 if m:
1502   - return 'scsi'
  1500 + return 'sdX'
1503 1501 return device
1504 1502
1505 1503 def scsi_dev(nr):
@@ -1542,7 +1540,6 @@ def exit(ret):
1542 1540 sys.stdout.write(ansi['reset'])
1543 1541 if 'signal' in sys.modules.keys():
1544 1542 signal.signal(signal.SIGALRM, signal.SIG_DFL)
1545   -# termios.tcsetattr(fd, termios.TCSADRAIN, old)
1546 1543 sys.exit(ret)
1547 1544
1548 1545 def listmodules():
@@ -1579,7 +1576,7 @@ def main():
1579 1576 user = getpass.getuser()
1580 1577 hostname = os.uname()[1].split('.')[0]
1581 1578 if re.compile('(screen|xterm*)').match(os.getenv('TERM')):
1582   - sys.stdout.write('\033]0;(%s@%s) %s %s\007' % (user, hostname, 'dstat', ' '.join(op.args)))
  1579 + sys.stdout.write('\033]0;(%s@%s) %s %s\007' % (user, hostname, os.path.basename(sys.argv[0]), ' '.join(op.args)))
1583 1580
1584 1581 if op.output:
1585 1582 if os.path.exists(op.output):
@@ -1771,13 +1768,6 @@ if __name__ == '__main__':
1771 1768 except:
1772 1769 pass
1773 1770
1774   - ### Prevent keyboard input
1775   -# fd = sys.stdin.fileno()
1776   -# old = termios.tcgetattr(fd)
1777   -# new = termios.tcgetattr(fd)
1778   -# new[3] = new[3] & ~termios.ECHO
1779   -# termios.tcsetattr(fd, termios.TCSADRAIN, new)
1780   -
1781 1771 op = Options(sys.argv[1:])
1782 1772 main()
1783 1773 except KeyboardInterrupt, e:
54 dstat15
@@ -18,11 +18,12 @@
18 18
19 19 try:
20 20 import sys, signal, os, re, time, string
21   - import types, signal, resource
22   - pwd = os.path.dirname(sys.argv[0])
  21 + import types, signal, resource, getpass
  22 + cwd = os.path.abspath(os.path.dirname(sys.argv[0]))
23 23 sys.path.insert(0, os.getenv('HOME') + '/.dstat/')
24   - sys.path.insert(1, pwd)
25   - sys.path.insert(2, pwd + '/plugins/')
  24 + if cwd in sys.path: sys.path.remove(cwd)
  25 + sys.path.insert(1, cwd)
  26 + sys.path.insert(2, cwd + '/plugins/')
26 27 sys.path.insert(3, '/usr/share/dstat/')
27 28 sys.path.insert(4, '/usr/local/share/dstat/')
28 29 except KeyboardInterrupt, e:
@@ -56,7 +57,7 @@ except NameError:
56 57 True = 1
57 58 False = 0
58 59
59   -VERSION = '0.6.0'
  60 +VERSION = '0.6.1'
60 61
61 62 class Options:
62 63 def __init__(self, args):
@@ -196,6 +197,11 @@ class Options:
196 197 print 'Processors: %d' % getcpunr()
197 198 print 'Pagesize: %d' % resource.getpagesize()
198 199 print 'Clock ticks per secs: %d' % os.sysconf('SC_CLK_TCK')
  200 + print
  201 +
  202 + global op
  203 + op = self
  204 + listmodules()
199 205
200 206 def usage(self):
201 207 print 'Usage: dstat [-afv] [options..] [delay [count]]'
@@ -230,7 +236,7 @@ Dstat options:
230 236 --mods stat1,stat2
231 237
232 238 -a, --all equals -cdngy (default)
233   - -f, --full expand -D, -I and -N discovery lists
  239 + -f, --full expand -C, -D, -I and -N discovery lists
234 240 -v, --vmstat equals -pmgdsc -D total
235 241
236 242 --integer show integer values
@@ -439,7 +445,7 @@ class dstat_cpu(dstat):
439 445 while cpu < cpunr:
440 446 list.append(str(cpu))
441 447 cpu = cpu + 1
442   - if len(list) > 2: list = list[0:2]
  448 +# if len(list) > 2: list = list[0:2]
443 449 for name in list:
444 450 if name in self.discover(''):
445 451 ret.append(name)
@@ -500,7 +506,7 @@ class dstat_cpu24(dstat):
500 506 while cpu < cpunr:
501 507 list.append(str(cpu))
502 508 cpu = cpu + 1
503   - if len(list) > 2: list = list[0:2]
  509 +# if len(list) > 2: list = list[0:2]
504 510 for name in list:
505 511 if name in self.discover(''):
506 512 ret.append(name)
@@ -1313,7 +1319,7 @@ def dpopen(cmd):
1313 1319 global pipes
1314 1320 if 'pipes' not in globals().keys(): pipes = {}
1315 1321 if cmd not in pipes.keys():
1316   - pipes[cmd] = os.popen3('/usr/lpp/mmfs/bin/mmpmon -p', 't', 0)
  1322 + pipes[cmd] = os.popen3(cmd, 't', 0)
1317 1323 return pipes[cmd]
1318 1324
1319 1325 def readpipe(file, tmout = 0.001):
@@ -1491,18 +1497,16 @@ def getcpunr():
1491 1497 ### FIXME: Add scsi support too and improve
1492 1498 def sysfs_dev(device):
1493 1499 "Convert sysfs device names into device names"
1494   - ide_re = re.compile('ide/host([0-9])/bus([0-9])/target([0-9])/lun([0-9])/disc')
1495   - scsi_re = re.compile('placeholder')
1496   - m = ide_re.match(device)
  1500 + m = re.match('ide/host([0-9])/bus([0-9])/target([0-9])/lun([0-9])/disc', device)
1497 1501 if m:
1498 1502 l = m.groups()
1499 1503 # ide/host0/bus0/target0/lun0/disc -> 0 -> hda
1500 1504 # ide/host0/bus1/target0/lun0/disc -> 2 -> hdc
1501 1505 nr = int(l[1]) * 2 + int(l[3])
1502 1506 return 'hd' + chr(ord('a') + nr)
1503   - m = scsi_re.match(device)
  1507 + m = re.match('placeholder', device)
1504 1508 if m:
1505   - return 'scsi'
  1509 + return 'sdX'
1506 1510 return device
1507 1511
1508 1512 def scsi_dev(nr):
@@ -1545,7 +1549,6 @@ def exit(ret):
1545 1549 sys.stdout.write(ansi['reset'])
1546 1550 if 'signal' in sys.modules.keys():
1547 1551 signal.signal(signal.SIGALRM, signal.SIG_DFL)
1548   -# termios.tcsetattr(fd, termios.TCSADRAIN, old)
1549 1552 sys.exit(ret)
1550 1553
1551 1554 def main():
@@ -1559,6 +1562,11 @@ def main():
1559 1562 # hz = os.sysconf('SC_CLK_TCK')
1560 1563 interval = 1
1561 1564
  1565 + user = getpass.getuser()
  1566 + hostname = string.split(os.uname()[1], '.')[0]
  1567 + if re.compile('(screen|xterm*)').match(os.getenv('TERM')):
  1568 + sys.stdout.write('\033]0;(%s@%s) %s %s\007' % (user, hostname, os.path.basename(sys.argv[0]), ' '.join(op.args)))
  1569 +
1562 1570 if op.output:
1563 1571 if os.path.exists(op.output):
1564 1572 outputfile = open(op.output, 'a', 0)
@@ -1568,9 +1576,7 @@ def main():
1568 1576 outputfile.write('"Dstat %s CSV output"\n' % VERSION)
1569 1577 outputfile.write('"Author:","Dag Wieers <dag@wieers.com>",,,,"URL:","http://dag.wieers.com/home-made/dstat/"\n')
1570 1578
1571   - ### FIXME: Get rid of socket()
1572   - import socket
1573   - outputfile.write('"Host:","%s"\n' % (socket.gethostbyaddr(socket.gethostname())[0]))
  1579 + outputfile.write('"Host:","%s",,,,"User:","%s"\n' % (hostname, user))
1574 1580 outputfile.write('"Cmdline:","dstat %s",,,,"Date:","%s"\n\n' % (' '.join(op.args), time.strftime('%d %b %Y %H:%M:%S %Z', time.localtime())))
1575 1581
1576 1582 ### Check terminal capabilities
@@ -1598,7 +1604,10 @@ def main():
1598 1604 oldvislist = []
1599 1605 totlist = []
1600 1606 for module in op.modlist:
1601   - if module == 'cpu': mods = ( 'cpu', 'cpu24' )
  1607 + if module in ('list', 'help'):
  1608 + listmodules()
  1609 + exit(0)
  1610 + elif module == 'cpu': mods = ( 'cpu', 'cpu24' )
1602 1611 elif module == 'disk': mods = ( 'disk', 'disk24', 'disk24old' )
1603 1612 elif module == 'int': mods = ( 'int', 'int24' )
1604 1613 elif module == 'page': mods = ( 'page', 'page24' )
@@ -1747,13 +1756,6 @@ if __name__ == '__main__':
1747 1756 except:
1748 1757 pass
1749 1758
1750   - ### Prevent keyboard input
1751   -# fd = sys.stdin.fileno()
1752   -# old = termios.tcgetattr(fd)
1753   -# new = termios.tcgetattr(fd)
1754   -# new[3] = new[3] & ~termios.ECHO
1755   -# termios.tcsetattr(fd, termios.TCSADRAIN, new)
1756   -
1757 1759 op = Options(sys.argv[1:])
1758 1760 main()
1759 1761 except KeyboardInterrupt, e:

0 comments on commit f6e972f

Please sign in to comment.
Something went wrong with that request. Please try again.