|
|
465c2f |
diff -up dstat-0.7.2/dstat.disk-path dstat-0.7.2/dstat
|
|
|
465c2f |
--- dstat-0.7.2/dstat.disk-path 2011-12-12 17:25:23.000000000 +0100
|
|
|
465c2f |
+++ dstat-0.7.2/dstat 2011-12-12 16:15:33.000000000 +0100
|
|
|
465c2f |
@@ -130,7 +130,7 @@ class Options:
|
|
|
465c2f |
elif opt in ['-d']:
|
|
|
465c2f |
self.plugins.append('disk')
|
|
|
465c2f |
elif opt in ['-D']:
|
|
|
465c2f |
- self.disklist = arg.split(',')
|
|
|
465c2f |
+ self.disklist = self.get_disklist(arg)
|
|
|
465c2f |
elif opt in ['--filesystem']:
|
|
|
465c2f |
self.plugins.append('fs')
|
|
|
465c2f |
elif opt in ['-g']:
|
|
|
465c2f |
@@ -240,6 +240,32 @@ class Options:
|
|
|
465c2f |
print 'dstat: delay must be an integer, greater than zero'
|
|
|
465c2f |
sys.exit(1)
|
|
|
465c2f |
|
|
|
465c2f |
+ def get_disklist(self, disks):
|
|
|
465c2f |
+ disklist = disks.split(',')
|
|
|
465c2f |
+ ret = []
|
|
|
465c2f |
+ for disk in disklist:
|
|
|
465c2f |
+ # e.g. /dev/sda1
|
|
|
465c2f |
+ if disk[:5] == '/dev/':
|
|
|
465c2f |
+ # file or symlink
|
|
|
465c2f |
+ if os.path.exists(disk):
|
|
|
465c2f |
+ # e.g. /dev/disk/by-uuid/15e40cc5-85de-40ea-b8fb-cb3a2eaf872
|
|
|
465c2f |
+ if os.path.islink(disk):
|
|
|
465c2f |
+ target = os.readlink(disk)
|
|
|
465c2f |
+ # convert relative pathname to absolute
|
|
|
465c2f |
+ if target[0] != '/':
|
|
|
465c2f |
+ target = os.path.join(os.path.dirname(disk), target)
|
|
|
465c2f |
+ target = os.path.normpath(target)
|
|
|
465c2f |
+ print 'dstat: symlink %s -> %s' % (disk, target)
|
|
|
465c2f |
+ disk = target
|
|
|
465c2f |
+ # trim leading /dev/
|
|
|
465c2f |
+ disk = disk[5:]
|
|
|
465c2f |
+ ret.append(disk)
|
|
|
465c2f |
+ else:
|
|
|
465c2f |
+ print 'dstat: %s does not exist' % disk
|
|
|
465c2f |
+ else:
|
|
|
465c2f |
+ ret.append(disk)
|
|
|
465c2f |
+ return ret
|
|
|
465c2f |
+
|
|
|
465c2f |
def version(self):
|
|
|
465c2f |
print 'Dstat %s' % VERSION
|
|
|
465c2f |
print 'Written by Dag Wieers <dag@wieers.com>'
|