Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added termtitle support

  • Loading branch information...
commit 15f90d624a96e5e1aa4508a644a8762333d012c2 1 parent 1416000
@dagwieers authored
Showing with 8 additions and 4 deletions.
  1. +1 −0  ChangeLog
  2. +7 −4 dstat
View
1  ChangeLog
@@ -2,6 +2,7 @@
- Look for plugins in ~/.dstat/ too
- Added -M list to show the list of available modules per path
- Fixed a bug in dpopen causing gpfs/gpfsop to fail after a while
+- Change terminal title (if terminal supports it)
* 0.6.0 - Bettiesbaai - released 29/05/2005
- Removed keyboard input prevention patch. (Dbt 304673, Marc Lehmann)
View
11 dstat
@@ -18,7 +18,7 @@ from __future__ import generators
try:
import sys, signal, os, re, time
- import types, signal, resource
+ import types, signal, resource, getpass
cwd = os.path.abspath(os.path.dirname(sys.argv[0]))
sys.path.insert(0, os.getenv('HOME') + '/.dstat/')
if cwd in sys.path: sys.path.remove(cwd)
@@ -1575,6 +1575,11 @@ def main():
# hz = os.sysconf('SC_CLK_TCK')
interval = 1
+ user = getpass.getuser()
+ hostname = os.uname()[1].split('.')[0]
+ if re.compile('(screen|xterm*)').match(os.getenv('TERM')):
+ sys.stdout.write('\033]0;(%s@%s) %s %s\007' % (user, hostname, 'dstat', ' '.join(op.args)))
+
if op.output:
if os.path.exists(op.output):
outputfile = open(op.output, 'a', 0)
@@ -1584,9 +1589,7 @@ def main():
outputfile.write('"Dstat %s CSV output"\n' % VERSION)
outputfile.write('"Author:","Dag Wieers <dag@wieers.com>",,,,"URL:","http://dag.wieers.com/home-made/dstat/"\n')
- ### FIXME: Get rid of socket()
- import socket
- outputfile.write('"Host:","%s"\n' % (socket.gethostbyaddr(socket.gethostname())[0]))
+ outputfile.write('"Host:","%s",,,,"User:","%s"\n' % (hostname, user))
outputfile.write('"Cmdline:","dstat %s",,,,"Date:","%s"\n\n' % (' '.join(op.args), time.strftime('%d %b %Y %H:%M:%S %Z', time.localtime())))
### Check terminal capabilities
Please sign in to comment.
Something went wrong with that request. Please try again.