Giter VIP home page Giter VIP logo

iotop's Introduction

iotop

Is your Linux server too slow or load is too high? One of the possible causes of such symptoms may be high IO (input/output) waiting time, which basically means that some of your processes need to read or write to a hard drive while it is too slow and not ready yet, serving data for some other processes.

Common practice is to use iostat -x in order to find out which block device (hard drive) is slow, but this information is not always helpful. It could help you much more if you knew which process reads or writes the most data from your slow disk, so you could renice it using ionice or even kill it.

iotop identifies processes that use high amount of input/output requests on your machine. It is similar to the well known top utility, but instead of showing you what consumes CPU the most, it lists processes by their IO usage. Inspired by iotop Python script from Guillaume Chazarain, rewritten in C by Vyacheslav Trushkin and improved by Boian Bonev so it runs without Python at all.

iotop is licensed GPL-2.0+

Packaging status

Sample screenshot

iotop screenshot

How to install from binary package

Many Linux distributions already include this program under the name iotop-c.

If your distribution is relatively new, chances are that it already has iotop packaged. Follow these instructions.

In case it is not available, follow the How to build from source instructions.

Debian/Devuan/Ubuntu/other derivatives  

Use the following command (note that -y disables confirmation prompts):

sudo apt install iotop-c -y
Fedora  

Use the following command (note that -y disables confirmation prompts):

sudo dnf install iotop-c -y
CentOS 7/CentOS 8/RHEL 7/RHEL 8/RHEL 9  

Use the following commands (note that -y disables confirmation prompts):

sudo yum install epel-release -y
sudo yum install iotop-c -y
Void Linux  

Use the following command:

sudo xbps-install iotop-c
Arch Linux  

Use the following command:

sudo pacman -S iotop-c

How to build from source

Please note that the installation and the usage of this program require root access.

Debian/Devuan/Ubuntu/other derivatives  

Use the following commands (note that -y disables confirmation prompts):

apt install git build-essential libncurses-dev libncursesw5-dev pkg-config -y
git clone https://github.com/Tomas-M/iotop
cd iotop
make -j
Fedora  

Use the following commands (note that -y disables confirmation prompts):

dnf install git gcc make ncurses-devel pkgconfig -y
git clone https://github.com/Tomas-M/iotop
cd iotop
make -j
CentOS 8/RHEL 8/RHEL 9  

Use the following commands (note that -y disables confirmation prompts):

yum install git gcc make ncurses-devel pkgconfig -y
git clone https://github.com/Tomas-M/iotop
cd iotop
make -j
CentOS 7/RHEL 7  

Note: On CentOS 7/RHEL 7 gcc does not support -Wdate-time and needs a -Wno-strict-overflow to suppress a pile of bogus warnings.

Use the following commands (note that -y disables confirmation prompts):

yum install git gcc make ncurses-devel pkgconfig -y
git clone https://github.com/Tomas-M/iotop
cd iotop
sed -i 's/-Wdate-time/-Wno-strict-overflow/' Makefile
make -j
Void Linux  

Use the following commands:

xbps-install git base-devel ncurses-devel
git clone https://github.com/Tomas-M/iotop
cd iotop
make -j

How to install as a system command

sudo make install

How to update to latest version

cd iotop && git checkout master && git pull && make clean && make -j

Options

-v, --version          show program's version number and exit
-h, --help             show this help message and exit
-H, --help-type=TYPE   set type of interactive help (none, win or inline)
-o, --only             only show processes or threads actually doing I/O
    --no-only          show all processes or threads
-b, --batch            non-interactive mode
-n NUM, --iter=NUM     number of iterations before ending [infinite]
-d SEC, --delay=SEC    delay between iterations [1 second]
-p PID, --pid=PID      processes/threads to monitor [all]
-u USER, --user=USER   users to monitor [all]
-P, --processes        only show processes, not all threads
    --threads          show all threads
