Identify sar -d devices in Solaris and Linux

Sar is one of the most powerful performance measuring tools available for Linux, FreeBSD and Solaris or Illumos based distros, one of the issues most people encounter is mapping the disks when using sar -d.


1. Mappings in Solaris

An example of sar -d in Solaris (This is an OpenIndiana box actually)

root@solarisbox:~# sar -d 1

SunOS solarisbox 5.11 oi_151a7p1 i86pc    11/30/2015

11:29:03   device        %busy   avque   r+w/s  blks/s  avwait  avserv

11:29:04   sd6.t1.m          0     0.0       0       0     0.0     0.0
           sd7.t2.m          0     0.0       0       0     0.0     0.0
           sd8.t3.m          0     0.0       0       0     0.0     0.0
           sd0               0     0.0       0       0     0.0     0.0
           sd0,a             0     0.0       0       0     0.0     0.0
           sd0,c             0     0.0       0       0     0.0     0.0
           sd0,i             0     0.0       0       0     0.0     0.0
           sd0,q             0     0.0       0       0     0.0     0.0
           sd0,r             0     0.0       0       0     0.0     0.0
           sd1               0     0.0       0       0     0.0     0.0
           sd1,a             0     0.0       0       0     0.0     0.0
           sd1,h             0     0.0       0       0     0.0     0.0
           sd1,i             0     0.0       0       0     0.0     0.0
           sd1,q             0     0.0       0       0     0.0     0.0
           sd4               0     0.0       0       0     0.0     0.0
           sd4,q             0     0.0       0       0     0.0     0.0
           sd4,r             0     0.0       0       0     0.0     0.0
           sd4,s             0     0.0       0       0     0.0     0.0
           sd4,t             0     0.0       0       0     0.0     0.0
           sd4,u             0     0.0       0       0     0.0     0.0
           sd6               0     0.0       0       0     0.0     0.0
           sd6,a             0     0.0       0       0     0.0     0.0
           sd6,h             0     0.0       0       0     0.0     0.0
           sd6,i             0     0.0       0       0     0.0     0.0
           sd6,q             0     0.0       0       0     0.0     0.0
           sd7               0     0.0       0       0     0.0     0.0
           sd7,a             0     0.0       0       0     0.0     0.0
           sd7,h             0     0.0       0       0     0.0     0.0
           sd7,i             0     0.0       0       0     0.0     0.0
           sd7,q             0     0.0       0       0     0.0     0.0
           sd8               0     0.0       0       0     0.0     0.0
           sd8,a             0     0.0       0       0     0.0     0.0
           sd8,h             0     0.0       0       0     0.0     0.0
           sd8,i             0     0.0       0       0     0.0     0.0
           sd8,q             0     0.0       0       0     0.0     0.0

Iostat would show the devices as seen by the OS.

root@solarisbox:~# iostat -xn
extended device statistics
    r/s    w/s   kr/s   kw/s wait actv wsvc_t asvc_t  %w  %b device
    0.0   10.3    0.4   88.1  0.2  0.0   16.2    1.2   1   1 rpool
    2.0   12.2    1.5   88.1  0.0  0.0    0.0    0.8   0   1 c1t0d0
    0.0    0.0    4.4    0.1  0.0  0.0    0.0    0.3   0   0 c1t1d0
    0.2    0.0    0.2    0.0  0.0  0.0    0.0    0.1   0   0 c0t50000C0F02E8FBEAd0
    2.5    1.5   12.8    0.0  0.0  0.0    0.0    0.0   0   0 c2t500003957C887080d0
    2.5    1.5   12.8    1.3  0.0  0.0    0.0    0.0   0   0 c2t500003954C88E20Cd0
    0.2    0.0    0.1    0.0  0.0  0.0    0.0    0.0   0   0 c2t500003955C883E14d0
    2.8    1.5   12.8    0.1  0.0  0.0    0.0    0.0   0   0 c2t6000402003E019CE7D83479D00000000d0
    2.8    1.5   12.9    0.8  0.0  0.0    0.0    0.0   0   0 c2t6000402003E019CE7D83479200000000d0
    2.8    1.5   12.9    0.8  0.0  0.0    0.0    0.0   0   0 c2t6000402003E019CE7D83479600000000d0
    2.4    1.5   12.9    0.8  0.0  0.0    0.0    0.0   0   0 c2t6000402003E019CE7D83478700000000d0

To map these devices to sd0, sd1, sd7 etc as displayed by sar, one can use this commands in a small script:

#!/bin/bash
ls -l /dev/rdsk/*s2 | nawk '{sub(".*devices/pci","/pci",$NF);sub(":.*","",$NF);sub(".*/","",$(NF-2));print "\""$NF"\"", $(NF-2)}' | sort > dev_to_disk

nawk '/sd/ {gsub("\"","",$3);print $1, $3 $2}'  /etc/path_to_inst | sort > disk_to_sar
exit 0


