1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-22 02:51:03 +00:00

enhancement - fetch remaining time of array rebuilding and show them on config

* add info about remaining time, read-only status
 * change label to follow b39d26e
This commit is contained in:
Ken-ichi Mito 2015-05-04 18:37:09 +09:00
parent 760b14f554
commit 6284302ae1

View file

@ -37,17 +37,18 @@ close($mdstat);
my($devinfo_re, $devstat_re, $action_re) = ( my($devinfo_re, $devstat_re, $action_re) = (
'(md\d+)\s+:\s+active\s+(\(read-only\)\s+|\(auto-read-only\)\s+|)(\w+)\s+(.*)', '(md\d+)\s+:\s+active\s+(\(read-only\)\s+|\(auto-read-only\)\s+|)(\w+)\s+(.*)',
'.*\[(\d+)\/(\d+)]\s+\[(\w+)]', '.*\[(\d+)\/(\d+)]\s+\[(\w+)]',
'.*(reshape|check|resync|recovery)\s*=\s*(\d+\.\d+%|\w+)', '.*(reshape|check|resync|recovery)\s*=\s*(\d+\.\d+%|\w+)(.*finish=(.*min))?',
); );
# Interestingly, swap is presented as "active (auto-read-only)" # Interestingly, swap is presented as "active (auto-read-only)"
# and mdadm has '--readonly' option to make the array 'active (read-only)' # and mdadm has '--readonly' option to make the array 'active (read-only)'
my($dev, $type, $members, $nmem, $nact, $status, $action, $proc); my($dev, $ro, $type, $members, $nmem, $nact, $status, $action, $proc, $minute);
while (@text) { while (@text) {
my $line = shift @text; my $line = shift @text;
if ($line =~ /$devinfo_re/) { if ($line =~ /$devinfo_re/) {
# first line should like "active raid1 sda1[0] sdc1[2] sdb1[1]" # first line should like "active raid1 sda1[0] sdc1[2] sdb1[1]"
$dev = $1; $dev = $1;
$ro = $2 || '';
$type = $3; $type = $3;
$members = $4; $members = $4;
@ -69,17 +70,20 @@ while (@text) {
# this line will appear only when the array is in action # this line will appear only when the array is in action
$action = $1; $action = $1;
my $percent = $2; my $percent = $2;
$minute = $4 || '';
if ($percent =~ /(\d+\.\d+)%/) { if ($percent =~ /(\d+\.\d+)%/) {
$proc = $1; $proc = $1;
} }
else { else {
# 'resync=DELAYED' or 'resync=PENDING' # 'resync=DELAYED' or 'resync=PENDING'
$action .= " ($percent)";
$proc = -1; $proc = -1;
} }
} }
else { else {
# array is not in action # array is not in action
$action = 'idle'; $action = 'idle';
$minute = '';
unshift(@text, $line); unshift(@text, $line);
} }
} }
@ -90,16 +94,16 @@ while (@text) {
if ( $ARGV[0] and $ARGV[0] eq "config" ) { if ( $ARGV[0] and $ARGV[0] eq "config" ) {
print "$dev.label $dev\n"; print "$dev.label $dev\n";
print "$dev.info $type $members\n"; print "$dev.info $type $ro$members\n";
# 100: means less than 100 # 100: means less than 100
# Because of an unfound bug, sometimes reported as 99.XX even when OS reports 100. # Because of an unfound bug, sometimes reported as 99.XX even when OS reports 100.
print "$dev.critical 98:\n"; print "$dev.critical 98:\n";
print $dev, "_rebuild.label $dev rebuilt\n"; print $dev, "_rebuild.label $dev reshape/recovery\n";
print $dev, "_rebuild.info $type\n"; print $dev, "_rebuild.info $action $minute\n";
# Because of an unfound bug, sometimes reported as 99.XX even when OS reports 100. # Because of an unfound bug, sometimes reported as 99.XX even when OS reports 100.
print $dev, "_rebuild.critical 98:\n"; print $dev, "_rebuild.critical 98:\n";
print $dev, "_check.label $dev check/resync \n"; print $dev, "_check.label $dev check/resync \n";
print $dev, "_check.info $type\n"; print $dev, "_check.info $action $minute\n";
} else { } else {
my $pct = 100 * $nact / $nmem; my $pct = 100 * $nact / $nmem;
my $rpct = 100; my $rpct = 100;