-a, --accumulated      show accumulated I/O instead of bandwidth
    --no-accumulated   show bandwidth
-A, --accum-bw         show accumulated bandwidth
    --no-accum-bw      show last iteration bandwidth
-k, --kilobytes        use kilobytes instead of a human friendly unit
    --no-kilobytes     use human friendly unit
-t, --time             add a timestamp on each line (implies --batch)
-c, --fullcmdline      show full command line
    --no-fullcmdline   show program names only
-1, --hide-pid         hide PID/TID column
    --show-pid         show PID/TID column
-2, --hide-prio        hide PRIO column
    --show-prio        show PRIO column
-3, --hide-user        hide USER column
    --show-user        show USER column
-4, --hide-read        hide DISK READ column
    --show-read        show DISK READ column
-5, --hide-write       hide DISK WRITE column
    --show-write       show DISK WRITE column
-6, --hide-swapin      hide SWAPIN column
    --show-swapin      show SWAPIN column
-7, --hide-io          hide IO column
    --show-io          show IO column
-8, --hide-graph       hide GRAPH column
    --show-graph       show GRAPH column
-9, --hide-command     hide COMMAND column
    --show-command     show COMMAND column
-g TYPE, --grtype=TYPE set graph data source (io, r, w, rw and sw)
-R, --reverse-graph    reverse GRAPH column direction
    --no-reverse-graph do not reverse GRAPH column direction
-q, --quiet            suppress some lines of header (implies --batch)
-x, --dead-x           show exited processes/threads with letter x
    --no-dead-x        show exited processes/threads with background
-e, --hide-exited      hide exited processes
    --show-exited      show exited processes
-l, --no-color         do not colorize values
    --color            colorize values
-T, --hide-time        hide current time
    --show-time        show current time
    --si               use SI units of 1000 when printing values
    --no-si            use non-SI units of 1024 when printing values
    --threshold=1..10  threshold to switch to next unit
    --ascii            disable using Unicode
    --unicode          use Unicode drawing chars
-W, --write            write preceding options to the config and exit

Contribute

iotop was originally written by Vyacheslav Trushkin in 2014, distributed by Tomas Matejicek and later improved by Boian Bonev.

iotop is maintaned on GitHub at https://github.com/Tomas-M/iotop

The preferred way to contribute to the project is to file a pull request at GitHub.

Contacts of current maintainers are:

The iotop community gathers in #iotop on libera.chat:

Notable contributions (ordered by time of last contribution):

Thanks! This project is what it is now because the steam you have put into it

NB. In case you have contributed to the project and do not see your name in the list, please note that the above list is updated manually and it is an omission - notify the maintainers to fix it.

iotop's People

Contributors

alicektx avatar amonakov avatar bbonev avatar bokunodev avatar cade-vs avatar christian-heusel avatar debian-janitor avatar einprofispieler avatar filipkofron avatar jiasli avatar mikoxyz avatar rjekov avatar tomas-m avatar uhle avatar yumkam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

iotop's Issues

98% CPU use

Is it normal that iotop consumes 98% CPU when running? It completely hogs one CPU core.

I'm using version 1.24.

2023-10-05-14-03-00-251980868

FR: Add configuration file

I'd like to save my defaults for which column to sort, which columns to show or whether to show idle processes. This also opens the path to additional settings/preferences not everyone might like.

FR: add iops count

wouldn't it be useful to have iotop monitor iops instead of read/write throughput, too ?
(to be able to determine which process is an iops hog , which totally matters, especially with ordinary hdd)

from linux process info, this should be available (syscr/syscw)

cat /proc/2577/io

rchar: 231362397403320
wchar: 60299521079984
syscr: 8486645208
syscw: 2586473645
read_bytes: 191716084186159
write_bytes: 30517886778390
cancelled_write_bytes: 726028288

