Last active
February 11, 2017 22:57
-
-
Save norpol/ff54a3cefcba4a89882147bb76ca36f7 to your computer and use it in GitHub Desktop.
tiny iotop alternative
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# 2017 © MIT https://gist.github.com/norpol/ | |
# Usage: pidiotop.sh <PID> | |
# Example: pidiotop.sh $(pgrep -n dd) | |
# Requires: bc | |
set -ue | |
pid="${1}" | |
interval=10 | |
bbytes= | |
bytes= | |
while true; do | |
bbytes="${bytes}" | |
bytes=$(awk -v rbytes='read_bytes:' '$1 == rbytes { print $2; exit}' "/proc/${1}/io") | |
if [ -n "${bbytes}" ]; then | |
mbs=$(echo "(${bytes}-${bbytes})/${interval}/1000/1000" | bc -l) | |
printf "\r${mbs}MB/s" | |
fi | |
sleep "${interval}"s | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment