强大的进程管理工具htop

top太老了

与其说top太老了,不如说top的逻辑方式不再适合现代程序的交互逻辑

今天碰到了一款更为强大的进程管理工具-htop,简而言之,比top好用多了

上截图看下:
htop截图

左上角CPU,内存,SWAP使用情况,右上角任务进程启动时间

然后就是进程的详细情况,功能键基本功能都有了,而且支持鼠标操作

简洁的交互方式,鼠标就可以kill掉进程

对我来讲已经到了可以替换htop的地步了

安装:

早期htop放在SourceForge.net上,现在的URL地址

多种发行版的包管理器已经提供支持

例如Ubuntu直接输入命令

apt install htop

即可

CentOS相对麻烦一些需要加入Fedora源,不过我通过源码编译安装的方式

1、下载源码包

wget http://hisham.hm/htop/releases/2.0.2/htop-2.0.2.tar.gz

2、编译安装一气呵成

./configure --prefix=/usr/local/htop && make && make install

注:./configure –prefix=/usr/local/htop可能提示
configure: error: You may want to use –disable-unicode or install libncursesw.

安装ncurses-devel即可

3、建立软链接

ln -s /usr/local/htop/bin/htop /usr/bin/

一般来讲到这里就完成了,但是我的环境比较复杂,OpenVZ的虚拟化

root@localhost:~/htop-2.0.2# ./configure --prefix=/usr/local/htop
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/root/htop-2.0.2':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details

首先安装gcc

root@localhost:~/htop-2.0.2# yum install gcc
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: repos.lax.quadranet.com
* extras: repos.dfw.quadranet.com
* updates: mirrors.usc.edu
正在解决依赖关系
-- 正在检查事务
--- 软件包 gcc.x86_64.0.4.8.5-4.el7 将被 安装
-- 正在处理依赖关系 libgomp = 4.8.5-4.el7,它被软件包 gcc-4.8.5-4.el7.x86_64 需要
-- 正在处理依赖关系 cpp = 4.8.5-4.el7,它被软件包 gcc-4.8.5-4.el7.x86_64 需要
-- 正在处理依赖关系 glibc-devel ;= 2.2.90-12,它被软件包 gcc-4.8.5-4.el7.x86_64 需要
-- 正在处理依赖关系 libmpfr.so.4()(64bit),它被软件包 gcc-4.8.5-4.el7.x86_64 需要
-- 正在处理依赖关系 libmpc.so.3()(64bit),它被软件包 gcc-4.8.5-4.el7.x86_64 需要
-- 正在处理依赖关系 libgomp.so.1()(64bit),它被软件包 gcc-4.8.5-4.el7.x86_64 需要
-- 正在检查事务
--- 软件包 cpp.x86_64.0.4.8.5-4.el7 将被 安装
--- 软件包 glibc-devel.x86_64.0.2.17-106.el7_2.8 将被 安装
-- 正在处理依赖关系 glibc-headers = 2.17-106.el7_2.8,它被软件包 glibc-devel-2.17-106.el7_2.8.x86_64 需要
-- 正在处理依赖关系 glibc-headers,它被软件包 glibc-devel-2.17-106.el7_2.8.x86_64 需要
--- 软件包 libgomp.x86_64.0.4.8.5-4.el7 将被 安装
--- 软件包 libmpc.x86_64.0.1.0.1-3.el7 将被 安装
--- 软件包 mpfr.x86_64.0.3.1.1-4.el7 将被 安装
-- 正在检查事务
--- 软件包 glibc-headers.x86_64.0.2.17-106.el7_2.8 将被 安装
-- 正在处理依赖关系 kernel-headers = 2.2.1,它被软件包 glibc-headers-2.17-106.el7_2.8.x86_64 需要
-- 正在处理依赖关系 kernel-headers,它被软件包 glibc-headers-2.17-106.el7_2.8.x86_64 需要
-- 解决依赖关系完成
错误:软件包:glibc-headers-2.17-106.el7_2.8.x86_64 (updates)
需要:kernel-headers = 2.2.1
错误:软件包:glibc-headers-2.17-106.el7_2.8.x86_64 (updates)
需要:kernel-headers
您可以尝试添加 --skip-broken 选项来解决该问题
您可以尝试执行:rpm -Va --nofiles --nodigest

系统版本信息:

root@localhost:/# cat /etc/redhat-release $$ uname -r
CentOS Linux release 7.2.1511 (Core)
2.6.32-042stab113.11

在https://wiki.openvz.org/Download/kernel找到了合适的kernel-header


wget http://download.openvz.org/kernel/branches/rhel6-2.6.32/042stab113.11/vzkernel-headers-2.6.32-042stab113.11.x86_64.rpm

rpm -ivh vzkernel-headers-2.6.32-042stab113.11.x86_64.rpm

再安装gcc就可以了

实用功能:

1.参数说明:

htop命令参数选项

htop –d 数据刷新时间

htop –u aurain 显示用户aurain的所属进程

M    按Memory 使用排序

P    按CPU 使用排序

T    按Time+ 使用排序

F3 按进程名搜索

直接输入数字 光标将定位于该PID的进程

q 退出

进程内参数

PID:进程标志号,是非零正整数

USER:进程所有者的用户名

PR:进程的优先级别

NI:进程的优先级别数值

VIRT:虚拟内存virtual memory usage。一个应用占有的地址空间,只是要应用程序要求的,就全算在这里,而不管它真的用了没有。

RES:常驻内存resident memory usage。这个值就是该应用程序真正使用的内存,但还有两个小问题,一是有些东西可能放在交换盘上了(SWAP),二是有些内存可能是共享的。

SHR:shared memory。共享内存。就是说这一块内存空间有可能也被其他应用程序使用着;而Virt - Shr似乎就是这个程序所要求的并且没有共享的内存空间。

S:进程的状态,其中S表示休眠,R表示正在运行,Z表示僵死状态,N表示该进程优先值是负数

%CPU:该进程占用的CPU使用率

%MEM:该进程占用的物理内存和总内存的百分比

TIME+:该进程启动后占用的总的CPU时间

COMMAND:进程启动的启动命令名称

2.隐藏重复进程

按F2→ 选择Display options→选择 Hide userland threads

 

发表评论

您的电子邮箱地址不会被公开。 必填项已用 * 标注