rchar: number of bytes the process read, using any read-like system call (from files, pipes, tty...).
wchar: number of bytes the process wrote using any write-like system call.
syscr: number of read-like system call invocations that the process performed.
syscr: number of write-like system call invocations that the process performed.
read_bytes: number of bytes the process directly read from disk.
write_bytes: number of bytes the process originally dirtied in the page-cache (assuming they will go to disk later).
cancelled_write_bytes: number of bytes the process "un-dirtied" - e.g. using an "ftruncate" call that truncated pages from the page-cache.  

http://www.haifux.org/lectures/254/alice_and_bob_in_io_land/node51.html

Add option for different characters for graphics

When running iotop on the Linux console (and, I assume, any terminal without braille support), we are limited to the characters provided in the console font - that somewhat restricts what can be displayed - the graphs show as diamonds. The Linux console, and most VT-like terminals have, however, some semigraphic mosaic characters that can be used to convey the same kind of information.

One such set is the scan 9-7-5-3-1 lines, ⎽⎼─⎻⎺, which can show one value per column (but 5 values rather than 4). Most physical terminals support these characters as well.

Linux console fonts can have 256 or 512 glyphs, as well as an extra Unicode table for more. With that, it'd be possible to support Braille and other symbols on the graphical console - this being a matter of font support for those. Unfortunately no font I tried bundled with Ubuntu, Debian, and Fedora did support them (I'll make feature requests for those on their respective bug trackers).

In the meantime, it'd be worth adding a theme command-line switch to select different graph character options.

With that done, we can start exploring different sets, such as the ITU T.100 set of "smoothed mosaic", which are in Unicode between U+1FB3C to U+1FB67. They offer 2 points at 4 heights per character cell, as a filled polygon, or a mix of fill rates (the 0-25-50% set from CP 437, which is commonly supported) and colors (as done in Sysdig's spectrogram display)

`iotop-c` shows empty screen in docker container running on Windows WSL2

> docker run -it --rm registry.access.redhat.com/ubi8/ubi:8.4

# This doesn't work
# yum install epel-release -y
Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Red Hat Universal Base Image 8 (RPMs) - BaseOS                                          192 kB/s | 798 kB     00:04
Red Hat Universal Base Image 8 (RPMs) - AppStream                                       2.8 MB/s | 2.6 MB     00:00
Red Hat Universal Base Image 8 (RPMs) - CodeReady Builder                                35 kB/s |  17 kB     00:00
No match for argument: epel-release
Error: Unable to find a match: epel-release

# yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
# yum install iotop-c -y
# iotop-c

or

> docker run -it --rm fedora

# yum install iotop-c -y
# iotop-c

image

# iotop-c --version
iotop-c 1.20

FR: Switch to next larger prefix sooner

Currently, when you have multiple MiB/s of writes, you will often see values like 8000.00 K/s as it only switches to the M prefix in the 10s of MiB/s.

The original python iotop switches somewhere in the neighbourhood of 2048K which I personally find easier to interpret and more aesthetically pleasing.

Black bar in graph IO column

Testing iotop – using commit c10e657 (Update contributors) – there is a black bar in the rsync row, but the usage is shown as 0. What does that mean?

iotop-cut

add support for disk or partition parameter

hi,
it's a very useful top, but lack a very important feature to be able to filter for a given partition or disk.
eg. i'd like to know hoe much data written a service. BUT suppose it write logs, db, user data etc. and I also would like to know how much data written into my system disk or root partition.
so a command line argument eg. / or /dev/sda2 would be very useful!
is it possible to add such a feature?

Display output enhancement

It would be a useful enhancement to add colours and even themes to the displayed output. Colours make highlighting or identifying things easier at a glance. A monochrome only switch may also be needed for some older or more basic terminals that don't support ansi colour codes.

It might be also nice to be able to customise the characters in the graph column to use Unicode block style characters instead of dot style ones.

Processes sometimes don't show up?

Sometimes when I start iotop-c -o when a process is already running, that process will not be shown. It does show a Total DISK WRITE including that process' IO and a few btrfs threads but their small IO doesn't add up to the total.

This does not happen with the python iotop.

The issue is very spurious and hard to reproduce.

FR: Add option to toggle graph direction

I'm used to having graphs grow from right to left from many other tools including i.e. btop.

It feels more intuitive for me to have time go from left-to-right rather than right-to-left once the graph is written out.

It'd be great if this was configurable #47

Why the blkio_delay is so different with iotop-py?

I made a busy reading of disk in clickhouse, and notice the GRAPH[IO]▽ column in the view is quite different with the IO> column in iotop.

The main thread of clickhouse shows the GRAPH[IO] is 100% and IO> is zero.
Which I think iotop is correct.

Because the IO mainly happens in a background thread, the main thread should be idle.

I see the data is fetched from netlink instead of /proc; but the algorithm is similar.
I don't understand the result, is there something I missed that GRAPH[IO] is not equivalent to IO> ?

Process graphs don't animate properly when using --ascii

When using the --ascii option, the per-process graphs appear to be trying to express two values per character cell, unlike the graphs on top, which express one value per cell when not in unicode. This is observable in the master branch.

Screencast.from.2023-08-29.23-30-34.webm

Monitor list of processes

Possibility to specify -p multiple times would be really nice.

I see on

params.pid=atoi(optarg);
, that it just stores the passed PID, and on
if ((params.pid!=-1)&&(s->tid!=params.pid))
that it makes a single comparison.

I'd like if this tool would store all the occurrences of -p, and store it in a linked list or in an array, and walk that array/ll in the filter1 function.

Build as a library for embedding

This is a suggestion: Is it possible to change iotop to work as a C/C++ library? This would allow developer to add this feature on other aplications, like monitoring systems.

Warnings with clang

When building with clang for 32-bit arm:

src/xxxid_info.c:103:52: warning: comparison of integers of different signs: '__u32' (aka 'unsigned int') and 'ssize_t' (aka 'int') [-Wsign-compare]
        if (answ.n.nlmsg_type==NLMSG_ERROR||(rep_len<0)||!NLMSG_OK((&answ.n),rep_len))
                                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/linux/netlink.h:100:24: note: expanded from macro 'NLMSG_OK'
                           (nlh)->nlmsg_len <= (len))
                           ~~~~~~~~~~~~~~~~ ^   ~~~
