Combining Relevance Statements

Can anyone help me merge these three queries so that I can see something in an output like:

sda,12504,vmware,virtual disk

lines of files "size" of folders whose (name of it starts with "sd") of folder "/sys/block"

lines of files "/device/vendor" of folders whose (name of it starts with "sd") of folder "/sys/block/"

lines of files "/device/model" of folders whose (name of it starts with "sd") of folder "/sys/block/"

Normally you’ve have to worry about cross-products when you retrieve the lines of two files, but I think we can assume each of these files has only one line?

Try

(name of it, lines of files "size" of it, lines of files "/device/vendor" of it, lines of files "/device/model" of it) of folders whose (name of it starts with "sd") of folder "/sys/block/"

And maybe bundle those together with

Concatenation "," of (item 0 of it; item 1 of it; item 2 of it; item 3 of it) of ...
1 Like

just run “lsscsi” it will give you what you need.

# lsscsi
[0:0:0:0]    disk    VMware   Virtual disk     1.0   /dev/sda
[1:0:0:0]    cd/dvd  NECVMWar VMware IDE CDR00 1.00  /dev/sr0

or you can run “cat /proc/scsi/scsi”

$lsscsi
[0:0:8:0]    enclosu ORACLE   X5-2L            0407  -
[0:2:0:0]    disk    LSI      MR9361-8i        4.23  /dev/sda
[0:2:1:0]    disk    LSI      MR9361-8i        4.23  /dev/sdb
[0:2:2:0]    disk    LSI      MR9361-8i        4.23  /dev/sdc
[0:2:3:0]    disk    LSI      MR9361-8i        4.23  /dev/sdd
[0:2:4:0]    disk    LSI      MR9361-8i        4.23  /dev/sde
[0:2:5:0]    disk    LSI      MR9361-8i        4.23  /dev/sdf
[0:2:6:0]    disk    LSI      MR9361-8i        4.23  /dev/sdg
[0:2:7:0]    disk    LSI      MR9361-8i        4.23  /dev/sdh
[0:2:8:0]    disk    LSI      MR9361-8i        4.23  /dev/sdi
[0:2:9:0]    disk    LSI      MR9361-8i        4.23  /dev/sdj
[0:2:10:0]   disk    LSI      MR9361-8i        4.23  /dev/sdk
[0:2:11:0]   disk    LSI      MR9361-8i        4.23  /dev/sdl
[7:0:0:0]    disk    ORACLE   SSM              PMAP  /dev/sdm


$lsscsi
[0:0:0:0]    storage HP       P440ar           7.00  -
[0:1:0:0]    disk    HP       LOGICAL VOLUME   7.00  /dev/sda
[0:1:0:1]    disk    HP       LOGICAL VOLUME   7.00  /dev/sdb
[0:1:0:2]    disk    HP       LOGICAL VOLUME   7.00  /dev/sdc


$ cat /proc/scsi/scsi
Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
  Vendor: VMware   Model: Virtual disk     Rev: 1.0
  Type:   Direct-Access                    ANSI  SCSI revision: 02
Host: scsi1 Channel: 00 Id: 00 Lun: 00
  Vendor: NECVMWar Model: VMware IDE CDR00 Rev: 1.00
  Type:   CD-ROM                           ANSI  SCSI revision: 05

  
$ cat /proc/scsi/scsi
Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
  Vendor: HP       Model: P440ar           Rev: 7.00
  Type:   RAID                             ANSI  SCSI revision: 05
Host: scsi0 Channel: 01 Id: 00 Lun: 00
  Vendor: HP       Model: LOGICAL VOLUME   Rev: 7.00
  Type:   Direct-Access                    ANSI  SCSI revision: 05
Host: scsi0 Channel: 01 Id: 00 Lun: 01
  Vendor: HP       Model: LOGICAL VOLUME   Rev: 7.00
  Type:   Direct-Access                    ANSI  SCSI revision: 05
Host: scsi0 Channel: 01 Id: 00 Lun: 02
  Vendor: HP       Model: LOGICAL VOLUME   Rev: 7.00
  Type:   Direct-Access                    ANSI  SCSI revision: 05

This misses the size though :frowning:

This is perfection! I had played around with variations of this but couldn’t get it for love nor money :slight_smile:

Thanks again Jason!

1 Like
for file in `lsscsi|grep -v cd| awk ' {print $NF}'`; do parted $file print|grep Disk|grep -v Flags; done
Disk /dev/sda: 55.8GB
1 Like

Ah yeah sorry, meant to say I was trying to do this without running anything on the endpoints so it had to be pure relevance.