Development knowledge/Linux

[Linux] top ๋ช…๋ น์–ด ์ •๋ฆฌ ๋ฐ ์„ค๋ช…

yuri lee 2022. 11. 14. 23:04
๋ฐ˜์‘ํ˜•

Intro 

์•ˆ๋…•ํ•˜์„ธ์š”. ๋ฆฌ๋ˆ…์Šค์˜ top ๋ช…๋ น์–ด์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. 

 

top ๋ช…๋ น์–ด๋ž€?

top ๋ช…๋ น์–ด๋Š” Linux์—์„œ ์‹คํ–‰ ์ค‘์ธ ํ”„๋กœ์„ธ์Šค์˜ ์‹ค์‹œ๊ฐ„์„ ํ‘œ์‹œํ•˜๊ณ  ์ปค๋„ ๊ด€๋ฆฌ ์ž‘์—…์„ ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค. ์ด ๋ช…๋ น์–ด๋Š” CPU ๋ฐ ๋ฉ”๋ชจ๋ฆฌ ์‚ฌ์šฉ๋Ÿ‰์„ ํฌํ•จํ•œ ๋ฆฌ์†Œ์Šค ์‚ฌ์šฉ๋Ÿ‰์„ ๋ณด์—ฌ์ฃผ๋Š” ์‹œ์Šคํ…œ ์ •๋ณด ์š”์•ฝ์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. 

 

 

top ๋ช…๋ น ๊ตฌ๋ฌธ ๋ฐ ์˜ต์…˜

top -hv | -bcEeHiOSs1 -d secs -n max -u | U user -p pid(s) -o field -w [cols]
-h Help ๋ช…๋ น ๋„์›€๋ง ํŒŒ์ผ์„ ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค. 
-v Version ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ๋ฒ„์ „ ๋ฐ ์‚ฌ์šฉ ํ”„๋กฌํฌํŠธ๋ฅผ ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค. 
-b Batch mode Starts top in batch mode, allowing to send the command's output to a file or other programs. top doesn't accept input in batch mode and runs until killed or until it reaches the specified iteration limit.
-c Toggle command line/program name Reverses the last remembered c state. If top displayed command lines, that field now shows program names and vice versa.
-d [secs.tenths] Delay time interval Prompts you to specify the delay before updating the screen, overriding the default value. The value is in seconds. The command accepts fractional seconds but doesn't accept negative numbers.
-e [k | m | g | t | p] Toggle task memory scaling Allows you to change top task area memory scaling. The available scaling options are k (kibibytes), m (mebibytes), g (gibibytes), t (tebibytes), p (pebibytes).
-E [k | m | g | t | p | e] Toggle summary memory scaling Allows you to change top summary area memory scaling. The available scaling options are k (kibibytes), m (mebibytes), g (gibibytes), t (tebibytes), p (pebibytes), e (exbibytes).
-H Threads mode operation Specifying the -H option instructs top to display individual threads instead of a sum of all threads in each process.
-i Idle process toggle Reverses the last remembered i state. When the toggle is OFF, top doesn't display the tasks that haven't used CPU resources since the last update.
-n Limit iteration number Specify the maximum number of iterations you want top to produce before ending.
-o [field name] Overwrite sort field Specify the field name top uses to sort tasks. Prepending a + to the field name forces top to sort high to low while prepending it with - orders tasks low to high. The -o option primarily supports automated batch mode operation.
-O Output field names The -O option complements the -o option, causing top to print each of the available field names separately and then quit.
-p [N1, N2...] Monitor process IDs mode Instructs top to monitor only the processes with the specified process IDs. When combined with the threads mode (-H), top shows all the processes in each monitored PID thread group. The maximum number of PIDs is 20. Specifying the PID value 0 is considered as the top program process ID. To return to normal operation, issue any of the following commands: =, u, or U, as they are mutually exclusive.
-s Secure mode operation Starts top in secure mode, even for root.
-S Cumulative time toggle Reverses the last remembered S state. When the cumulative time toggle is ON, each process is listed with the CPU time it has used.
-u | -U [ID or name] User filter mode Displays only the processes matching the specified user ID or user name. The -u option matches only the effective user, while the -U option matches any user - real, effective, saved, or filesystem. Prepending the user ID or user name with an exclamation point (!) causes top to display only the processes that don't match the one provided.
-w [number] Output width override When used without an argument, -w instructs top to format the output using the COLUMNS= and LINES= environment variables, if applicable. Otherwise, the width is fixed at 512 columns maximum. Appending an argument to -w increases (up to 512) or decreases the output width while the row number is unlimited. The program never exceeds the actual terminal dimensions at which top was invoked.
-1 Single/separate CPU states toggle Reverses the last remembered CPU state portion. Depending on the NUMA Node command toggle (2) state, either displays all CPU information in a single line or separately.

 


https://phoenixnap.com/kb/top-command-in-linux

๋ฐ˜์‘ํ˜•