src/xxxid_info.c:157:38: warning: comparison of integers of different signs: '__u32' (aka 'unsigned int') and 'ssize_t' (aka 'int') [-Wsign-compare]
        if (msg.n.nlmsg_type==NLMSG_ERROR||!NLMSG_OK((&msg.n),rv)) {
                                            ^~~~~~~~~~~~~~~~~~~~~
/usr/include/linux/netlink.h:100:24: note: expanded from macro 'NLMSG_OK'
                           (nlh)->nlmsg_len <= (len))
                           ~~~~~~~~~~~~~~~~ ^   ~~~
2 warnings generated.

FR: Amount of IO per time

Besides 'accumulated', it would be nice to have a view that would present the amount of IO per unit of time (depending on how long iotop or process is running).

I tend to run iotop in -Pa mode in a background terminal, but after a while I forget how long is it since I started iotop, which makes it difficult to calculate how much IO a certain process had done per day.

IO metrics are constantly zero on VMs

I can see that iotop is working good on my hosts (AWS EC2), which have been configured half a year ago

But today I've tried to set up a new host (same on AWS EC2) with the same linux distro (Ubuntu 20.04) and now for some reason:

  1. It asks me to launch iotop using sudo (due to vulnerability). It is ok for me to run it as sudo, no problem.
  2. There was a warning CONFIG_TASK_DELAY_ACCT not enabled in kernel, cannot determine SWAPIN and IO %
    no problem, executed echo 1 > /proc/sys/kernel/task_delayacct and warning disappeared. But IOPS are still not swing

