文章目录
- Iotop依赖及编译
- 1:内核配置
- 2: 环境配置
- 3.依赖库ncurses
- 3.1 Ncurses的编译配置
- 4. Iotop的编译及修改
- 5.测试效果如下:
Iotop依赖及编译
源码路径:https://github.com/Tomas-M/iotop#how-to-build-from-source (GitHub - Tomas-M/iotop: A top utility for IO)
1:内核配置
在编译内核make menuconfig的时候一定要把下面选项选上:
General setup —> CPU/Task time and stats accounting ->
[+] Export task/process statistics through netlink
[+] Enable per-task delay accounting
[+] Enable extended accounting over taskstats
[+] Enable per-task storage I/O accounting
+CONFIG_TASKSTATS=y
+CONFIG_TASK_DELAY_ACCT=y
+CONFIG_TASK_XACCT=y
+CONFIG_TASK_IO_ACCOUNTING=y
+CONFIG_SCHED_INFO=y
2: 环境配置
在执行iotop出现 Error opening terminal: vt102,请继续往下看:
在板子上如下操作/etc/profile加入
export TERM=vt100
export TERMINFO=/usr/share/terminfo
mkdir /usr/share/terminfo/v -p
然后copy自己的pc主机上的
/usr/share/terminfo/v/vt100
到板子上的/usr/share/terminfo/v/目录下
3.依赖库ncurses
源码路径:https://invisible-island.net/ncurses/ncurses.html#download_ncurses
3.1 Ncurses的编译配置
./configure --with-shared --without-debug --with-ticlib --disable-stripping --host=aarch64-linux-gnu CC=aarch64-linux-gnu-gcc --prefix=“$PWD/…/libncurses”
然后make && make install.libs && make install.lncludes
然后使用服务器的gcc 在全编译一次 能够生成terminfo 把这里的v/vt100保存下来
4. Iotop的编译及修改
需要修改Makefile,然后需要将Ncurses的成果物放到iotop的跟目录
INCLUDES := ./include 新增
CC=aarch64-linux-gnu-gcc 新增# PKG_CONFIG?=pkg-config
# NCCC?=$(shell $(PKG_CONFIG) --cflags ncursesw)
# NCLD?=$(shell $(PKG_CONFIG) --libs ncursesw)
# ifeq ("$(NCLD)","")
# NCCC:=$(shell $(PKG_CONFIG) --cflags ncurses)
# NCLD:=$(shell $(PKG_CONFIG) --libs ncurses)
# endif
# ifeq ("$(NCLD)","")
# NCCC:=
# NCLD:=-lncursesw
# endifCFLAGS += -L ./lib/ -Bstatic -lncurses 新增
CFLAGS += $(addprefix -I,$(INCLUDES)) 新增