I know the title of the post is long. With that out of the way lets get started.
Today I'll share a quick one liner to provide the size of attached disks in a neat format with iostat command in Solaris.
So, here's what the iostat -En command output looks like :
[ssuri@:~] $ sudo iostat -En
c21d0 Soft Errors: 0 Transport Errors: 0 Protocol Errors: 0
Vendor: SUN Product: VDSK Size: 137.67GB <137665445888 bytes>
c21d1 Soft Errors: 0 Transport Errors: 0 Protocol Errors: 0
Vendor: SUN Product: VDSK Size: 137.67GB <137665445888 bytes>
Today I'll share a quick one liner to provide the size of attached disks in a neat format with iostat command in Solaris.
So, here's what the iostat -En command output looks like :
[ssuri@:~] $ sudo iostat -En
c21d0 Soft Errors: 0 Transport Errors: 0 Protocol Errors: 0
Vendor: SUN Product: VDSK Size: 137.67GB <137665445888 bytes>
c21d1 Soft Errors: 0 Transport Errors: 0 Protocol Errors: 0
Vendor: SUN Product: VDSK Size: 137.67GB <137665445888 bytes>
And this is the one liner to format it so that we get a two column output consisting of the disk name and disk size only.
sudo iostat -En | awk '{print $1, $6}' | tr -d "Errors:" | sed 's/Vend//g' | sed '$!N;$!N;s/\n/ /g'
Given below is the output of the above one liner:
c21d0 137.67GB
c21d1 137.67GB
c21d2 274.88GB
c21d11 34.36GB
c21d12 34.36GB
c21d13 34.36GB
c21d14 34.36GB
c21d15 34.36GB
c21d16 34.36GB
c21d17 34.36GB
c21d18 68.72GB
c21d19 274.88GB
Now coming to the Linux part.
I was recently tasked with getting information on total connected SAN storage excluding the root & swap disks for some Linux servers.
I could've used fdisk but I used lsblk instead.
Here is the default output of lsblk without any filters:
[ssuri@:~] $ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 1024M 0 rom
sdb 8:16 0 32G 0 disk
`-grid_vg-grid_lv (dm-4) 253:4 0 32G 0 lvm /grid
sdc 8:32 0 24G 0 disk
`-kdump_vg-kdump_lv (dm-3) 253:3 0 24G 0 lvm
sdd 8:48 0 32G 0 disk
`-elmerd5db_vg-lvol1 (dm-2) 253:2 0 32G 0 lvm /elmerd5db/db
sde 8:64 0 32G 0 disk
`-sde1 8:65 0 32G 0 part
sdf 8:80 0 256G 0 disk
`-sdf1 8:81 0 256G 0 part
sdg 8:96 0 32G 0 disk
`-sdg1 8:97 0 32G 0 part
sda 8:0 0 60G 0 disk
|-sda1 8:1 0 512M 0 part /boot
`-sda2 8:2 0 59.5G 0 part
|-os_vg-root_lv (dm-0) 253:0 0 16G 0 lvm /
|-os_vg-swap_01_lv (dm-1) 253:1 0 4G 0 lvm [SWAP]
|-os_vg-tmp_lv (dm-5) 253:5 0 2G 0 lvm /tmp
|-os_vg-var_lv (dm-6) 253:6 0 10G 0 lvm /var
`-os_vg-hpds_lv (dm-7) 253:7 0 12G 0 lvm /var/opt/perf/datafiles
sdi 8:128 0 32G 0 disk
`-sdi1 8:129 0 32G 0 part
sdh 8:112 0 32G 0 disk
`-sdh1 8:113 0 32G 0 part
Now coming to the Linux part.
I was recently tasked with getting information on total connected SAN storage excluding the root & swap disks for some Linux servers.
I could've used fdisk but I used lsblk instead.
Here is the default output of lsblk without any filters:
[ssuri@:~] $ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 1024M 0 rom
sdb 8:16 0 32G 0 disk
`-grid_vg-grid_lv (dm-4) 253:4 0 32G 0 lvm /grid
sdc 8:32 0 24G 0 disk
`-kdump_vg-kdump_lv (dm-3) 253:3 0 24G 0 lvm
sdd 8:48 0 32G 0 disk
`-elmerd5db_vg-lvol1 (dm-2) 253:2 0 32G 0 lvm /elmerd5db/db
sde 8:64 0 32G 0 disk
`-sde1 8:65 0 32G 0 part
sdf 8:80 0 256G 0 disk
`-sdf1 8:81 0 256G 0 part
sdg 8:96 0 32G 0 disk
`-sdg1 8:97 0 32G 0 part
sda 8:0 0 60G 0 disk
|-sda1 8:1 0 512M 0 part /boot
`-sda2 8:2 0 59.5G 0 part
|-os_vg-root_lv (dm-0) 253:0 0 16G 0 lvm /
|-os_vg-swap_01_lv (dm-1) 253:1 0 4G 0 lvm [SWAP]
|-os_vg-tmp_lv (dm-5) 253:5 0 2G 0 lvm /tmp
|-os_vg-var_lv (dm-6) 253:6 0 10G 0 lvm /var
`-os_vg-hpds_lv (dm-7) 253:7 0 12G 0 lvm /var/opt/perf/datafiles
sdi 8:128 0 32G 0 disk
`-sdi1 8:129 0 32G 0 part
sdh 8:112 0 32G 0 disk
`-sdh1 8:113 0 32G 0 part
I know that I'm using disk sda and sdc for root and swap space respectively.
So lets limit the output to disk devices and filter out disks /dev/sda and /dev/sdc.
[ssuri@:~] $ lsblk | egrep disk | grep -v "sd[ac]"
sdb 8:16 0 32G 0 disk
sdd 8:48 0 32G 0 disk
sde 8:64 0 32G 0 disk
sdf 8:80 0 256G 0 disk
sdg 8:96 0 32G 0 disk
sdi 8:128 0 32G 0 disk
sdh 8:112 0 32G 0 disk
Now, I'll use awk to calculate the total size of these disks:
[ssuri@:~] $ lsblk | egrep disk | grep -v "sd[ac]" | tr -d "G" | awk '{sum+=$4} END {print sum}'
448
A quick and easy time saver.
No comments:
Post a Comment