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