From: Phil Turmel <philip@turmel.org>
To: John Robinson <john.robinson@anonymous.org.uk>
Cc: linux-raid@vger.kernel.org
Subject: Re: Determining which spindle is out of order
Date: Sun, 07 Nov 2010 13:39:21 -0500 [thread overview]
Message-ID: <4CD6F259.6080408@turmel.org> (raw)
In-Reply-To: <4CD6C36C.1080200@anonymous.org.uk>
[-- Attachment #1: Type: text/plain, Size: 1051 bytes --]
On 11/07/2010 10:19 AM, John Robinson wrote:
> On 07/11/2010 14:43, Phil Turmel wrote:
>> On 11/07/2010 08:43 AM, John Robinson wrote:
> [...]
>>> Please don't feel you have to turn this into a project, though.
>>
>> Too late. Here's a version that doesn't use udevadm at all...
>
> OK, it's an improvement because after I've changed the find command to find '*scsi_host*', it lists my controllers, but finds them all empty. I noted that the script was looking for subdirectories called block but mine have names like block:sda so I changed the script again to refer to 'block*' both in the loop in check_host and in the substitution at the top of describe_device. There's still something not quite right with trying to read CentOS/RHEL 5 / kernel 2.6.18 sysfs, because this was the output I got:
I think I understand the older sysfs directory format now.
> Hope this helps. I've also attached my edited version of the script.
I did another version, with regular expressions to accommodate the variations. Please give it a shot.
Regards,
Phil
[-- Attachment #2: lsdrv --]
[-- Type: text/plain, Size: 1891 bytes --]
#! /bin/bash
#
# Examine specific system host devices to identify the drives attached
#
function describe_controller () {
local device driver modprefix serial slotname
driver="`readlink -f \"$1/driver\"`"
driver="`basename $driver`"
modprefix="`cut -d: -f1 <\"$1/modalias\"`"
echo "Controller device @ ${1##/sys/devices/} [$driver]"
if [[ "$modprefix" == "pci" ]] ; then
slotname="`basename \"$1\"`"
echo " `lspci -s $slotname |cut -d\ -f2-`"
return
fi
if [[ "$modprefix" == "usb" ]] ; then
if [[ -f "$1/busnum" ]] ; then
device="`cat \"$1/busnum\"`:`cat \"$1/devnum\"`"
serial="`cat \"$1/serial\"`"
else
device="`cat \"$1/../busnum\"`:`cat \"$1/../devnum\"`"
serial="`cat \"$1/../serial\"`"
fi
echo " `lsusb -s $device` {SN: $serial}"
return
fi
echo -e " `cat \"$1/modalias\"`"
}
function describe_device () {
local empty=1
while read device ; do
empty=0
if [[ "$device" =~ ^(.+)/block[/:](.+)$ ]] ; then
targ="${BASH_REMATCH[1]}"
bdev="${BASH_REMATCH[2]}"
vnd="$(< $targ/vendor)"
mdl="$(< $targ/model)"
sn="`sginfo -s /dev/$bdev | \
sed -rn -e \"/Serial Number/{s%^.+' *(.+) *'.*\\\$%\\\\1%;p;q}\"`" &>/dev/null
if [[ -n "$sn" ]] ; then
echo -e " $1: `echo /dev/$bdev $vnd $mdl {SN: $sn}`"
else
echo -e " $1: `echo /dev/$bdev $vnd $mdl`"
fi
else
echo -e " $1: Unknown $device"
fi
done
[[ $empty -eq 1 ]] && echo -e " $1: [Empty]"
}
function check_host () {
local found=0
local pController=
while read shost ; do
host=`dirname "$shost"`
controller=`dirname "$host"`
bhost=`basename "$host"`
if [[ "$controller" != "$pController" ]] ; then
pController="$controller"
describe_controller "$controller"
fi
find $host -regex '.+/target[0-9:]+/[0-9:]+/block[:/][^/]+' |describe_device "$bhost"
done
}
find /sys/devices/ -regex '.+/scsi_host\(:block\)?' |check_host
next prev parent reply other threads:[~2010-11-07 18:39 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-03 14:13 Determining which spindle is out of order Nat Makarevitch
2010-11-03 14:38 ` Roman Mamedov
2010-11-03 15:17 ` Graham Mitchell
2010-11-03 16:05 ` Roman Mamedov
2010-11-03 19:00 ` Jon Hardcastle
2010-11-03 14:43 ` John Robinson
2010-11-03 14:45 ` Tim Small
2010-11-03 15:59 ` Jon Hardcastle
2010-11-03 17:17 ` Bill Davidsen
2010-11-03 20:03 ` Tim Small
2010-11-03 15:29 ` Mikael Abrahamsson
2010-11-03 21:54 ` Phil Turmel
2010-11-03 22:26 ` Roman Mamedov
2010-11-04 9:29 ` Tom Carlson
2010-11-06 10:22 ` Leslie Rhorer
2010-11-06 15:12 ` Phil Turmel
[not found] ` <4CD57867.4010207@anonymous.org.uk>
2010-11-06 16:02 ` Phil Turmel
2010-11-06 16:11 ` Mathias Burén
2010-11-06 16:45 ` Jan Ceuleers
2010-11-06 19:39 ` Phil Turmel
2010-11-06 20:16 ` Leslie Rhorer
2010-11-06 20:23 ` Mr. James W. Laferriere
2010-11-07 7:51 ` Jan Ceuleers
2010-11-07 12:53 ` John Robinson
2010-11-07 13:21 ` Phil Turmel
2010-11-07 13:43 ` John Robinson
2010-11-07 14:43 ` Phil Turmel
2010-11-07 15:04 ` Mathias Burén
2010-11-07 15:19 ` John Robinson
2010-11-07 18:39 ` Phil Turmel [this message]
2010-11-07 20:46 ` Leslie Rhorer
2010-11-07 21:22 ` John Robinson
2010-11-08 18:59 ` John Robinson
2010-11-07 21:24 ` Andreas Dröscher
2010-11-08 21:05 ` Mr. James W. Laferriere
2010-11-07 20:52 ` Roman Mamedov
2010-11-09 14:40 ` Phil Turmel
2010-11-06 19:58 ` Leslie Rhorer
2010-11-06 21:17 ` John Robinson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4CD6F259.6080408@turmel.org \
--to=philip@turmel.org \
--cc=john.robinson@anonymous.org.uk \
--cc=linux-raid@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).