This script will allow you to map devices seens with format for examples, to the names used by sar.
It will create 2 files containing the mappings.

2. Linux

In Linux this is a bit easier, as one needs to just list the devices (either /dev/sd* or /dev/disk/by-id/* or /dev/zvol/) to see it's major and minor numbers. sar in Linux is using major and minor for each device.

Example:


Average:          DEV       tps  rd_sec/s  wr_sec/s  avgrq-sz  avgqu-sz     await     svctm     %util
Average:       dev2-0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
Average:       dev8-0      2.59      0.00     20.69      8.00      0.01      3.33      1.17      0.30
Average:      dev8-16      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
Average:      dev8-32      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
Average:      dev8-48      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
Average:      dev8-64      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
Average:      dev11-0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00


root@linuxboxs ~]# ls  -Ll /dev/sd*
brw-rw---- 1 root disk 8,  0 Nov 26 15:20 /dev/sda
brw-rw---- 1 root disk 8,  1 Nov 26 15:20 /dev/sda1
brw-rw---- 1 root disk 8, 16 Nov 26 15:20 /dev/sdb
brw-rw---- 1 root disk 8, 17 Nov 26 15:20 /dev/sdb1
brw-rw---- 1 root disk 8, 25 Nov 26 15:20 /dev/sdb9
brw-rw---- 1 root disk 8, 32 Nov 26 15:20 /dev/sdc
brw-rw---- 1 root disk 8, 33 Nov 26 15:20 /dev/sdc1
brw-rw---- 1 root disk 8, 41 Nov 26 15:20 /dev/sdc9
brw-rw---- 1 root disk 8, 48 Nov 26 15:20 /dev/sdd
brw-rw---- 1 root disk 8, 49 Nov 26 15:20 /dev/sdd1
brw-rw---- 1 root disk 8, 57 Nov 26 15:20 /dev/sdd9
brw-rw---- 1 root disk 8, 64 Nov 26 15:20 /dev/sde
brw-rw---- 1 root disk 8, 65 Nov 26 15:20 /dev/sde1
brw-rw---- 1 root disk 8, 73 Nov 26 15:20 /dev/sde9


root@linuxbox ~]# ls -Ll /dev/fd0
brw-rw---- 1 root disk 2, 0 Nov 26 15:20 /dev/fd0


or

root@linuxbox ~]# ls -Ll /dev/disk/by-id/*
brw-rw---- 1 root optical 11,  0 Nov 26 15:20 /dev/disk/by-id/ata-VMware_Virtual_SATA_CDRW_Drive_01000000000000000001
brw-rw---- 1 root disk     8, 64 Nov 26 15:20 /dev/disk/by-id/ata-VMware_Virtual_SATA_Hard_Drive_00000000000000000001
brw-rw---- 1 root disk     8, 65 Nov 26 15:20 /dev/disk/by-id/ata-VMware_Virtual_SATA_Hard_Drive_00000000000000000001-part1
brw-rw---- 1 root disk     8, 73 Nov 26 15:20 /dev/disk/by-id/ata-VMware_Virtual_SATA_Hard_Drive_00000000000000000001-part9
brw-rw---- 1 root disk     8, 64 Nov 26 15:20 /dev/disk/by-id/wwn-0x11209473928355008512x
brw-rw---- 1 root disk     8, 65 Nov 26 15:20 /dev/disk/by-id/wwn-0x11209473928355008512x-part1
brw-rw---- 1 root disk     8, 73 Nov 26 15:20 /dev/disk/by-id/wwn-0x11209473928355008512x-part9
brw-rw---- 1 root disk     8, 64 Nov 26 15:20 /dev/disk/by-id/wwn-0x5000c29a0d259b90
brw-rw---- 1 root disk     8, 65 Nov 26 15:20 /dev/disk/by-id/wwn-0x5000c29a0d259b90-part1
brw-rw---- 1 root disk     8, 73 Nov 26 15:20 /dev/disk/by-id/wwn-0x5000c29a0d259b90-part9


One can just create a small script to create a mapping file for future reference.

Or just run lsblk

root@linuxbox ~]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
fd0      2:0    1    4K  0 disk
sda      8:0    0   20G  0 disk
└─sda1   8:1    0   20G  0 part /
sdb      8:16   0   20G  0 disk
├─sdb1   8:17   0   20G  0 part
└─sdb9   8:25   0    8M  0 part
sdc      8:32   0   20G  0 disk
├─sdc1   8:33   0   20G  0 part
└─sdc9   8:41   0    8M  0 part
sdd      8:48   0    1G  0 disk
├─sdd1   8:49   0 1014M  0 part
└─sdd9   8:57   0    8M  0 part
sde      8:64   0    1G  0 disk
├─sde1   8:65   0 1014M  0 part
└─sde9   8:73   0    8M  0 part