Commit 1d0f88f3 authored by Paolino Paperino's avatar Paolino Paperino
Browse files
parents 3bd42996 c3b095f4
UserParameter=ceph.health,/etc/zabbix/scripts/ceph_health.sh
# Global
UserParameter=ceph.global.objs[*],/etc/zabbix/scripts/cephDiskUsage.pl $1 -o
UserParameter=ceph.global.rawsize[*],/etc/zabbix/scripts/cephDiskUsage.pl $1
UserParameter=ceph.global.rawfrac[*],/etc/zabbix/scripts/cephDiskUsage.pl $1 -f
UserParameter=ceph.global.objs[*],/etc/zabbix/scripts/cephUsage.pl $1 -o
UserParameter=ceph.global.objsdeg[*],/etc/zabbix/scripts/cephHealth.pl $1 --od
UserParameter=ceph.global.objsdegfrac[*],/etc/zabbix/scripts/cephHealth.pl $1 --od -f
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.thrnearfull[*],/etc/zabbix/scripts/cephHealth.pl $1 --nearfullth
UserParameter=ceph.global.thrfull[*],/etc/zabbix/scripts/cephHealth.pl $1 --fullth
UserParameter=ceph.global.slowosd[*],/etc/zabbix/scripts/cephHealth.pl $1 --slowosd
UserParameter=ceph.global.slowreq[*],/etc/zabbix/scripts/cephHealth.pl $1 --slowreq
UserParameter=ceph.osd.nearfull[*],/etc/zabbix/scripts/cephHealth.pl $1 --nearfull
UserParameter=ceph.osd.full[*],/etc/zabbix/scripts/cephHealth.pl $1 --full
UserParameter=ceph.osd.down[*],/etc/zabbix/scripts/cephOsdStat.pl $1 -s down
UserParameter=ceph.osd.up[*],/etc/zabbix/scripts/cephOsdStat.pl $1 -s up
UserParameter=ceph.osd.out[*],/etc/zabbix/scripts/cephOsdStat.pl $1 -s out
UserParameter=ceph.osd.in[*],/etc/zabbix/scripts/cephOsdStat.pl $1 -s in
# Pools
UserParameter=ceph.pool.num[*],/etc/zabbix/scripts/queryCephPools.pl $1
UserParameter=ceph.pool.discovery[*],/etc/zabbix/scripts/queryCephPools.pl $1 -j
UserParameter=ceph.pool.objs[*],/etc/zabbix/scripts/cephDiskUsage.pl $1 -p $2 -o
UserParameter=ceph.pool.size[*],/etc/zabbix/scripts/cephDiskUsage.pl $1 -p $2
UserParameter=ceph.pool.frac[*],/etc/zabbix/scripts/cephDiskUsage.pl $1 -p $2 -f
UserParameter=ceph.pool.objs[*],/etc/zabbix/scripts/cephUsage.pl $1 -p $2 -o
UserParameter=ceph.pool.size[*],/etc/zabbix/scripts/cephUsage.pl $1 -p $2
UserParameter=ceph.pool.frac[*],/etc/zabbix/scripts/cephUsage.pl $1 -p $2 -f
# Pool groups: group by first field of '.'-separated pool string
UserParameter=ceph.poolgrp.num[*],/etc/zabbix/scripts/queryCephPools.pl $1 -g
UserParameter=ceph.poolgrp.discovery[*],/etc/zabbix/scripts/queryCephPools.pl $1 -g -j
UserParameter=ceph.poolgrp.objs[*],/etc/zabbix/scripts/cephDiskUsage.pl $1 -g -p $2 -o
UserParameter=ceph.poolgrp.size[*],/etc/zabbix/scripts/cephDiskUsage.pl $1 -g -p $2
UserParameter=ceph.poolgrp.frac[*],/etc/zabbix/scripts/cephDiskUsage.pl $1 -g -p $2 -f
UserParameter=ceph.poolgrp.objs[*],/etc/zabbix/scripts/cephUsage.pl $1 -g -p $2 -o
UserParameter=ceph.poolgrp.size[*],/etc/zabbix/scripts/cephUsage.pl $1 -g -p $2
UserParameter=ceph.poolgrp.frac[*],/etc/zabbix/scripts/cephUsage.pl $1 -g -p $2 -f
# PGs
# tot=total, acc=active+clean, act=active, bck=backfilling, cln=clean, dee=deep
# deg=degraded, dow=down, ncm=incomplete, ncs=inconsistent, oth=other, pee=peering/peered
# rec=recovery, rem=remapped, rep=repair, scr=scrubbing, sta=stale, und=undersized
UserParameter=ceph.pgstat.tot[*],/etc/zabbix/scripts/cephPg.pl $1 -f tot
UserParameter=ceph.pgstat.acc[*],/etc/zabbix/scripts/cephPg.pl $1 -f acc
UserParameter=ceph.pgstat.act[*],/etc/zabbix/scripts/cephPg.pl $1 -f act
UserParameter=ceph.pgstat.bck[*],/etc/zabbix/scripts/cephPg.pl $1 -f bck
UserParameter=ceph.pgstat.cln[*],/etc/zabbix/scripts/cephPg.pl $1 -f cln
UserParameter=ceph.pgstat.dee[*],/etc/zabbix/scripts/cephPg.pl $1 -f dee
UserParameter=ceph.pgstat.deg[*],/etc/zabbix/scripts/cephPg.pl $1 -f deg
UserParameter=ceph.pgstat.dow[*],/etc/zabbix/scripts/cephPg.pl $1 -f dow
UserParameter=ceph.pgstat.ncm[*],/etc/zabbix/scripts/cephPg.pl $1 -f ncm
UserParameter=ceph.pgstat.ncs[*],/etc/zabbix/scripts/cephPg.pl $1 -f ncs
UserParameter=ceph.pgstat.oth[*],/etc/zabbix/scripts/cephPg.pl $1 -f oth
UserParameter=ceph.pgstat.pee[*],/etc/zabbix/scripts/cephPg.pl $1 -f pee
UserParameter=ceph.pgstat.rec[*],/etc/zabbix/scripts/cephPg.pl $1 -f rec
UserParameter=ceph.pgstat.rem[*],/etc/zabbix/scripts/cephPg.pl $1 -f rem
UserParameter=ceph.pgstat.rep[*],/etc/zabbix/scripts/cephPg.pl $1 -f rep
UserParameter=ceph.pgstat.scr[*],/etc/zabbix/scripts/cephPg.pl $1 -f scr
UserParameter=ceph.pgstat.sta[*],/etc/zabbix/scripts/cephPg.pl $1 -f sta
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
......
#!/usr/bin/perl
################################################################################
# cephHealth.pl - Return health status, degraded and recovering objects
################################################################################
#
# This script executes 'ceph health detail' and returns one in:
# *) <status_flag>, 0=HEALTH_OK 1=HEALTH_WARN 2=HEALTH_ERR
# *) number of objects degraded
# *) number of objects degraded, fraction of total
# *) number of objects misplaced
# *) number of objects misplaced, fraction of total
#
################################################################################
use strict;
use warnings;
use Getopt::Long;
sub fail_usage
{
my ($msg)=@_;
print STDERR $msg."\n" if $msg;
print STDERR "Please use '-h' for usage.\n";
exit 1;
}
sub convertNumber
{
my ($string,$toWhat) = @_;
my $value = 0.;
if ($toWhat eq 'size') {
# return unit: T
$value = $string;
my $lastChar = lc(chop($string));
if ($lastChar eq "p") {
$value = $string * 1000.;
} elsif ($lastChar eq "t") {
$value = $string + 0.;
} elsif ($lastChar eq "g") {
$value = $string * 0.001;
} elsif ($lastChar eq "m") {
$value = $string * 0.001 * 0.001;
} elsif ($lastChar eq "k") {
$value = $string * 0.001 * 0.001;
} else {
$value = $value * 0.001 * 0.001 * 0.001 * 0.001;
}
} elsif ($toWhat eq 'count') {
# return unit: M
$value = $string;
my $lastChar = lc(chop($string));
if ($lastChar eq "p") {
$value = $string * 1000. * 1000. * 1000.;
} elsif ($lastChar eq "t") {
$value = $string * 1000. * 1000.;
} elsif ($lastChar eq "g") {
$value = $string * 1000.;
} elsif ($lastChar eq "m") {
$value = $string + 0.;
} elsif ($lastChar eq "k") {
$value = $string * 0.001;
} else {
$value = $value * 0.001 * 0.001;
}
}
return $value;
}
my $_sudo = `which sudo`;
chomp $_sudo;
### Options
our($opt_exec, $opt_become, $opt_cluster, $opt_user, $opt_keyring, $opt_monhost,
$opt_status, $opt_slow_osd, $opt_slow_req, $opt_object_degraded, $opt_object_misplaced,
$opt_fraction, $opt_fullth, $opt_nearfullth, $opt_full, $opt_nearfull, $opt_filter, $opt_debug, $opt_h);
if (@ARGV > 0) {
GetOptions("e=s"=>\$opt_exec,
"b" =>\$opt_become,
"c=s"=>\$opt_cluster,
"u=s"=>\$opt_user,
"k=s"=>\$opt_keyring,
"m=s"=>\$opt_monhost,
"status" =>\$opt_status,
"slowosd" =>\$opt_slow_osd,
"slowreq" =>\$opt_slow_req,
"od" =>\$opt_object_degraded,
"om" =>\$opt_object_misplaced,
"f" =>\$opt_fraction,
"fullth" =>\$opt_fullth,
"nearfullth" =>\$opt_nearfullth,
"full" =>\$opt_full,
"nearfull" =>\$opt_nearfull,
"s=s"=>\$opt_filter,
"d" =>\$opt_debug,
"h" =>\$opt_h) || fail_usage;
} fail_usage "Unknown parameter." if (@ARGV > 0);
my $cephCmd = "";
if (defined $opt_exec) {
$cephCmd = "$opt_exec";
} else {
$cephCmd = "/usr/bin/ceph";
}
if ( ! -e $cephCmd) {
die "Executable $cephCmd not found!";
}
if (defined $opt_become) {
$cephCmd = "$_sudo $cephCmd";
}
#
if (defined $opt_cluster) {
$cephCmd .= " --cluster $opt_cluster";
}
if (defined $opt_user) {
$cephCmd .= " --user $opt_user";
}
if (defined $opt_keyring) {
$cephCmd .= " --keyring $opt_keyring";
}
if (defined $opt_monhost) {
$cephCmd .= " -m $opt_monhost";
}
#
my $doStatus = 0;
if (defined $opt_status) {
$doStatus = 1;
}
my $doSlowOsd = 0;
if (defined $opt_slow_osd) {
$doSlowOsd = 1;
}
my $doSlowReq = 0;
if (defined $opt_slow_req) {
$doSlowReq = 1;
}
my $doObjectDeg = 0;
if (defined $opt_object_degraded) {
$doObjectDeg = 1;
}
my $doObjectMis = 0;
if (defined $opt_object_misplaced) {
$doObjectMis = 1;
}
my $doFraction = 0;
if (defined $opt_fraction) {
$doFraction = 1;
}
my $doOsdFull = 0;
if (defined $opt_full) {
$doOsdFull = 1;
}
my $doOsdNearFull = 0;
if (defined $opt_nearfull) {
$doOsdNearFull = 1;
}
my $doOsdFullth = 0;
if (defined $opt_fullth) {
$doOsdFullth = 1;
}
my $doOsdNearFullth = 0;
if (defined $opt_nearfullth) {
$doOsdNearFullth = 1;
}
my @matchStr = ();
if (defined $opt_filter) {
@matchStr = split(/,/,$opt_filter);
}
#
my $sumDo = $doStatus + $doSlowOsd + $doSlowReq + $doObjectDeg + $doObjectMis + $doOsdFull + $doOsdNearFull + $doOsdFullth + $doOsdNearFullth;
if ($sumDo > 1) {
fail_usage "Either status or slow_requests/osds or objectsDeg/objectsMis or OSD_full/OSD_nearfull or OSD_fullTh/OSD_nearfullTh.";
}
# Fetch the "pg dump" data and put it in an array
if ($doOsdFullth + $doOsdNearFullth) {
my @_pgdata = `$cephCmd pg dump 2> /dev/null`;
chomp @_pgdata;
foreach my $_pgline (@_pgdata) {
if ($doOsdFullth) {
if ($_pgline =~ m/^full\S+\s+([-+]?[0-9]*\.?[0-9]+)/) {
print $1."\n";
exit 0;
}
} elsif ($doOsdNearFullth) {
if ($_pgline =~ m/^nearfull\S+\s+([-+]?[0-9]*\.?[0-9]+)/) {
print $1."\n";
exit 0;
}
}
if ($_pgline =~ m/^\d+/) {
print "-1"."\n";
exit 0;
}
}
}
# Fetch the data and put it in an array
my @_data = `$cephCmd health detail`;
chomp @_data;
my %poolHash;
my $firstLine = 1;
my $skipNext = 0;
my %statusHash = (
'HEALTH_OK' => 0,
'HEALTH_WARN' => 1,
'HEALTH_ERR' => 2,
);
my $status = 0;
my $numSlowReq = 0;
my $numSlowOsd = 0;
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)
{
if ($firstLine) {
my @fields = split(/\s+/, $_line);
if (exists $statusHash{$fields[0]}) {
$status = $statusHash{$fields[0]};
if ($status == 1) {
# if (@matchStr) {
#
# }
}
} else {
$status = 2;
}
if ($_line =~ m/ (\d+) requests are blocked/) {
$numSlowReq = $1;
}
if ($_line =~ m/ (\d+) osds have slow requests/) {
$numSlowOsd = $1;
}
if ($_line =~ m/ (\d+)\/(\d+) objects misplaced \(([-+]?[0-9]*\.?[0-9]+)\%\)/) {
$objMisplaced = $1;
$objMisplacedFrac = $3;
}
if ($_line =~ m/ (\d+)\/(\d+) objects degraded \(([-+]?[0-9]*\.?[0-9]+)\%\)/) {
$objDegraded = $1;
$objDegradedFrac = $3;
}
$firstLine = 0;
next;
}
if ($_line =~ m/^osd.*is near full/) {
$osdNearFull += 1;
} elsif ($_line =~ m/^osd.*is full/) {
$osdFull += 1;
}
}
if (defined $opt_status) {
print $status."\n";
} elsif (defined $opt_object_degraded) {
if (defined $opt_fraction) {
print $objDegradedFrac."\n";
} else {
print $objDegraded."\n";
}
} elsif (defined $opt_object_misplaced) {
if (defined $opt_fraction) {
print $objMisplacedFrac."\n";
} else {
print $objMisplaced."\n";
}
} elsif (defined $opt_slow_req) {
print $numSlowReq."\n";
} elsif (defined $opt_slow_osd) {
print $numSlowOsd."\n";
} elsif (defined $opt_nearfull) {
print $osdNearFull."\n";
} elsif (defined $opt_full) {
print $osdFull."\n";
} else {
print "-1\n";
}
exit 0;
#!/usr/bin/perl
################################################################################
# cephOsdStat.pl - Return number of disks up/down in/out
################################################################################
#
# This script executes 'ceph osd dump' and returns number of disks which
# are up,down in,out or all of these information if flag --all is used.
#
# cephOsdStat.pl -s in # return number of disks which are 'in'
# cephOsdStat.pl -s all # return blank-tabbed list of all possible states (for debugging)
#
# Originator:
# 2017-11-16: Fulvio Galeazzi (Consortium GARR)
# Contributors:
#
################################################################################
use strict;
use warnings;
use Getopt::Long;
sub fail_usage
{
my ($msg)=@_;
print STDERR $msg."\n" if $msg;
print STDERR "Please use '-h' for usage.\n";
exit 1;
}
my $_sudo = `which sudo`;
chomp $_sudo;
### Options
our($opt_exec, $opt_become, $opt_cluster, $opt_user, $opt_keyring, $opt_monhost,
$opt_state, $opt_debug, $opt_h);
if (@ARGV > 0) {
GetOptions("e=s"=>\$opt_exec,
"b" =>\$opt_become,
"c=s"=>\$opt_cluster,
"u=s"=>\$opt_user,
"k=s"=>\$opt_keyring,
"m=s"=>\$opt_monhost,
"s=s"=>\$opt_state,
"d" =>\$opt_debug,
"h" =>\$opt_h) || fail_usage;
} fail_usage "Unknown parameter." if (@ARGV > 0);
my $cephCmd = "";
if (defined $opt_exec) {
$cephCmd = "$opt_exec";
} else {
$cephCmd = "/usr/bin/ceph";
}
if ( ! -e $cephCmd) {
die "Executable $cephCmd not found!";
}
if (defined $opt_become) {
$cephCmd = "$_sudo $cephCmd";
}
#
if (defined $opt_cluster) {
$cephCmd .= " --cluster $opt_cluster";
}
if (defined $opt_user) {
$cephCmd .= " --user $opt_user";
}
if (defined $opt_keyring) {
$cephCmd .= " --keyring $opt_keyring";
}
if (defined $opt_monhost) {
$cephCmd .= " -m $opt_monhost";
}
#
if (not defined $opt_state) {
fail_usage "Please use '-s <desired_state>' or '-s all' flag.";
}
my $wantAll = 0;
if (defined $opt_state && $opt_state =~ /^all$/) {
$wantAll = 1;
}
my %statesHash = (
'down' => 0,
'up' => 0,
'in' => 0,
'out' => 0,
);
# Fetch the data and put it in an array
my @_data = `$cephCmd osd dump`;
chomp @_data;
# Read the array and print the wanted data
foreach my $_line (@_data)
{
if ($_line =~ m/^osd\.\d+\s+(\w+)\s+(\w+)/) {
my $updown = $1;
my $inout = $2;
$statesHash{$updown} = $statesHash{$updown} + 1;
$statesHash{$inout} = $statesHash{$inout} + 1;
}
}
if ($wantAll) {
my $line = "ALL:";
foreach my $akey (sort keys %statesHash) {
$line .= " ".$akey.":".$statesHash{$akey};
}
print $line."\n";
} else {
if (defined $statesHash{$opt_state}) {
print $statesHash{$opt_state}."\n";
} else {
print "-1\n";
}
}
exit 0;
#!/usr/bin/perl
################################################################################
# cephPg.pl - Return disk space occupied, global or by a pool (group)
################################################################################
#
# This script executes 'ceph pg stat' and returns number of PG groups in
# some state. The desired state is selected as the 3-letter argument of
# option -f, like this:
# cephPg.pl -f acc # return number of PGs in active+clean state
# cephPg.pl -f all # return blank-tabbed list of all possible states/numbers (for debug purposes only)
#
# Hash %specialRegex contains a couple of special cases:
# - active+clean is substituted with a new string 'activeclean'
# - scrubbing+deep is substituted with string 'scrubbing'
#
# Originator:
# 2017-11-07: Fulvio Galeazzi (Consortium GARR)
# Contributors:
#
################################################################################
use strict;
use warnings;
use Getopt::Long;
sub fail_usage
{
my ($msg)=@_;
print STDERR $msg."\n" if $msg;
print STDERR "Please use '-h' for usage.\n";
exit 1;
}
my $_sudo = `which sudo`;
chomp $_sudo;
### Options
our($opt_exec, $opt_become, $opt_cluster, $opt_user, $opt_keyring, $opt_monhost,
$opt_filter, $opt_debug, $opt_h);
if (@ARGV > 0) {
GetOptions("e=s"=>\$opt_exec,
"b" =>\$opt_become,
"c=s"=>\$opt_cluster,
"u=s"=>\$opt_user,
"k=s"=>\$opt_keyring,
"m=s"=>\$opt_monhost,
"f=s"=>\$opt_filter,
"d" =>\$opt_debug,
"h" =>\$opt_h) || fail_usage;
} fail_usage "Unknown parameter." if (@ARGV > 0);
my $cephCmd = "";
if (defined $opt_exec) {
$cephCmd = "$opt_exec";
} else {
$cephCmd = "/usr/bin/ceph";
}
if ( ! -e $cephCmd) {
die "Executable $cephCmd not found!";
}
if (defined $opt_become) {
$cephCmd = "$_sudo $cephCmd";
}
#
if (defined $opt_cluster) {
$cephCmd .= " --cluster $opt_cluster";
}
if (defined $opt_user) {
$cephCmd .= " --user $opt_user";
}
if (defined $opt_keyring) {
$cephCmd .= " --keyring $opt_keyring";
}
if (defined $opt_monhost) {
$cephCmd .= " -m $opt_monhost";
}
#
my $wantAll = 0;
my @wantKeys = ();
if (defined $opt_filter) {
if ($opt_filter =~ m/all/) {
$wantAll = 1;
}
@wantKeys = split(/,/, $opt_filter);
}
#
my %specialRegex = (
'active+clean' => 'activeclean',
# 'scrubbing+deep' => 'scrubbing',
);
# statesHash keys:
# tot=total, acc=active+clean, act=active, bck=backfilling, cln=clean, dee=deep
# deg=degraded, dow=down, ncm=incomplete, ncs=inconsistent, oth=other, pee=peering/peered
# rec=recovery, rem=remapped, rep=repair, scr=scrubbing, sta=stale, und=undersized
my %statesHash = (
'activeclean' => 'acc',
'active' => 'act',
'backfilling' => 'bck',
'wait_backfill' => 'bck',
'backfill_toofull' => 'bck',
'clean' => 'cln',
'deep' => 'dee',
'degraded' => 'deg',
'down' => 'dow',
'incomplete' => 'ncm',
'inconsistent' => 'ncs',
'creating' => 'oth',
'replay' => 'oth',
'splitting' => 'oth',
'peered' => 'pee',
'peering' => 'pee',
'recovering' => 'rec',
'recovery_wait' => 'rec',
'remapped' => 'rem',
'repair' => 'rep',
'scrubbing' => 'scr',
'stale' => 'sta',
'undersized' => 'und',
);
my %pgHash = (
'tot' => 0,
);
foreach my $aSt (keys %statesHash) {
$pgHash{$statesHash{$aSt}} = 0;
}
# Fetch the data and put it in an array
my @_data = `$cephCmd pg stat`;
chomp @_data;
my $skipNext = 0;
# Read the array and print the wanted data
foreach my $_line (@_data)
{
if ($skipNext) {
next;
}
if ($_line =~ m/^v\S+:\s+(\d+)\s+pgs:([^;]*)/) {
$skipNext = 1;
$pgHash{'tot'} = $1;