Changeset 765

Show
Ignore:
Timestamp:
03/09/07 02:27:03 (2 years ago)
Author:
hachi
Message:

iostat on linux doesn't output stats per-partition, only per device, so we try to upgrade partitions to real devices for matching when we detect them.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/filepaths-20070306/server/mogstored

    r764 r765  
    392392            } 
    393393            next unless $init; 
    394             if (m/^ (\S+) .*? ([\d.]+)$/x) { 
     394            if (m/^ (\S+) .*? ([\d.]+) \n/x) { 
    395395                my ($devnode, $util) = ("/dev/$1", $2); 
    396396                unless (exists $dev_sysid->{$devnode}) { 
     
    434434        $map->{$mogdevid} = $osdevid; 
    435435    } 
     436 
     437    if (lc($^O) eq 'linux') { 
     438        my %name_to_number; 
     439        my %number_to_name; 
     440 
     441        if (open my $partitions, '<', '/proc/partitions') { 
     442            <$partitions>; <$partitions>; # First two lines are for humans 
     443            while (my $line = <$partitions>) { 
     444                my ($major, $minor, undef, $devname) = split /\s+/, $line; 
     445                my $devno = ($major << 8) + $minor; 
     446                $name_to_number{$devname} = $devno; 
     447                $number_to_name{$devno} = $devname; 
     448            } 
     449        } else { 
     450            warn "Unable to open /proc/partitions: $!"; 
     451        } 
     452 
     453        foreach my $mogdevid (keys %$map) { 
     454            my $original = $map->{$mogdevid}; 
     455            my $devname = $number_to_name{$original} or next; 
     456            if (my ($new) = $devname =~ m/^([hs]d\w)\d+$/) { 
     457                next unless $name_to_number{$new}; 
     458                $map->{$mogdevid} = $name_to_number{$new}; 
     459            } 
     460        } 
     461    } 
    436462    return $map; 
    437463}