I'm confused since versions of iotop are the same 0.6 (installed via apt both) and hosts are the same (distro, instance type etc)

Even when building iotop version 1.22 from source showing me 0% IOPS

изображение

I've tried btop++ and it is showing IOPS load, same as iostat

What I'm doing wrong?

Don't show task_delayacct warning if SWAPIN and IO columns disabled

As noted in #21, SWAPIN and IO don't work if task_delayacct is not enabled.

While knowing this is important, it may not be crucial for the current use of iotop; and the message is distracting and continues to be displayed even if SWAPIN and IO are disabled, potentially overlapping useful information depending on screen width/height.

The user may also not wish to enable task_delayacct because it results in a performance overhead, or as it will be misleading, since delay for most services will only be available after they are restarted, which may be impractical for ad-hoc troubleshooting.

It would therefore be nice if it the message was only shown if either of the columns it relates to were enabled. Potentially, a brief notice could be shown on startup, and thereafter the columns would be disabled by default.

As a secondary matter, it might be worth allowing iotop to run without CONFIG_TASK_DELAY_ACCT enabled, not showing SWAPIN and IO. While I/O delay % can be useful information, just knowing reads/writes per process may be sufficient for the intended use.

get error when make ...

root@vultr:~/iotop# make
Package ncursesw was not found in the pkg-config search path.
Perhaps you should add the directory containing `ncursesw.pc'
to the PKG_CONFIG_PATH environment variable
No package 'ncursesw' found
Package ncurses was not found in the pkg-config search path.
Perhaps you should add the directory containing `ncurses.pc'
to the PKG_CONFIG_PATH environment variable
No package 'ncurses' found
Package ncurses was not found in the pkg-config search path.
Perhaps you should add the directory containing `ncurses.pc'
to the PKG_CONFIG_PATH environment variable
No package 'ncurses' found
DE bld/xxxid_info.o
CC bld/xxxid_info.o
DE bld/checks.o
CC bld/checks.o
DE bld/view_curses.o
CC bld/view_curses.o
src/view_curses.c:24:20: fatal error: curses.h: No such file or directory
compilation terminated.
Makefile:67: recipe for target 'bld/view_curses.o' failed
make: *** [bld/view_curses.o] Error 1

src/curses.h file lost?

Error trying to run iotop after install

I am trying to run iotop on a ubuntu 22.04.3 minimal install. I think I am missing a dependency. I just have no way to figure out which one. This does work on a regular install of ubuntu.

Any help would be appreciated. Thanks

Brad

Traceback (most recent call last):
File "/usr/sbin/iotop", line 10, in
from iotop.ui import main
File "/usr/lib/python3/dist-packages/iotop/ui.py", line 46, in
from iotop.data import find_uids, TaskStatsNetlink, ProcessList, Stats
File "/usr/lib/python3/dist-packages/iotop/data.py", line 51, in
vmstat_f = VmStat()
File "/usr/lib/python3/dist-packages/iotop/vmstat.py", line 23, in init
self.vmstat = self.read()
File "/usr/lib/python3/dist-packages/iotop/vmstat.py", line 40, in read
return pgpgin, pgpgout
UnboundLocalError: local variable 'pgpgin' referenced before assignment

Brew Package

Would it be possible to have a brew package for this? It looks great!

iotop clarification

Hi there, while using iotop in kubernetes pods I am getting an error as below.
Traceback (most recent call last):
File "/usr/sbin/iotop", line 17, in
main()
File "/usr/lib/python3/dist-packages/iotop/ui.py", line 737, in main
main_loop()
File "/usr/lib/python3/dist-packages/iotop/ui.py", line 727, in
main_loop = lambda: run_iotop(options)
File "/usr/lib/python3/dist-packages/iotop/ui.py", line 620, in run_iotop
return curses.wrapper(run_iotop_window, options)
File "/usr/lib/python3.7/curses/init.py", line 94, in wrapper
return func(stdscr, *args, **kwds)
File "/usr/lib/python3/dist-packages/iotop/ui.py", line 609, in run_iotop_window
taskstats_connection = TaskStatsNetlink(options)
File "/usr/lib/python3/dist-packages/iotop/data.py", line 151, in init
self.family_id = controller.get_family_id('TASKSTATS')
File "/usr/lib/python3/dist-packages/iotop/genetlink.py", line 76, in get_family_id
m = GeNlMessage.recv(self.conn)
File "/usr/lib/python3/dist-packages/iotop/genetlink.py", line 56, in recv
msg = conn.recv()
File "/usr/lib/python3/dist-packages/iotop/netlink.py", line 255, in recv
raise err
OSError: Netlink error: No such file or directory (2)

I already found out a solution for this. That is using below two configurations in k8s manifests
privileged : true
hostNetwork: true
But in our requirements it mandates to not use hostNetwork: true. So I just wanted to know why iotop demands hostNetwork : true ? And if you know any other way to run iotop without errors without using hostNetwork : true please let me know.

Thank You

Running iotop-c as non root results in a `~/.config/iotop` dir.

I have XDG_CONFIG_HOME set to ~/.local/config instead of the default location of ~/.config.

I recently tested iotop -c and made the mistake of trying to run it as non root. After correcting that error I noticed that my home now has a ~/.config/iotop directory.

The directory is being created by iotop-c, likely because it has a hardcoded path to ~/.config instead of checking the xdg enviroment variables.

What's interesting is that iotop can no longer be run as regular user, so this should be easy to fix.

(This issue does not happen with the regular iotop btw).

Edit: The issue is on lines 53 and 23 of configfile.c.

No qsort_r in musl

$ docker run -it --rm alpine sh
/ # cd
~ # apk add --no-cache alpine-sdk linux-headers ncurses-dev
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
fetch
http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
(1/42) Upgrading musl (1.1.24-r8 -> 1.1.24-r9)
(2/42) Installing fakeroot (1.24-r0)
(3/42) Installing openssl (1.1.1g-r0)
(4/42) Installing libattr (2.4.48-r0)
(5/42) Installing attr (2.4.48-r0)
(6/42) Installing libacl (2.2.53-r0)
(7/42) Installing tar (1.32-r1)
(8/42) Installing pkgconf (1.7.2-r0)
(9/42) Installing patch (2.7.6-r6)
(10/42) Installing libgcc (9.3.0-r2)
(11/42) Installing libstdc++ (9.3.0-r2)
(12/42) Installing lzip (1.21-r0)
(13/42) Installing ca-certificates (20191127-r4)
(14/42) Installing nghttp2-libs (1.41.0-r0)
(15/42) Installing libcurl (7.69.1-r0)
(16/42) Installing curl (7.69.1-r0)
(17/42) Installing abuild (3.6.0-r0)
Executing abuild-3.6.0-r0.pre-install
(18/42) Installing binutils (2.34-r1)
(19/42) Installing libmagic (5.38-r0)
(20/42) Installing file (5.38-r0)
(21/42) Installing gmp (6.2.0-r0)
(22/42) Installing isl (0.18-r0)
(23/42) Installing libgomp (9.3.0-r2)
(24/42) Installing libatomic (9.3.0-r2)
(25/42) Installing libgphobos (9.3.0-r2)
(26/42) Installing mpfr4 (4.0.2-r4)
(27/42) Installing mpc1 (1.1.0-r1)
(28/42) Installing gcc (9.3.0-r2)
(29/42) Installing musl-dev (1.1.24-r9)
(30/42) Installing libc-dev (0.7.2-r3)
(31/42) Installing g++ (9.3.0-r2)
(32/42) Installing make (4.3-r0)
(33/42) Installing fortify-headers (1.1-r0)
(34/42) Installing build-base (0.5-r2)
(35/42) Installing expat (2.2.9-r1)
(36/42) Installing pcre2 (10.35-r0)
(37/42) Installing git (2.26.2-r0)
(38/42) Installing alpine-sdk (1.0-r0)
(39/42) Installing linux-headers (5.4.5-r1)
(40/42) Installing ncurses-terminfo-base (6.2_p20200523-r0)
(41/42) Installing ncurses-libs (6.2_p20200523-r0)
(42/42) Installing ncurses-dev (6.2_p20200523-r0)
Executing busybox-1.31.1-r16.trigger
Executing ca-certificates-20191127-r4.trigger
OK: 232 MiB in 55 packages
~ # git clone --depth 1 https://github.com/Tomas-M/iotop.git
Cloning into 'iotop'...
remote: Enumerating objects: 32, done.
remote: Counting objects: 100% (32/32), done.
remote: Compressing objects: 100% (28/28), done.
remote: Total 32 (delta 2), reused 14 (delta 0), pack-reused 0
Receiving objects: 100% (32/32), 38.33 KiB | 478.00 KiB/s, done.
Resolving deltas: 100% (2/2), done.
~ # cd iotop/
~/iotop # make
DE bld/arr.o
CC bld/arr.o
src/arr.c: In function 'arr_sort':
src/arr.c:188:5: warning: implicit declaration of function 'qsort_r'; did you
mean 'qsort'? [-Wimplicit-function-declaration]
  188 |     qsort_r(pa->sor, pa->length, sizeof *pa->sor,cb,arg);
        |     ^~~~~~~
		      |     qsort
			  DE bld/checks.o
			  CC bld/checks.o
			  DE bld/ioprio.o
			  CC bld/ioprio.o
			  DE bld/main.o
			  CC bld/main.o
			  DE bld/utils.o
			  CC bld/utils.o
			  DE bld/views.o
			  CC bld/views.o
			  DE bld/vmstat.o
			  CC bld/vmstat.o
			  DE bld/xxxid_info.o
			  CC bld/xxxid_info.o
			  LD iotop
			  /usr/lib/gcc/x86_64-alpine-linux-musl/9.3.0/../../../../x86_64-alpine-linux-musl/bin/ld:
			  /tmp/iotop.OmIkGL.ltrans0.ltrans.o: in function `view_curses':
			  :(.text+0x22e3): undefined reference to `qsort_r'
			  /usr/lib/gcc/x86_64-alpine-linux-musl/9.3.0/../../../../x86_64-alpine-linux-musl/bin/ld:
			  /tmp/iotop.OmIkGL.ltrans0.ltrans.o: in function `view_batch':
			  :(.text+0x4958): undefined reference to `qsort_r'
			  collect2: error: ld returned 1 exit status
			  make: *** [Makefile:63: iotop] Error 1

Getting fatal reply error

I built this repo from source using make and running it gives a scrolling
fatal reply error, -1
The line changes color after some time and occasionally gibberish such as KB/S gets printed.

Freeze on netlink error reply?

iotop enters an infinite wait on netlink, probably as a result of ignoring a previous error:

11:31:14.201289 socket(AF_NETLINK, SOCK_RAW, NETLINK_GENERIC) = 3
11:31:14.201393 bind(3, {sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, 12) = 0
11:31:14.201511 getpid()                = 46880
11:31:14.201610 sendto(3, {{len=36, type=nlctrl, flags=NLM_F_REQUEST, seq=0, pid=46880}, "\x03\x01\x00\x00\x0e\x00\x02\x00\x54\x41\x53\x4b\x53\x54\x41\x54\x53\x00\x00\x00"}, 36, 0, {sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, 12) = 36
11:31:14.202179 recvfrom(3, {{len=56, type=NLMSG_ERROR, flags=0, seq=0, pid=46880}, {error=-ENOENT, msg={{len=36, type=nlctrl, flags=NLM_F_REQUEST, seq=0, pid=46880}, "\x03\x01\x00\x00\x0e\x00\x02\x00\x54\x41\x53\x4b\x53\x54\x41\x54\x53\x00\x00\x00"}}}, 1044, 0, NULL, NULL) = 56
11:31:14.202340 rt_sigaction(SIGINT, {sa_handler=0x565546aa1060, sa_mask=[INT], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fc8a8c1cd60}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
11:31:14.202472 openat(AT_FDCWD, "/proc", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 4
11:31:14.202597 fstat(4, {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
11:31:14.202738 getdents64(4, 0x56554726c380 /* 90 entries */, 32768) = 2632
11:31:14.202978 openat(AT_FDCWD, "/proc/1/task", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 5
11:31:14.203094 fstat(5, {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
11:31:14.203202 getdents64(5, 0x5655472743c0 /* 3 entries */, 32768) = 72
11:31:14.203309 sendto(3, {{len=28, type=0 /* NLMSG_??? */, flags=NLM_F_REQUEST, seq=0, pid=1}, "\x01\x01\x00\x00\x08\x00\x01\x00\x01\x00\x00\x00"}, 28, 0, {sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, 12) = 28
11:31:14.203458 recvfrom(3,   …

This is an lxc container and it may restrict access to various things around. Unhandled errors may result in weird behaviours.

Q: any tricks to get it compiling on macOS/Darwin?

Hello there,

From the description of the project (I didn't delve deep into the code myself), it seems that this tool (as opposed to the Python version) assumes there is a Linux kernel running beneath the OS/POSIX layer. This may explain why no references are made to FreeBSD, OpenBSD, NetBSD etc. on the README.md.

I did a quick attempt to compile it under macOS/Darwin (which is vaguely BSD-ish); however, it seems that clang (the default compiler by Apple) and gcc 12.1 (installed through Homebrew) get utterly confused when trying to include something as simple as src/iotop.h — mostly because of the way #define is working:

In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include/sys/types.h:75,
                 from src/iotop.h:27,
                 from src/arr.c:14:
/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include/sys/cdefs.h:681:49: error: operator '&&' has no right operand
  681 | #if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1L
      |                                                 ^~
/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include/sys/cdefs.h:687:49: error: operator '&&' has no right operand
  687 | #if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 2L
      |                                                 ^~
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include/sys/cdefs.h:715:
/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include/sys/_posix_availability.h:32:79:error: operator '&&' has no right operand
   32 | #if !defined(_DARWIN_C_SOURCE) && defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 198808L
      |                                                                               ^~
/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include/sys/_posix_availability.h:38:79:error: operator '&&' has no right operand
   38 | #if !defined(_DARWIN_C_SOURCE) && defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199009L
      |                                                                               ^~
/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include/sys/_posix_availability.h:44:79:error: operator '&&' has no right operand
   44 | #if !defined(_DARWIN_C_SOURCE) && defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199209L
      |
[...]

My assumption is that the macOS/Darwin pre-processor has serious issues, after expanding the #defines, to deal with more complex expressions. This may perhaps be a result of an extra flag or a missing one; being an utter newbie to the complexities of compiling C/C++ (anything except the most basic things!), I wonder if anyone has a clue on what I ought to do to fix the above errors...

build error on centos7

i'm getting this error when trying to build on centos7

make

DE bld/delayacct.o
cc: error: unrecognized command line option '-Wdate-time'
make: *** [bld/delayacct.o] Error 1

after removing -Wdate-time for testing, i'm getting

CC bld/view_curses.o
In file included from src/view_curses.c:26:0:
src/view_curses.c: In function 'view_curses':
src/view_curses.c:964:30: error: 'A_ITALIC' undeclared (first use in this function)
attron(config.f.nocolor?A_ITALIC:COLOR_PAIR(RED_PAIR));
^
src/view_curses.c:964:30: note: each undeclared identifier is reported only once for each function it appears in
make: *** [bld/view_curses.o] Error 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.