Skip to content

Commit f0a88e5

Browse files
committed
Update parseMultipathOutput()
1 parent 945f58d commit f0a88e5

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

SAMPLE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ size=3.3T features='1 queue_if_no_path' hwhandler='1 alua' wp=rw
3232
|- 11:0:5:1 sdy 65:128 active ready running
3333
|- 13:0:2:1 sdau 66:224 active ready running
3434
- 13:0:4:1 sdcb 68:240 active ready running
35-
mpathc (360060160e7d04900afacea671f2bd112) dm-3 DGC,VRAID
35+
iso_coldstore (360060160e7d04900afacea671f2bd112) dm-3 DGC,VRAID
3636
size=20T features='1 queue_if_no_path' hwhandler='1 alua' wp=rw
3737
|-+- policy='service-time 0' prio=50 status=active
3838
| |- 11:0:1:10 sdl 8:176 active ready running

assets/js/script.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,20 @@ function parseMultipathOutput(input) {
2727
for (let i = 0; i < lines.length; i++) {
2828
const line = lines[i];
2929

30-
// Match: mpathX (wwid)
31-
const wwidMatch = line.match(/^mpath\w+\s+\((.*?)\)/);
32-
if (wwidMatch) {
33-
const wwid = wwidMatch[1];
30+
// Match: <alias> (wwid) or mpathX (wwid)
31+
const match = line.match(/^([\w\-]+)\s+\(([0-9a-f]+)\)/i);
32+
if (match) {
33+
const alias = match[1]; // can be a friendly name or mpathX
34+
const wwid = match[2];
3435
let size = "UNKNOWN";
3536
let lun = "UNKNOWN";
3637

38+
// Look ahead for size and LUN info
3739
for (let j = i; j < i + 15 && j < lines.length; j++) {
3840
const lookahead = lines[j];
3941

40-
if (lookahead.includes("size=")) {
41-
const sizeMatch = lookahead.match(/size=([\d\.]+[TG])/);
42-
if (sizeMatch) size = sizeMatch[1];
43-
}
42+
const sizeMatch = lookahead.match(/size=([\d.]+[TG])/);
43+
if (sizeMatch) size = sizeMatch[1];
4444

4545
const lunMatch = lookahead.match(/\d+:\d+:\d+:(\d+)/);
4646
if (lunMatch) {
@@ -49,13 +49,14 @@ function parseMultipathOutput(input) {
4949
}
5050
}
5151

52-
entries.push({ wwid, size, lun, alias: "unknown-alias" });
52+
entries.push({ alias, wwid, size, lun });
5353
}
5454
}
5555

5656
return entries;
5757
}
5858

59+
5960
function formatMultipathConf(entries) {
6061
const output = [];
6162
output.push("multipaths {\n");

0 commit comments

Comments
 (0)