0

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..

cepal67
  • 11
  • 2
  • Welcome to StackOverflow! Can you please show us your work so far? Folks here will be only too happy to help you figure out coding problems, but may be reluctant to simply hand you a finished solution to a system administration challenge. On StackOverflow, everything starts with your code. – ghoti Jan 05 '16 at 13:55
  • Hello ghoti; I don't need a whole solution, I need the first step hint: how do I parse over multiple lines simply. My first step was I crawled through solutions on here and elsewhere and they'd have been specifically tailored codes for particular input & output formats without much explanation so that I could use them as templates for my case. I have done multiline parsing only many years ago, in perl, and have forgotten by far more than the all of that experience since... – cepal67 Jan 05 '16 at 14:37
  • I'm not going to take on writing original code for this at this time. I suggest you look at implementing a small state machine that implements your rules, perhaps using awk with a number of state variables (position and counters). You might get some ideas from [this question](http://stackoverflow.com/q/14350856/1072112). – ghoti Jan 05 '16 at 17:22

0 Answers0