Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 659419 Details for
Bug 883427
[RFE] logwatch support for mdadm devices
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
pure perl scrape of /proc/mdstat
pure_perl_logwatch_mdadm.patch (text/plain), 7.36 KB, created by
jcpunk
on 2012-12-07 14:51:53 UTC
(
hide
)
Description:
pure perl scrape of /proc/mdstat
Filename:
MIME Type:
Creator:
jcpunk
Created:
2012-12-07 14:51:53 UTC
Size:
7.36 KB
patch
obsolete
>diff -upr /tmp/conf/services/mdadm.conf conf/services/mdadm.conf >--- /tmp/conf/services/mdadm.conf 2012-12-06 16:11:59.947735758 -0600 >+++ conf/services/mdadm.conf 2012-12-06 11:21:39.404559553 -0600 >@@ -0,0 +1,17 @@ >+# You can put comments anywhere you want to. They are effective for the >+# rest of the line. >+ >+# this is in the format of <name> = <value>. Whitespace at the beginning >+# and end of the lines is removed. Whitespace before and after the = sign >+# is removed. Everything is case *insensitive*. >+ >+# Yes = True = On = 1 >+# No = False = Off = 0 >+ >+Title = "Mdadm" >+ >+# Which logfile group... >+LogFile = messages >+ >+# what is the path to mdstat >+$mdstat = '/proc/mdstat' >diff -upr /tmp/scripts/services/mdadm scripts/services/mdadm >--- /tmp/scripts/services/mdadm 2012-12-06 16:12:15.555542620 -0600 >+++ scripts/services/mdadm 2012-12-07 08:46:16.937569184 -0600 >@@ -0,0 +1,229 @@ >+#!/usr/bin/perl -w >+ >+use strict; >+$|++; >+ >+# if /proc/mdstat is not found or not readable >+# there is nothing we can do here, so just leave >+unless ( -r $ENV{'mdstat'}) { >+ exit(0); >+} >+ >+# we will need you later >+my $Detail = $ENV{'LOGWATCH_DETAIL_LEVEL'} || 0; >+ >+# open the mdstat file (probably /proc/mdstat) >+open(PROC, $ENV{'mdstat'}); >+my @proc_mdstat = <PROC>; >+close(PROC); >+ >+# make it one big long string >+my $mdstat_string = join('', @proc_mdstat); >+ >+# remove extra whitespace >+$mdstat_string =~ s/[\n\s]+/ /g; >+ >+# make a list of 'md' devices and their information >+my @md_devices = split('md', $mdstat_string); >+ >+# no md devices tracked, we are done >+exit(0) if ($#md_devices < 1); >+ >+# the 'unused devices' got stuck on the end of the last element >+my @unused = split('unused devices:', pop(@md_devices)); >+ >+# this one is an md device >+push(@md_devices, $unused[0]); >+ >+# where we are going to hold the data >+my %md_dev; >+ >+# our unused device list, needs less extra white space >+# if the line is missing, don't worry about it >+if ($#unused > 0) { >+ $md_dev{'unused'} = $unused[1]; >+ $md_dev{'unused'} =~ s/^\s+//; >+ $md_dev{'unused'} =~ s/\s+$//; >+} else { >+ $md_dev{'unused'} = '<none>'; >+} >+ >+for my $line (@md_devices) { >+ if ($line =~ /([\S]+)\s:\sactive\s(?:\(auto-read-only\)\s)*(raid\d+)([\w\d\\(\)[\] ]+)\s\d+\sblocks\s.*\s*\[(\d+)\/(\d+)\]\s*\[([_U]+)\]/) { >+ >+ my $md = $1; >+ my $raid = $2; >+ my $dev_list = $3; >+ my $device_have = $4; >+ my $dev_need = $5; >+ my $status = $6; >+ >+ # white space, oh you you curse me! >+ $dev_list =~ s/^\s+//; >+ >+ # if we've got any _ that means we are missing a device >+ if ($status =~ /_/) { >+ $status = 'Degraded'; >+ } elsif ($device_have < $dev_need) { >+ $status = 'Degraded'; >+ } else { >+ $status = 'OK'; >+ } >+ >+ my $percent = 'False'; >+ my $finished = 'False'; >+ >+ # look for resync and possible ETA >+ my $resync = 'False'; >+ if ($line =~ /resync\s*=\s*([\w\d\.%]+)/) { >+ $resync = $1; >+ $percent = $1; >+ if ($line =~ /finish\s*=\s*([\w\d\.]+)/) { >+ $finished = $1; >+ } else { >+ $finished = 'PENDING'; >+ } >+ } >+ >+ if ($resync ne 'False') { >+ $status = 'Synchronizing'; >+ } >+ >+ # look for recovery and possible ETA >+ my $recovery = 'False'; >+ if ($line =~ /recovery\s*=\s*([\w\d\.%]+)/) { >+ $recovery = $1; >+ $percent = $1; >+ if ($line =~ /finish\s*=\s*([\w\d\.]+)/) { >+ $finished = $1; >+ } else { >+ $finished = 'PENDING'; >+ } >+ } >+ >+ if ($recovery ne 'False') { >+ $status = 'Recovering'; >+ } >+ >+ # look for check and possible ETA >+ my $checking = 'False'; >+ if ($line =~ /check\s*=\s*([\w\d\.%]+)/) { >+ $checking = $1; >+ $percent = $1; >+ if ($line =~ /finish\s*=\s*([\w\d\.]+)/) { >+ $finished = $1; >+ } else { >+ $finished = 'PENDING'; >+ } >+ } >+ if ($checking ne 'False') { >+ $status = 'Checking'; >+ } >+ >+ >+ # remove the device counts >+ $dev_list =~ s/\[\d+\]//g; >+ >+ # split things off >+ my @devices = split(/\s/, $dev_list); >+ my @good = (); >+ my @failed = (); >+ my @spare = (); >+ >+ for my $device (@devices) { >+ if ($device =~ /(.*)\(F\)/) { >+ push(@failed, $1); >+ } elsif ($device =~ /(.*)\(S\)/) { >+ push(@spare, $1); >+ } else { >+ push(@good, $device); >+ } >+ } >+ >+ $md_dev{'md' . $md} = { >+ 'level' => $raid, >+ 'status' => $status, >+ 'eta' => $finished, >+ 'percent' => $percent, >+ 'good_dev' => \@good, >+ 'spare_dev' => \@spare, >+ 'bad_dev' => \@failed >+ }; >+ >+ } >+} >+ >+my @found = keys(%md_dev); >+ >+# only thing we ended up with is the 'unused' line >+if ($#found == 0 ) { >+ exit(0); >+} >+ >+# Low: >+if ($Detail <= 4) { >+ for my $item (@found) { >+ # don't care in low detail >+ if ($item eq 'unused') { >+ next; >+ } >+ # don't care in low detail >+ if ($md_dev{$item}{'status'} =~ /OK|Checking/) { >+ next; >+ } >+ if ($md_dev{$item}{'eta'} ne 'False') { >+ print '/dev/' . $item . ' : ' . $md_dev{$item}{'status'} . ', ETA: ' . $md_dev{$item}{'eta'} . "\n"; >+ } else { >+ print '/dev/' . $item . ' : ' . $md_dev{$item}{'status'} . "\n"; >+ } >+ } >+} >+# Med: >+elsif($Detail <= 9) { >+ for my $item (@found) { >+ # don't care in medium detail >+ if ($item eq 'unused') { >+ next; >+ } >+ print '/dev/' . $item . ' - ' . $md_dev{$item}{'level'} . ' : ' . $md_dev{$item}{'status'} . "\n"; >+ >+ if ($md_dev{$item}{'eta'} ne 'False') { >+ print "\tETA: " . $md_dev{$item}{'eta'}; >+ if ($md_dev{$item}{'percent'} ne 'False') { >+ print ', Percent: ', $md_dev{$item}{'percent'}; >+ } >+ print "\n"; >+ } >+ } >+} >+# High: >+else { >+ for my $item (@found) { >+ # Put this at the end >+ if ($item eq 'unused') { >+ next; >+ } >+ # always print good devices, only show failed or spare if they exist >+ print '/dev/' . $item . ' : ' . $md_dev{$item}{'status'} . "\n"; >+ print "\tRaid Level: " . $md_dev{$item}{'level'} . "\n"; >+ print "\tGood Devices: " . join(', ', @{$md_dev{$item}{'good_dev'}}) . "\n"; >+ if (@{$md_dev{$item}{'bad_dev'}}) { >+ print "\tFailed Devices: " . join(', ', @{$md_dev{$item}{'bad_dev'}}) . "\n"; >+ } >+ if (@{$md_dev{$item}{'spare_dev'}}) { >+ print "\tSpare Devices: " . join(', ', @{$md_dev{$item}{'spare_dev'}}) . "\n"; >+ } >+ >+ if ($md_dev{$item}{'eta'} ne 'False') { >+ print "\tETA: " . $md_dev{$item}{'eta'}; >+ if ($md_dev{$item}{'percent'} ne 'False') { >+ print ', Percent: ', $md_dev{$item}{'percent'}; >+ } >+ print "\n"; >+ } >+ print "\n"; >+ } >+ print "Unused Devices: " . $md_dev{'unused'} . "\n"; >+ >+} >+
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 883427
:
657581
|
659419
|
662605