Htop
htop is an interactive text-mode process viewer for Unix systems. It aims to be a better top.
This is htop, an interactive process viewer. It requires ncurses. It is developed primarily on Linux, but we also have code for running under FreeBSD and Mac OS X (help and testing are wanted for these platforms!)
This software has evolved considerably over the years, and is reasonably complete, but there is always room for improvement.
Preview
Screenshot-htop.png
Comparison between htop and classic top
- In htop you can scroll the list vertically and horizontally to see all processes and full command lines.
- In top you are subject to a delay for each unassigned key you press (especially annoying when multi-key escape sequences are triggered by accident).
- htop starts faster (top seems to collect data for a while before displaying anything).
- In htop you don't need to type the process number to kill a process, in top you do.
- In htop you don't need to type the process number or the priority value to renice a process, in top you do.
- In htop you can kill multiple processes at once.
- top is older, hence, more tested.
프로세스 정보
- PID: 프로세스의 프로세스 ID번호
- USER: 프로세스의 소유자
- PR: 프로세스의 우선순위
- NI: 우선순위에 영향을 주는 프로세스의 nice 값
- VIRT: 프로세스가 사용중인 가상 메모리 양
- RES: 프로세스가 사용중인 물리 RAM의 양 (단위는 킬로바이트) - (Resident set size; RSS) - 이 녀석으로 메모리 사용량 계산하자.
- SHR: 프로세스가 사용중인 공유 메모리 양
- S: 프로세스의 현재 상태(zombied, sleeping, running, uninterruptedly sleeping, traced)
- %CPU: 프로세스가 프로세서를 사용한 시간의 백분율
- %MEM: 프로세스가 사용중인 물리 RAM의 백분율
- TIME+: 프로세스가 프로세서를 사용한 시간
- COMMAND: 프로세스 시작에 사용한 명령어명
기능
- F1(help): 도움말 및 단축키의 기능을 알 수 있다.
- F2(Setup): htop 설정 메뉴이다.
- F3(Search): 프로세스를 검색할 수 있다. ( '/' 키로도 검색이 가능하다.)
- F4(Filter): 원하는 프로세스만 모니터링이 가능하다. ( = ps -ef | grep mysqld )
- F5(Tree): 프로세스의 부모자식 관계를 트리 형태로 보여주는 기능이다. + 또는 - 키를 이용해 트리를 펼치거나 접을 수 있다. ( =pstree 명령과 동일 )
- F6(Sort): 프로세스를 CPU, 메모리, 사용자 등.. 원하는 방식으로 정렬하여 볼 수 있다. ( 정렬할 필드에 색깔이 표시되어 보기 쉽다. )
- F7, F8(Nice): 프로세스의 우선 순위를 바꾸는 단축키이다. ( f7 키는 우선순위를 높이고 f8 키로 우선순위를 내릴 수 있다. -> 즉, 값이 작을수우선순위가 높다. )
- F9(Kill): 프로세스를 종료시켜주는 단축키이다. ( = kill -9 {PID} ) -> 만약 여러 프로세스를 한번에 종료시키려면 "space" 키로 다수의 프로세스를 선택 후 F9키를 눌러 프로세스를 종료한다.
- F10(quit): htop 종료
그 외의 기능
- u: 특정 사용자의 프로세스만 볼 수 있다.
- i: I/O 우선순위를 변경할 수 있다.
- s: 특정 프로세스 선택 후 "s"키를 누르면 해당 프로세스의 strace을 보여준다. ( = 시스템 콜 트레이스(strace) )
- l: 프로세스 선택 후 "l"키를 누르면 특정 프로세스에서 열고 있는 파일을 볼 수 있다.
- htop화면에서 숫자를 입력하면 해당 PID를 가진 프로세스를 찾을 수 있다.
Columns
F2 눌러서 확인할 수 있는 컬럼 목록
- PID - Process/thread ID
- STATE - Process state (S sleeping, R running, D disk, Z zombie, T traced, W paging, I idle)
- PPID - Parent process ID
- PGRP - Process group ID
- SESSION - Process's session ID
- TTY_NR - Controlling terminal
- TPGID - Process ID of the fg process group of the controlling terminal
- MINFLT - Number of minor faults which have not required loading a memory page from disk
- CMINFLT - Children processes' minor faults
- MAJFLT - Number of major faults which have required loading a memory page from disk
- CMAJFLT - Children processes' major faults
- UTIME - User CPU time - time the process spent executing in user mode
- STIME - System CPU time - time the kernel spent running system calls for this process
- CUTIME - Children processes' user CPU time
- CSTIME - Children processes' system CPU time
- PRIORITY - Kernel's internal priority for the process
- NICE - Nice value (the higher the value, the more it lets other processes take priority)
- STARTTIME - Time the process was started
- PROCESSOR - Id of the CPU the process last executed on
- M_VIRT - Total program size in virtual memory
- M_RESIDENT - Resident set size, size of the text and data sections, plus stack usage
- M_SHARE - Size of the process's shared pages
- M_TRS - Size of the text segment of the process
- M_DRS - Size of the data segment plus stack usage of the process
- M_LRS - The library size of the process (calculated from memory maps)
- M_DT - Size of the dirty pages of the process (unused since Linux 2.6; always 0)
- ST_UID - User ID of the process owner
- PERCENT_CPU - Percentage of the CPU time the process used in the last sampling
- PERCENT_MEM - Percentage of the memory the process is using, based on resident memory size
- USER - Username of the process owner (or user ID if name cannot be determined)
- TIME - Total time the process has spent in user and system time
- NLWP - Number of threads in the process
- TGID - Thread group ID (i.e. process ID)
- PERCENT_NORM_CPU - Normalized percentage of the CPU time the process used in the last sampling (normalized by cpu co
- CTID - OpenVZ container ID (a.k.a. virtual environment ID)
- VPID - OpenVZ process ID
- VXID - VServer process ID
- RCHAR - Number of bytes the process has read
- WCHAR - Number of bytes the process has written
- SYSCR - Number of read(2) syscalls for the process
- SYSCW - Number of write(2) syscalls for the process
- RBYTES - Bytes of read(2) I/O for the process
- WBYTES - Bytes of write(2) I/O for the process
- CNCLWB - Bytes of cancelled write(2) I/O
- IO_READ_RATE - The I/O rate of read(2) in bytes per second for the process
- IO_WRITE_RATE - The I/O rate of write(2) in bytes per second for the process
- IO_RATE - Total I/O rate in bytes per second
- CGROUP - Which cgroup the process is in
- OOM - OOM (Out-of-Memory) killer score
- IO_PRIORITY - I/O priority
- PERCENT_CPU_DELAY - CPU delay %
- PERCENT_IO_DELAY - Block I/O delay %
- PERCENT_SWAP_DELAY - Swapin delay %
- M_PSS - proportional set size, same as M_RESIDENT but each page is divided by the number of processes sharing it.
- M_SWAP - Size of the process's swapped pages
- M_PSSWP - shows proportional swap share of this mapping, Unlike "Swap", this does not take into account swapped out
- CTXT - Context switches (incremental sum of voluntary_ctxt_switches and nonvoluntary_ctxt_switches)
- SECATTR - Security attribute of the process (e.g. SELinux or AppArmor)
- COMM - comm string of the process from /proc/[pid]/comm
- EXE - Basename of exe of the process from /proc/[pid]/exe
- CWD - The current working directory of the process
/proc/meminfo
으로 메모리 사용량 계산
htop에서 ...
- 사용 된 총 메모리 = MemTotal-MemFree
- 비 캐시 / 버퍼 메모리 (녹색) = 사용 된 총 메모리-(버퍼 + 캐시 된 메모리)
- 버퍼 (파란색) = Buffers
- 캐시 된 메모리 (노란색) = Cached+ SReclaimable-Shmem
- 스왑 = SwapTotal-SwapFree
See also
- ps
- top
- htop
- ctop
- Glances
- nmon
- free
- Resource usage
- procs - replacement for ps written in Rust.
- LXTask - (LXDE; 가벼운 태스크 관리자]])
- mpstat
- iotop - Disk I/O
- Sampler - 쉘 커맨드 실행, 시각화 및 알림 도구
- iftop - shows network traffic by service and host
- NetHogs
Favorite site
- Github - htop
- [추천] htop explained | peteris.rocks 1
- 인터넷나야나 :: Htop (Linux Process Monitoring) 사용법
- 리눅스포털 - htop : top 보다 사용자 위주의 모니터링 도구
- (ubuntu) 리눅스 htop 설치 및 사용방법
References
-
Htop_explained_-_peteris.rocks.pdf ↩