Map sar device names
Jump to navigation
Jump to search
"sar -d 5" is my favorite way to get disk latency numbers, but the device names it reports are just major, minor numbers. This isn't how I think about filesystems, so I need to map to a human-readable filesystem name to understand the latency numbers that are reported.
the output of sar -d 5 looks like this for me
10:58:34 AM DEV tps rd_sec/s wr_sec/s avgrq-sz avgqu-sz await svctm %util 10:58:39 AM dev8-0 1.60 0.00 363.20 227.00 0.02 15.00 9.50 1.52 10:58:39 AM dev8-16 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 10:58:39 AM dev252-0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 10:58:39 AM dev252-1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 10:58:39 AM dev252-2 45.40 0.00 363.20 8.00 0.66 14.63 0.33 1.52 10:58:39 AM dev8-32 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 10:58:39 AM dev252-3 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 10:58:39 AM dev252-4 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 10:58:39 AM dev8-64 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 10:58:39 AM dev8-80 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 ^C
I get major/minor device numbers with "ls -lL /dev/" and read through looking for a match
I happen to already know the general range of devices that have traffic, so I've narrowed down my list, but the first time I did this, I went through all of /dev. In this example, I'm looking for the dev8-0 and dev252-2 since they are busy writing at the moment.
root@weasel:~# ls -lL /dev/sda* brw-rw---- 1 root disk 8, 0 Mar 23 08:06 /dev/sda brw-rw---- 1 root disk 8, 1 Mar 23 08:06 /dev/sda1 brw-rw---- 1 root disk 8, 2 Mar 23 08:06 /dev/sda2 brw-rw---- 1 root disk 8, 5 Mar 23 08:06 /dev/sda5 root@weasel:~# ls -lL /dev/dm* brw-rw---- 1 root disk 252, 0 Mar 23 08:06 /dev/dm-0 brw-rw---- 1 root disk 252, 1 Mar 23 08:06 /dev/dm-1 brw-rw---- 1 root disk 252, 2 Mar 23 08:06 /dev/dm-2 brw-rw---- 1 root disk 252, 3 Mar 23 08:06 /dev/dm-3 brw-rw---- 1 root disk 252, 4 Mar 23 08:06 /dev/dm-4
Here I see the device names of interest are /dev/sda and /dev/dm-2. Looking in /dev/mapper, I can see the friendly name for dm-2 is Ubuntu-root.
root@weasel:~# ls -l /dev/mapper total 0 crw------- 1 root root 10, 236 Mar 23 08:06 control lrwxrwxrwx 1 root root 7 Mar 23 08:06 netstore-netstore -> ../dm-0 lrwxrwxrwx 1 root root 7 Mar 23 08:06 netstore-store -> ../dm-1 lrwxrwxrwx 1 root root 7 Mar 23 08:06 rootback-rootback -> ../dm-4 lrwxrwxrwx 1 root root 7 Mar 23 08:06 Ubuntu-root -> ../dm-2 lrwxrwxrwx 1 root root 7 Mar 23 08:06 Ubuntu-swap_1 -> ../dm-3
dmsetup ls
Another way to map major/minor numbers and names.
root@weasel:~# dmsetup ls Ubuntu-swap_1 (252, 3) netstore-netstore (252, 0) Ubuntu-root (252, 2) netstore-store (252, 1) rootback-rootback (252, 4)
tell iostat to give me the names
root@weasel:~# iostat -xN 5 Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util sda 0.00 35.20 0.00 2.80 0.00 151.20 108.00 0.02 6.00 0.00 6.00 5.14 1.44 sdb 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 netstore-netstore 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 netstore-store 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 Ubuntu-root 0.00 0.00 0.00 37.80 0.00 151.20 8.00 0.20 5.31 0.00 5.31 0.38 1.44 sdc 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 Ubuntu-swap_1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 rootback-rootback 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 sde 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 sdf 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00