Commit e98413a4 authored by Fulvio Galeazzi's avatar Fulvio Galeazzi
Browse files

2018-05-07: FG; Added min/max OSD fraction used.

parent 174a718c
......@@ -7,6 +7,8 @@ UserParameter=ceph.global.objsmis[*],/etc/zabbix/scripts/cephHealth.pl $1 --om
UserParameter=ceph.global.objsmisfrac[*],/etc/zabbix/scripts/cephHealth.pl $1 --om -f
UserParameter=ceph.global.rawsize[*],/etc/zabbix/scripts/cephUsage.pl $1
UserParameter=ceph.global.rawfrac[*],/etc/zabbix/scripts/cephUsage.pl $1 -f
UserParameter=ceph.global.minfrac[*],/etc/zabbix/scripts/queryCephDisks.pl $1 $2 -i minfrac
UserParameter=ceph.global.maxfrac[*],/etc/zabbix/scripts/queryCephDisks.pl $1 $2 -i maxfrac
UserParameter=ceph.global.thrbackfillfull[*],/etc/zabbix/scripts/cephHealth.pl $1 --backfillfullth
UserParameter=ceph.global.thrnearfull[*],/etc/zabbix/scripts/cephHealth.pl $1 --nearfullth
UserParameter=ceph.global.thrfull[*],/etc/zabbix/scripts/cephHealth.pl $1 --fullth
......@@ -56,12 +58,16 @@ UserParameter=ceph.pgstat.und[*],/etc/zabbix/scripts/cephPg.pl $1 -f und
# Disks
UserParameter=ceph.osdsize.all.discovery[*],/etc/zabbix/scripts/queryCephDisks.pl $1 $2 -j
UserParameter=ceph.osdsize.all.count[*],/etc/zabbix/scripts/queryCephDisks.pl $1 $2 -s $3
UserParameter=ceph.osdsize.all.minfrac[*],/etc/zabbix/scripts/cephDiskPerf.pl $1 $2 -s $3 -i minfrac
UserParameter=ceph.osdsize.all.maxfrac[*],/etc/zabbix/scripts/cephDiskPerf.pl $1 $2 -s $3 -i maxfrac
UserParameter=ceph.osdperf.all.clat[*],/etc/zabbix/scripts/cephDiskPerf.pl $1 $2 -s $3 -i clat
UserParameter=ceph.osdperf.all.clatdev[*],/etc/zabbix/scripts/cephDiskPerf.pl $1 $2 -s $3 -i clat -w dev
UserParameter=ceph.osdperf.all.alat[*],/etc/zabbix/scripts/cephDiskPerf.pl $1 $2 -s $3 -i alat
UserParameter=ceph.osdperf.all.alatdev[*],/etc/zabbix/scripts/cephDiskPerf.pl $1 $2 -s $3 -i alat -w dev
UserParameter=ceph.osdsize.this.discovery[*],/etc/zabbix/scripts/queryCephDisks.pl $1 $2 -j -t
UserParameter=ceph.osdsize.this.count[*],/etc/zabbix/scripts/queryCephDisks.pl $1 $2 -s $3 -t
UserParameter=ceph.osdsize.this.minfrac[*],/etc/zabbix/scripts/cephDiskPerf.pl $1 $2 -s $3 -t -i minfrac
UserParameter=ceph.osdsize.this.maxfrac[*],/etc/zabbix/scripts/cephDiskPerf.pl $1 $2 -s $3 -t -i maxfrac
UserParameter=ceph.osdperf.this.clat[*],/etc/zabbix/scripts/cephDiskPerf.pl $1 $2 -s $3 -t -i clat
UserParameter=ceph.osdperf.this.clatdev[*],/etc/zabbix/scripts/cephDiskPerf.pl $1 $2 -s $3 -t -i clat -w dev
UserParameter=ceph.osdperf.this.alat[*],/etc/zabbix/scripts/cephDiskPerf.pl $1 $2 -s $3 -t -i alat
......
......@@ -24,7 +24,7 @@ use warnings;
use Getopt::Long;
use Math::Complex;
use List::Util qw( min max );
sub fail_usage
{
......@@ -87,17 +87,23 @@ if (defined $opt_monhost) {
$cephCmd .= " -m $opt_monhost";
}
#
my $perfType = "";
my $perfType = "clat";
my $fracType = "";
my $perfWhat = 'avg';
if (defined $opt_iwant1) {
$perfType = $opt_iwant1;
fail_usage "Info option -i expects either 'clat' or alat' only."
unless ($perfType eq 'alat' || $perfType eq 'clat');
fail_usage "Info option -i expects either 'clat'|'alat' or 'minfrac'|'maxfrac' only."
unless ($opt_iwant1 eq 'alat' || $opt_iwant1 eq 'clat' || $opt_iwant1 eq 'maxfrac' || $opt_iwant1 eq 'minfrac');
if ( $opt_iwant1 eq 'alat' || $opt_iwant1 eq 'clat' ) {
$perfType = $opt_iwant1;
}
if ( $opt_iwant1 eq 'maxfrac' || $opt_iwant1 eq 'minfrac' ) {
$fracType = $opt_iwant1;
}
}
if (defined $opt_iwant2) {
$perfWhat = $opt_iwant2;
fail_usage "Info option -w currently expects 'dev' only."
unless ($perfWhat eq 'dev');
fail_usage "Info option -w currently expects 'dev' only, in conjunction with -i 'clat'|'alat'"
unless ($perfWhat eq 'dev' and ($perfType eq 'alat' || $perfType eq 'clat'));
}
#
my $thisHost = 0;
......@@ -154,6 +160,8 @@ my @_dataSize = `$cephCmd osd df`;
chomp @_dataSize;
my %dataSizeH = ();
my %dataTypeH = ();
my %fracSizeH = ();
my %fracTypeH = ();
foreach my $_lineS (@_dataSize)
{
# Removing leading and trailing blanks
......@@ -163,6 +171,7 @@ foreach my $_lineS (@_dataSize)
next unless ($fields[0] =~ /^\d+$/);
my $osdNum = $fields[0];
my $type = $fields[1];
my $frac = $fields[7];
my $size = $fields[4];
my $sizeLastChar = lc(chop($size));
if ($sizeLastChar eq "t") {
......@@ -170,10 +179,12 @@ foreach my $_lineS (@_dataSize)
} elsif ($sizeLastChar eq "g") {
$size += 0.;
} else {
$size = $fields[3];
$size = $fields[4];
}
push (@{$dataSizeH{$size}}, $osdNum);
push (@{$dataTypeH{$type}}, $osdNum);
push (@{$fracSizeH{$size}}, $frac);
push (@{$fracTypeH{$type}}, $frac);
}
# Fetch the data from 'ceph osd perf' and put it in an hash indexed by osd#
......@@ -212,16 +223,24 @@ print "Select: $selectMin - $selectSize - $selectMax\n" if (defined $opt_debug);
my @latArray = ();
my $count = 0;
my $minFrac = 100.;
my $maxFrac = 0.;
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);
print "PerfType;ush: OSD=$elem size=$aKey lat=".$dataHash{$elem}{$perfType}."\n" if (defined $opt_debug);
push (@latArray, $dataHash{$elem}{$perfType});
$count++;
}
my $aMinFrac = min( @{$fracSizeH{$aKey}});
my $aMaxFrac = max( @{$fracSizeH{$aKey}});
print " min/max frac: ".$aMinFrac."/".$aMaxFrac."\n" if (defined $opt_debug);
$minFrac = $aMinFrac if ( $aMinFrac < $minFrac );
$maxFrac = $aMaxFrac if ( $aMaxFrac > $maxFrac );
print "New min/max frac: ".$aMinFrac."/".$aMaxFrac."\n" if (defined $opt_debug);
}
} else {
foreach my $aKey (sort keys %dataTypeH) {
......@@ -232,6 +251,12 @@ if ($selectSizeOrDev) {
push (@latArray, $dataHash{$elem}{$perfType});
$count++;
}
my $aMinFrac = min( @{$fracTypeH{$aKey}});
my $aMaxFrac = max( @{$fracTypeH{$aKey}});
print " min/max frac: ".$aMinFrac."/".$aMaxFrac."\n" if (defined $opt_debug);
$minFrac = $aMinFrac if ( $aMinFrac < $minFrac );
$maxFrac = $aMaxFrac if ( $aMaxFrac > $maxFrac );
print "New min/max frac: ".$aMinFrac."/".$aMaxFrac."\n" if (defined $opt_debug);
}
}
print "Count: $count\n" if (defined $opt_debug);
......@@ -251,11 +276,20 @@ for (@latArray) {
$avgValue = $sumLin / ($count + 0.);
$stdValue = sqrt(($sumSq / $count) - $avgValue * $avgValue);
print "Avg: $avgValue Std: $stdValue\n" if (defined $opt_debug);
if ($perfWhat eq 'dev') {
print "$stdValue\n";
if ( $fracType ne "" ) {
if ($fracType eq 'minfrac') {
print "$minFrac\n";
} elsif ($fracType eq 'maxfrac') {
print "$maxFrac\n";
}
} else {
print "$avgValue\n";
if ($perfWhat eq 'dev') {
print "$stdValue\n";
} elsif ($perfWhat eq 'avg') {
print "$avgValue\n";
}
}
#
exit 0;
......
......@@ -47,7 +47,7 @@ use strict;
use warnings;
use Getopt::Long;
use List::Util qw( min max );
sub fail_usage
{
......@@ -63,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_select, $opt_range, $opt_debug, $opt_h);
$opt_json, $opt_thishost, $opt_iwant, $opt_sizeOrDev, $opt_select, $opt_range, $opt_debug, $opt_h);
if (@ARGV > 0) {
GetOptions("e=s"=>\$opt_exec,
"l=s"=>\$opt_exec2,
......@@ -74,6 +74,7 @@ if (@ARGV > 0) {
"m=s"=>\$opt_monhost,
"j" =>\$opt_json,
"t" =>\$opt_thishost,
"i=s"=>\$opt_iwant,
"p" =>\$opt_sizeOrDev,
"s=s"=>\$opt_select,
"r=f"=>\$opt_range,
......@@ -109,6 +110,15 @@ if (defined $opt_monhost) {
$cephCmd .= " -m $opt_monhost";
}
#
my $wantWhat = 'count';
if (defined $opt_iwant) {
$wantWhat = $opt_iwant;
fail_usage "Info option -i expects 'minfrac'|'maxfrac' only."
unless ($wantWhat eq 'minfrac' || $wantWhat eq 'maxfrac');
fail_usage "Info option -i is incompatible with options -s and -t."
if (defined $opt_thishost || defined $opt_select);
}
#
my $doJson = 0;
if (defined $opt_json) {
$doJson = 1;
......@@ -173,6 +183,7 @@ chomp @_data;
my %dataHash = ();
my %typeHash = ();
my %finalHash = ();
my @fracUsed = ();
# Read the array and print the wanted data
foreach my $_line (@_data)
{
......@@ -183,6 +194,7 @@ foreach my $_line (@_data)
next unless ($fields[0] =~ /^\d+$/);
my $osdNum = $fields[0];
my $type = $fields[1];
my $frac = $fields[7];
my $size = $fields[4];
my $sizeLastChar = lc(chop($size));
if ($sizeLastChar eq "t") {
......@@ -190,12 +202,15 @@ foreach my $_line (@_data)
} elsif ($sizeLastChar eq "g") {
$size += 0.;
} else {
$size = $fields[3];
$size = $fields[4];
}
next unless ($size);
push (@{$dataHash{$size}}, $osdNum);
push (@{$typeHash{$type}}, $osdNum);
push (@fracUsed, $frac);
}
my $minFrac = min(@fracUsed);
my $maxFrac = max(@fracUsed);
my $lastKey = 0.;
my $selectMin = 0.;
......@@ -295,7 +310,13 @@ foreach my $key (sort keys %finalHash) {
}
if (!$doJson) {
print $_count . "\n";
if ($wantWhat eq 'count') {
print $_count . "\n";
} elsif ($wantWhat eq 'minfrac') {
print $minFrac . "\n";
} elsif ($wantWhat eq 'maxfrac') {
print $maxFrac . "\n";
}
} else {
$outJson .= "\n\t]\n";
$outJson .= "}\n";
......
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