dsfmt

dsfmt (Dist Stats Formatter) is a simple CLI utility to format disk stats (aka cat /proc/diskstats).

Why dsfmt?

Do you love the output of /proc/diskstats?

cat /proc/diskstats
 254       0 vda 1285 10 165446 341 5648 85195 6054016 10639 0 3649 12176 580 0 244025032 40 1131 1155
 254       1 vda1 1078 10 156526 311 5314 85195 6054000 10449 0 3483 10802 580 0 244025032 40 0 0

Do you have the man page memorized?

Do you love counting columns to figure out what a number might be telling you?

Do you love miscounting columns and realizing that everything is fine, or everything is on fire?

Maybe you love eye tests where you try to read large numbers with no commas?

Or you just love doing millisecond conversions.

I don’t like any of these things, so I made a tool that makes looking at disk stats a lot easier.

Usage:

> cat /proc/diskstats | dsfmt
      DEVICE       | READS / MERGED | SECTORS READ | READ TIME | WRITES / MERGED | SECTORS WRITTEN | WRITE TIME | IOS NOW | IOS TIME | WEIGHTED IOS TIME | DISCARDS / MERGED | SECTORS DISCARDED | DISCARD TIME
--------------------+----------------+--------------+-----------+-----------------+-----------------+------------+---------+----------+-------------------+-------------------+-------------------+---------------
  nvme0n1 259/0     | 7807 / 1       |       757441 | 44.25s    | 3957 / 528      |          833976 | 12.81s     |       0 | 33.516s  | 43.956s           | 0 / 0             |                 0 | 0s
+                   +----------------+--------------+-----------+-----------------+-----------------+------------+---------+----------+-------------------+-------------------+-------------------+--------------+
                    | 7307 / 1       |       754441 | 44.25s    | 3957 / 528      |          833976 | 12.81s     |       0 | 33.516s  | 43.956s           | 0 / 0             |                 0 | 0s
+-------------------+----------------+--------------+-----------+-----------------+-----------------+------------+---------+----------+-------------------+-------------------+-------------------+--------------+
  nvme0n1p1 259/1   | 7669 / 1       |       752537 | 44.152s   | 3955 / 520      |          833896 | 12.804s    |       0 | 33.464s  | 43.932s           | 0 / 0             |                 0 | 0s
+                   +----------------+--------------+-----------+-----------------+-----------------+------------+---------+----------+-------------------+-------------------+-------------------+--------------+
                    | 7669 / 1       |       732537 | 44.152s   | 3955 / 520      |          833896 | 12.804s    |       0 | 33.464s  | 43.932s           | 0 / 0             |                 0 | 0s
+-------------------+----------------+--------------+-----------+-----------------+-----------------+------------+---------+----------+-------------------+-------------------+-------------------+--------------+
  nvme0n1p128 259/2 | 45 / 0         |          360 | 19ms      | 0 / 0           |               0 | 0s         |       0 | 40ms     | 0s                | 0 / 0             |                 0 | 0s
+                   +----------------+--------------+-----------+-----------------+-----------------+------------+---------+----------+-------------------+-------------------+-------------------+--------------+
                    | 45 / 0         |          320 | 19ms      | 0 / 0           |               0 | 0s         |       0 | 40ms     | 0s                | 0 / 0             |                 0 | 0s
--------------------+----------------+--------------+-----------+-----------------+-----------------+------------+---------+----------+-------------------+-------------------+-------------------+---------------

Or use a shorter format which excludes Discard and Flush stats:

> cat /proc/diskstats | dsfmt --short
       DEVICE       | READS / MERGED | SECTORS READ | READ TIME | WRITES / MERGED | SECTORS WRITTEN | WRITE TIME | IOS NOW | IOS TIME | WEIGHTED IOS TIME
--------------------+----------------+--------------+-----------+-----------------+-----------------+------------+---------+----------+--------------------
  nvme0n1 259/0     | 7807 / 1       |       757441 | 44.25s    | 3957 / 528      |          833976 | 12.81s     |       0 | 33.516s  | 43.956s
+                   +----------------+--------------+-----------+-----------------+-----------------+------------+---------+----------+-------------------+
                    | 7307 / 1       |       754441 | 44.25s    | 3957 / 528      |          833976 | 12.81s     |       0 | 33.516s  | 43.956s
+-------------------+----------------+--------------+-----------+-----------------+-----------------+------------+---------+----------+-------------------+
  nvme0n1p1 259/1   | 7669 / 1       |       752537 | 44.152s   | 3955 / 520      |          833896 | 12.804s    |       0 | 33.464s  | 43.932s
+                   +----------------+--------------+-----------+-----------------+-----------------+------------+---------+----------+-------------------+
                    | 7669 / 1       |       732537 | 44.152s   | 3955 / 520      |          833896 | 12.804s    |       0 | 33.464s  | 43.932s
+-------------------+----------------+--------------+-----------+-----------------+-----------------+------------+---------+----------+-------------------+
  nvme0n1p128 259/2 | 45 / 0         |          360 | 19ms      | 0 / 0           |               0 | 0s         |       0 | 40ms     | 0s
+                   +----------------+--------------+-----------+-----------------+-----------------+------------+---------+----------+-------------------+
                    | 45 / 0         |          320 | 19ms      | 0 / 0           |               0 | 0s         |       0 | 40ms     | 0s
--------------------+----------------+--------------+-----------+-----------------+-----------------+------------+---------+----------+--------------------

Installation

Packages, binaries, and archives are published for all major platforms (Mac amd64/arm64 & Linux amd64/arm64):

Debian / Ubuntu:

[[ `uname -m` == "aarch64" ]] && ARCH="arm64" || ARCH="amd64"
OS=`uname | tr '[:upper:]' '[:lower:]'`
wget https://github.com/bwagner5/dsfmt/releases/download/v0.0.2/dsfmt_0.0.2_${OS}_${ARCH}.deb
dpkg --install dsfmt_0.0.2_linux_amd64.deb
cat /proc/diskstats | dsfmt

RedHat:

[[ `uname -m` == "aarch64" ]] && ARCH="arm64" || ARCH="amd64"
OS=`uname | tr '[:upper:]' '[:lower:]'`
rpm -i https://github.com/bwagner5/dsfmt/releases/download/v0.0.2/dsfmt_0.0.2_${OS}_${ARCH}.rpm

Download Binary Directly:

[[ `uname -m` == "aarch64" ]] && ARCH="arm64" || ARCH="amd64"
OS=`uname | tr '[:upper:]' '[:lower:]'`
curl -Lo dsfmt https://github.com/bwagner5/dsfmt/releases/download/v0.0.2/dsfmt_0.0.2_${OS}_${ARCH} 
chmod +x dsfmt

GitHub

View Github