On RHEL6 machines I need to regularly check for all SAN LUNs having at least one functional path over at least two different HBA ports. I'd like a simple parser script which would tell me which LUNs do NOT meet those criteria.
Id' assume some of you had been through the same and might have already created a simple parser which might save me a bit of a time... Ideally using standard Linux tools, so bash/cat/grep/awk/sed, not perl/ruby/java/erlang... (although perl might be acceptable indeed).
Output per device can look following, the "keyword" for the LUN is "dm-[[:digit:]]", then there might be one or more HBA ports each having nought or more visible paths in various condition, here's a few examples:
1) device without alias, two HBA ports, two paths for each, all working well
36005076802810c208000000000000014 dm-53 IBM,2145
size=10T features='1 queue_if_no_path' hwhandler='0' wp=rw
|-+- policy='round-robin 0' prio=50 status=active
| |- 4:0:1:20 sded 128:80 active ready running
| `- 4:0:2:20 sdez 129:176 active ready running
`-+- policy='round-robin 0' prio=10 status=enabled
|- 3:0:1:20 sdcf 69:48 active ready running
`- 3:0:2:20 sddb 70:144 active ready running
2) this device has an alias, and only one path per port:
otsdcpp01_lun49 (360001ff0118e74c831000100000e8ded) dm-52 IBM,DCS9900
size=7.3T features='0' hwhandler='0' wp=rw
|-+- policy='round-robin 0' prio=1 status=active
| `- 2:0:0:33 sdd 8:48 active ready running
`-+- policy='round-robin 0' prio=1 status=enabled
`- 1:0:6:33 sdgl 132:16 active ready running
3) this one has 4 paths, alas via only one HBA - that should be reported:
360000970000296800131533030303638 dm-1 EMC,SYMMETRIX
size=600G features='1 queue_if_no_path' hwhandler='0' wp=rw
`-+- policy='round-robin 0' prio=1 status=active
|- 2:0:1:1 sdh 8:112 active ready running
|- 1:0:0:1 sdw 65:96 active ready running
|- 2:0:2:1 sdy 65:128 active ready running
`- 1:0:1:1 sdcr 69:240 active ready running
4) single-path device (here it's a local SCSI disk, but better to report it):
3600508b1001030384639323138300600 dm-53 HP,LOGICAL VOLUME
size=137G features='1 queue_if_no_path' hwhandler='0' wp=rw
`-+- policy='round-robin 0' prio=1 status=active
`- 0:0:0:0 sda 8:0 active ready running
The multipath command outputs the devices without any gaps, empty lines etc.
The output of the command doesn't have to be super-beautiful, ie dump the whole block of that device would the device be triggered as "insufficiently reduntantly pathed", so this parser would be something like "multi-line-block grep" filtering out "multi-path-over-multi-HBA" cases and leaving those which potentially need attention.
TIA !
CePal
P.S.: if someone with high-enough reputation can add "multipath" to the tags please, would be cool..