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 662605 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]
Less error prone pure perl scrape of /proc/mdstat
cleaned_up_pure_perl_logwatch_mdadm.patch (text/plain), 7.70 KB, created by
jcpunk
on 2012-12-12 20:59:00 UTC
(
hide
)
Description:
Less error prone pure perl scrape of /proc/mdstat
Filename:
MIME Type:
Creator:
jcpunk
Created:
2012-12-12 20:59:00 UTC
Size:
7.70 KB
patch
obsolete
>diff -upr /tmp/foo/conf/services/mdadm.conf conf/services/mdadm.conf >--- /tmp/foo/conf/services/mdadm.conf 2012-12-10 09:21:51.359531216 -0600 >+++ conf/services/mdadm.conf 2012-12-10 08:19:37.068532420 -0600 >@@ -0,0 +1,16 @@ >+# 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... >+# since we don't have real logs, put it will 'messages' so that >+# it runs towards the back >+LogFile = messages >diff -upr /tmp/foo/scripts/services/mdadm scripts/services/mdadm >--- /tmp/foo/scripts/services/mdadm 2012-12-10 09:20:49.463656273 -0600 >+++ scripts/services/mdadm 2012-12-10 08:29:17.369655627 -0600 >@@ -0,0 +1,235 @@ >+#!/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 '/proc/mdstat') { >+ exit(0); >+} >+ >+# we will need you later >+my $Detail = $ENV{'LOGWATCH_DETAIL_LEVEL'} || 0; >+ >+# open /proc/mdstat file, if we can't just exit >+open(PROC, '/proc/mdstat') or exit(0); >+my @proc_mdstat = <PROC>; >+close(PROC); >+ >+# where we are going to hold the data >+my %md_dev; >+ >+# 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 here >+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]); >+ >+# 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 how 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'; >+ } >+ >+ # known defaults, if False we will ignore >+ 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 = (); >+ >+ # split out the devices, sort them so that the order is static >+ for my $device (sort @devices) { >+ if ($device =~ /(.*)\(F\)/) { >+ push(@failed, $1); >+ } elsif ($device =~ /(.*)\(S\)/) { >+ push(@spare, $1); >+ } else { >+ push(@good, $device); >+ } >+ } >+ >+ # this hash should contain all the useful data >+ $md_dev{'md' . $md} = { >+ 'level' => $raid, >+ 'status' => $status, >+ 'eta' => $finished, >+ 'percent' => $percent, >+ 'good_dev' => \@good, >+ 'spare_dev' => \@spare, >+ 'bad_dev' => \@failed >+ }; >+ >+ } >+} >+ >+my @found = sort 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"; >+ } >+ >+ # only show these is they exist >+ unless ($md_dev{'unused'} =~ /none/) { >+ 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