From c5d6aa0d1e4615b1673685f998aa61f46fec7ea8 Mon Sep 17 00:00:00 2001 From: Fulvio Galeazzi <fulvio.galeazzi@garr.it> Date: Tue, 7 Nov 2017 01:48:17 +0100 Subject: [PATCH] 2017-11-07: FG; Added checks for near-full and full OSD numbers. --- Ceph/Config/userparameter_ceph.conf | 2 ++ Ceph/Script/cephHealth.pl | 44 ++++++++++++++++++++++------- Ceph/Script/cephPg.pl | 6 ++-- 3 files changed, 39 insertions(+), 13 deletions(-) diff --git a/Ceph/Config/userparameter_ceph.conf b/Ceph/Config/userparameter_ceph.conf index c5844bc..0197c38 100644 --- a/Ceph/Config/userparameter_ceph.conf +++ b/Ceph/Config/userparameter_ceph.conf @@ -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.osd.nearfull[*],/etc/zabbix/scripts/cephHealth.pl $1 --nearfull +UserParameter=ceph.osd.full[*],/etc/zabbix/scripts/cephHealth.pl $1 --full # Pools UserParameter=ceph.pool.num[*],/etc/zabbix/scripts/queryCephPools.pl $1 UserParameter=ceph.pool.discovery[*],/etc/zabbix/scripts/queryCephPools.pl $1 -j diff --git a/Ceph/Script/cephHealth.pl b/Ceph/Script/cephHealth.pl index 01d581d..ef0fba6 100755 --- a/Ceph/Script/cephHealth.pl +++ b/Ceph/Script/cephHealth.pl @@ -70,7 +70,7 @@ chomp $_sudo; ### Options our($opt_exec, $opt_become, $opt_cluster, $opt_user, $opt_keyring, $opt_monhost, - $opt_status, $opt_object_degraded, $opt_object_misplaced, $opt_fraction, $opt_filter, $opt_debug, $opt_h); + $opt_status, $opt_object_degraded, $opt_object_misplaced, $opt_fraction, $opt_full, $opt_nearfull, $opt_filter, $opt_debug, $opt_h); if (@ARGV > 0) { GetOptions("e=s"=>\$opt_exec, "b" =>\$opt_become, @@ -82,6 +82,8 @@ if (@ARGV > 0) { "od" =>\$opt_object_degraded, "om" =>\$opt_object_misplaced, "f" =>\$opt_fraction, + "full" =>\$opt_full, + "nearfull" =>\$opt_nearfull, "s=s"=>\$opt_filter, "d" =>\$opt_debug, "h" =>\$opt_h) || fail_usage; @@ -113,13 +115,6 @@ if (defined $opt_monhost) { $cephCmd .= " -m $opt_monhost"; } # -if (defined $opt_status && (defined $opt_object_degraded || defined $opt_object_misplaced)) { - fail_usage "Either status or objects, not both."; -} -if (defined $opt_object_degraded && defined $opt_object_misplaced) { - fail_usage "Either degraded objects or misplaced, not both."; -} -# my $doStatus = 0; if (defined $opt_status) { $doStatus = 1; @@ -136,9 +131,22 @@ my $doFraction = 0; if (defined $opt_fraction) { $doFraction = 1; } -my $matchStr = ""; +my $doOsdFull = 0; +if (defined $opt_full) { + $doOsdFull = 1; +} +my $doOsdNearFull = 0; +if (defined $opt_nearfull) { + $doOsdNearFull = 1; +} +my @matchStr = (); if (defined $opt_filter) { - $matchStr = $opt_filter; + @matchStr = split(/,/,$opt_filter); +} +# +my $sumDo = $doStatus + $doObjectDeg + $doObjectMis + $doOsdFull + $doOsdNearFull; +if ($sumDo > 1) { + fail_usage "Either status or objectsDeg/objectsMis or OSD_full/OSD_nearfull."; } # Fetch the data and put it in an array @@ -158,6 +166,8 @@ my $objDegraded = 0; my $objDegradedFrac = 0; my $objMisplaced = 0; my $objMisplacedFrac = 0; +my $osdFull = 0; +my $osdNearFull = 0; # Read the array and print the wanted data foreach my $_line (@_data) { @@ -165,6 +175,11 @@ foreach my $_line (@_data) my @fields = split(/\s+/, $_line); if (exists $statusHash{$fields[0]}) { $status = $statusHash{$fields[0]}; + if ($status == 1) { +# if (@matchStr) { +# +# } + } } else { $status = 2; } @@ -179,6 +194,11 @@ foreach my $_line (@_data) $firstLine = 0; next; } + if ($_line =~ m/^osd.*is near full/) { + $osdNearFull += 1; + } elsif ($_line =~ m/^osd.*is full/) { + $osdFull += 1; + } } if (defined $opt_status) { @@ -195,6 +215,10 @@ if (defined $opt_status) { } else { print $objMisplaced."\n"; } +} elsif (defined $opt_nearfull) { + print $osdNearFull."\n"; +} elsif (defined $opt_full) { + print $osdFull."\n"; } else { print "-1\n"; } diff --git a/Ceph/Script/cephPg.pl b/Ceph/Script/cephPg.pl index ee4fd2a..a98adb9 100755 --- a/Ceph/Script/cephPg.pl +++ b/Ceph/Script/cephPg.pl @@ -94,9 +94,9 @@ my %specialRegex = ( my %statesHash = ( 'activeclean' => 'acc', 'active' => 'act', - 'backfill' => 'bck', - 'wait-backfill' => 'bck', - 'backfill-toofull' => 'bck', + 'backfilling' => 'bck', + 'backfill_wait' => 'bck', + 'backfill_toofull' => 'bck', 'clean' => 'cln', 'deep' => 'dee', 'degraded' => 'deg', -- GitLab