Commit 0928d9c2 authored by Fulvio Galeazzi's avatar Fulvio Galeazzi
Browse files

2018-04-05: FG; fixed performance OSD data for Luminous.

parent 9606e8ae
......@@ -40,7 +40,7 @@ chomp $_sudo;
### Options
our($opt_exec, $opt_exec2, $opt_become, $opt_cluster, $opt_user, $opt_keyring, $opt_monhost,
$opt_thishost, $opt_iwant1, $opt_iwant2, $opt_select, $opt_range, $opt_debug, $opt_h);
$opt_thishost, $opt_iwant1, $opt_iwant2, $opt_sizeOrDev, $opt_select, $opt_range, $opt_debug, $opt_h);
if (@ARGV > 0) {
GetOptions("e=s"=>\$opt_exec,
"l=s"=>\$opt_exec2,
......@@ -52,7 +52,8 @@ if (@ARGV > 0) {
"t" =>\$opt_thishost,
"i=s"=>\$opt_iwant1,
"w=s"=>\$opt_iwant2,
"s=f"=>\$opt_select,
"p" =>\$opt_sizeOrDev,
"s=s"=>\$opt_select,
"r=f"=>\$opt_range,
"d" =>\$opt_debug,
"h" =>\$opt_h) || fail_usage;
......@@ -103,15 +104,23 @@ my $thisHost = 0;
if (defined $opt_thishost) {
$thisHost = 1;
}
#
# 0 is default, group by device class
# 1 group by disk size
my $selectSizeOrDev = 0;
if (defined $opt_sizeOrDev) {
$selectSizeOrDev = 1;
}
my $selectSize = 0.;
if (defined $opt_select) {
$selectSize = $opt_select;
if ($selectSizeOrDev) {
$selectSize += 0.;
}
}
unless ($selectSize >= 0.) {
fail_usage "SelectSize option -s expects positive float.";
if ($selectSizeOrDev > 0 and $selectSize < 0.) {
fail_usage "SelectSize option -s expects positive float, when used together with -p option.";
}
my $range = 0.;
my $range = .1;
if (defined $opt_range) {
$range = $opt_range;
}
......@@ -144,6 +153,7 @@ if ($thisHost) {
my @_dataSize = `$cephCmd osd df`;
chomp @_dataSize;
my %dataSizeH = ();
my %dataTypeH = ();
foreach my $_lineS (@_dataSize)
{
# Removing leading and trailing blanks
......@@ -152,7 +162,8 @@ foreach my $_lineS (@_dataSize)
my @fields = split(/\s+/, $_lineS);
next unless ($fields[0] =~ /^\d+$/);
my $osdNum = $fields[0];
my $size = $fields[3];
my $type = $fields[1];
my $size = $fields[4];
my $sizeLastChar = lc(chop($size));
if ($sizeLastChar eq "t") {
$size = $size * 1000.;
......@@ -162,6 +173,7 @@ foreach my $_lineS (@_dataSize)
$size = $fields[3];
}
push (@{$dataSizeH{$size}}, $osdNum);
push (@{$dataTypeH{$type}}, $osdNum);
}
# Fetch the data from 'ceph osd perf' and put it in an hash indexed by osd#
......@@ -188,24 +200,38 @@ foreach (sort {$a<=> $b} keys %dataHash) {
my $lastKey = 0.;
my $selectMin = 0.;
my $selectMax = (sort {$b<=>$a} keys %{dataSizeH})[0] * 1.1;
if ($selectSize > 0) {
$lastKey = $selectSize;
$selectMin = $selectSize * (1. - ($range/100.));
$selectMin = 0 if ($selectMin < 0.);
$selectMax = $selectSize * (1. + ($range/100.));
if ($selectSizeOrDev) {
if ($selectSize > 0) {
$lastKey = $selectSize;
$selectMin = $selectSize * (1. - ($range/100.));
$selectMin = 0 if ($selectMin < 0.);
$selectMax = $selectSize * (1. + ($range/100.));
}
}
print "Select: $selectMin - $selectSize - $selectMax\n" if (defined $opt_debug);
my @latArray = ();
my $count = 0;
foreach my $aKey (sort {$a<=>$b} keys %dataSizeH) {
next unless $aKey >= $selectMin;
next if $aKey >= $selectMax;
foreach my $elem (sort {$a<=> $b} @{$dataSizeH{$aKey}}) {
next if ($thisHost && not exists $osdThisHost{$elem});
print "Push: OSD=$elem size=$aKey lat=".$dataHash{$elem}{$perfType}."\n" if (defined $opt_debug);
push (@latArray, $dataHash{$elem}{$perfType});
$count++;
if ($selectSizeOrDev) {
foreach my $aKey (sort {$a<=>$b} keys %dataSizeH) {
next unless $aKey >= $selectMin;
next if $aKey >= $selectMax;
foreach my $elem (sort {$a<=> $b} @{$dataSizeH{$aKey}}) {
next if ($thisHost && not exists $osdThisHost{$elem});
print "Push: OSD=$elem size=$aKey lat=".$dataHash{$elem}{$perfType}."\n" if (defined $opt_debug);
push (@latArray, $dataHash{$elem}{$perfType});
$count++;
}
}
} else {
foreach my $aKey (sort keys %dataTypeH) {
next unless $aKey =~ $selectSize;
foreach my $elem (sort {$a<=> $b} @{$dataTypeH{$aKey}}) {
next if ($thisHost && not exists $osdThisHost{$elem});
print "Push: OSD=$elem size=$aKey lat=".$dataHash{$elem}{$perfType}."\n" if (defined $opt_debug);
push (@latArray, $dataHash{$elem}{$perfType});
$count++;
}
}
}
print "Count: $count\n" if (defined $opt_debug);
......
......@@ -18,15 +18,18 @@
################################################################################
#
# Examples:
# *) return all disks grouped by size in Json format:
# *) return all disks grouped by device class in Json format:
# queryCephDisks.pl -j
# key name will be #OSDSIZE
# *) return disks of given device class in Json format:
# queryCephDisks.pl -j -q hdd
# key name will be #OSDSIZE
# *) return all disks grouped by size in Json format, grouping disks whose
# sizes differ less than <range> %
# queryCephDisks.pl -j -r <range>
# queryCephDisks.pl -j -p -r <range>
# key name will be #OSDSIZE
# *) return disks of given size in Json format:
# queryCephDisks.pl -j -s <size>
# queryCephDisks.pl -j -p -s <size>
# key name will be #OSDSIZE
# *) return disks of given size in Json format, grouping disks whose sizes
# differ less than <range> %
......@@ -37,7 +40,7 @@
# key name will be #OSDSIZETHIS
# *) -t can be combined with -s and or -r, same as above
# key name will be #OSDSIZETHIS
# *) without -j, return number of diskssummed over all groups
# *) without -j, return number of disks summed over all groups
#
################################################################################
use strict;
......@@ -60,7 +63,7 @@ chomp $_sudo;
### Options
our($opt_exec, $opt_exec2, $opt_become, $opt_cluster, $opt_user, $opt_keyring, $opt_monhost,
$opt_json, $opt_thishost, $opt_sizeOrDev, $opt_devtype, $opt_select, $opt_range, $opt_debug, $opt_h);
$opt_json, $opt_thishost, $opt_sizeOrDev, $opt_select, $opt_range, $opt_debug, $opt_h);
if (@ARGV > 0) {
GetOptions("e=s"=>\$opt_exec,
"l=s"=>\$opt_exec2,
......@@ -72,8 +75,7 @@ if (@ARGV > 0) {
"j" =>\$opt_json,
"t" =>\$opt_thishost,
"p" =>\$opt_sizeOrDev,
"w=s"=>\$opt_devtype,
"s=f"=>\$opt_select,
"s=s"=>\$opt_select,
"r=f"=>\$opt_range,
"d" =>\$opt_debug,
"h" =>\$opt_h) || fail_usage;
......@@ -126,17 +128,17 @@ if (defined $opt_sizeOrDev) {
my $selectSize = 0.;
if (defined $opt_select) {
$selectSize = $opt_select;
if ($selectSizeOrDev) {
$selectSize += 0.;
}
}
my $selectType = 0.;
if (defined $opt_devtype) {
$selectType = $opt_devtype;
unless ($selectSizeOrDev and $selectSize >= 0.) {
fail_usage "SelectSize option -s expects positive float, when used together with -p option.";
}
#
my $theJsonStringNum = $theJsonString."NUM";
#
unless ($selectSize >= 0.) {
fail_usage "SelectSize option -s expects positive float.";
}
my $range = 0.;
my $range = .1;
if (defined $opt_range) {
$range = $opt_range;
}
......@@ -144,7 +146,7 @@ unless ($range >= 0.) {
fail_usage "Range option -r expects positive float.";
}
# When requested, fetch list of OSDs on this host
# Possibly fetch list of OSDs on this host
my @_systemctl = ();
my %osdThisHost = ();
if ($thisHost) {
......@@ -198,12 +200,14 @@ foreach my $_line (@_data)
my $lastKey = 0.;
my $selectMin = 0.;
my $selectMax = (sort {$b<=>$a} keys %{dataHash})[0] * 1.1;
if ($selectSize > 0) {
$lastKey = $selectSize;
$selectMin = $selectSize * (1. - ($range/100.));
$selectMin = 0 if ($selectMin < 0.);
$selectMax = $selectSize * (1. + ($range/100.));
}
if ($selectSizeOrDev) {
if ($selectSize > 0) {
$lastKey = $selectSize;
$selectMin = $selectSize * (1. - ($range/100.));
$selectMin = 0 if ($selectMin < 0.);
$selectMax = $selectSize * (1. + ($range/100.));
}
}
print "Select: $selectMin - $selectSize - $selectMax\n" if (defined $opt_debug);
if ($selectSizeOrDev > 0) {
......@@ -224,7 +228,6 @@ if ($selectSizeOrDev > 0) {
}
@{$finalHash{$lastKey}} = sort { $a <=> $b } @{$finalHash{$lastKey}} if (scalar @{$finalHash{$lastKey}});
}
#
my $aLine = "Key $aKey: ";
foreach (@{$dataHash{$aKey}}) {
$aLine .= " ".$_;
......@@ -243,7 +246,8 @@ if ($selectSizeOrDev > 0) {
}
} else {
foreach my $aKey (sort keys %typeHash) {
next unless $aKey =~ /$selectType/;
print "aKey: $aKey Select: $selectSize\n";
next if ($selectSize =~ /[a-zA-Z]+/ and $aKey !~ /$selectSize/);
@{$finalHash{$aKey}} = ();
if ($thisHost) {
foreach my $osdNum (@{$typeHash{$aKey}}) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment