#!/usr/bin/perl my %lastdata=(); my $count=0; my $cmd="dmsetup status --target cache " . join(" ", @ARGV); while(1) { printf("device mpct cpct r_hit r_miss rpct w_hit w_miss wpct prm dem dirt\n") if scalar(@ARGV) != 1 || !$count++; my @alldata=`$cmd`; foreach my $data(@alldata) { my $dev; if(scalar(@ARGV) == 1) { $dev=$ARGV[0]; $dev =~ s/^.+\/[^\/]+$//; } else { $data =~ s/^(\S+)://; $dev=$1; } if(length($dev) > 15) { $dev=substr($dev,0,15); } $data =~ s/^[0-9 ]+ cache //; #print $data; chomp $data; my @data=split / /,$data; my @curdata=(); # From what I can tell: # Read hits come from SSD only # Read misses come from HDD # Promotions cause SSD writes # Demotions do nothing # Dirty blocks need writeback # Data line: #metabsize metaused/total databsize dataused/total rhit rmiss whit wmiss demotions promotions dirty nfeature feature ncore ncorekeyval corekey0 coreval0 ... policyname npolicyarg policykey0 policyarg0 ... #8 1631/51200 256 162410/819200 6361491 22705424 50094334 10653259 0 162410 0 1 writeback 2 migration_threshold 2048 mq 10 random_threshold 4 sequential_threshold 512 discard_promote_adjustment 1 read_promote_adjustment 4 write_promote_adjustment 8 if(!scalar(@{$lastdata{$dev}})) { push @curdata, eval "($data[1]) * 100"; push @curdata, eval "($data[3]) * 100"; push @curdata, $data[4]; push @curdata, $data[5]; push @curdata, $data[6]; push @curdata, $data[7]; push @curdata, $data[8]; push @curdata, $data[9]; push @curdata, $data[10]; } else { push @curdata, eval "($data[1]) * 100"; push @curdata, eval "($data[3]) * 100"; push @curdata, $data[4]-$lastdata{$dev}[4]; push @curdata, $data[5]-$lastdata{$dev}[5]; push @curdata, $data[6]-$lastdata{$dev}[6]; push @curdata, $data[7]-$lastdata{$dev}[7]; push @curdata, $data[8]-$lastdata{$dev}[8]; push @curdata, $data[9]-$lastdata{$dev}[9]; push @curdata, $data[10]; } @{$lastdata{$dev}}=@data; printf("%-15s %5.1f %5.1f % 6d % 6d %5.1f % 6d % 6d %5.1f %3d %3d %4d\n", $dev, $curdata[0], $curdata[1], $curdata[2], $curdata[3], (($curdata[3]||$curdata[2])?100*$curdata[2]/($curdata[3]+$curdata[2]):0), $curdata[4], $curdata[5], (($curdata[5]||$curdata[4])?100*$curdata[4]/($curdata[5]+$curdata[4]):0), $curdata[6], $curdata[7], $curdata[8]); } print "\n" if scalar(@ARGV) != 1; $count=0 if $count>24; sleep 1; }