M
M
mkone1122021-02-19 15:58:47
linux
mkone112, 2021-02-19 15:58:47

How to display the current percentage of disk usage in the terminal, similar to the Windows task manager?

Expectation:

$ <some_magick_command>
>>
sda    50%
sdb    37%

At the same time, it is not a display of new lines, but an update of the current screen, as in top - i.e. the terminal should always display, say, 2 lines with the current download.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry, 2021-02-19
@Tabletko

use iotop or iostat

X
xotkot, 2021-02-19
@xotkot

something like this:

DISK=(/dev/nvme0n1 /dev/loop0)
TIME=2
while :; do
  i=$(iostat -dsxy $TIME 1 -o JSON ${DISK[*]} | jq -r '.sysstat.hosts[].statistics[].disk[] | "\(.disk_device)\t\(.util) %"')
  clear
  echo -n -e "$i\n"
done

disks and time we put our
conclusion:
loop0	0.35 %
nvme0n1	0.42 %

ps
but as far as I can tell the value of the iostat utility util is only suitable for hard drives, based on the description
%util
Percentage of elapsed time during which I/O requests were issued to the device (bandwidth utilization for the device). Device saturation occurs when this value is close to 100% for devices serving requests serially. But for devices serving requests in parallel, such as RAID arrays and modern SSDs, this number does not reflect their performance limits.

P
pfg21, 2021-02-19
@pfg21

take the df exhaust and filter to suit your needs.

$ df -h
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/sda1             4.0G  2.4G  1.5G  62% /
    /dev/sda2              29G   14G   14G  50% /usr
    /dev/sda3              62G  2.6G   56G   5% /var
    tmpfs                 512M   60K  512M   1% /tmp

play around with tmux for interactivity

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question