Comando TOP
Autor: Marcos Abadi | Publicado: 2015-12-16T22:43:00-02:00


Comando TOP

# top





O comando top no Linux exibe os processos em execução no sistema. Uma das ferramentas mais importantes para um administrador do sistema. É amplamente utilizado para monitorar a carga do sistema. Nesse artigo é explorado o comando top em detalhes, pois ele é um comando interativo; ou seja, muitos outros comandos estão disponíveis quando ele está executando. Sendo assim, domine o comando top!


I – SAÍDA DO COMANDO TOP


top

top - 23:18:09 up&nbsp; 1:45,&nbsp; 1 user,&nbsp; load average: 0.76, 0.78, 0.76
Tasks: 192 total,&nbsp;&nbsp; 1 running, 190 sleeping,&nbsp;&nbsp; 0 stopped,&nbsp;&nbsp; 1 zombie
Cpu(s): 15.4%us,&nbsp; 5.7%sy,&nbsp; 0.0%ni, 78.8%id,&nbsp; 0.2%wa,&nbsp; 0.0%hi,&nbsp; 0.0%si,&nbsp; 0.0%st
Mem:&nbsp;&nbsp; 3058052k total,&nbsp; 2100524k used,&nbsp;&nbsp; 957528k free,&nbsp;&nbsp; 168696k buffers
Swap:&nbsp; 3481788k total,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0k used,&nbsp; 3481788k free,&nbsp; 1099720k cached
&nbsp;
&nbsp; PID USER&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PR&nbsp; NI&nbsp; VIRT&nbsp; RES&nbsp; SHR S %CPU %MEM&nbsp;&nbsp;&nbsp; TIME+&nbsp; COMMAND&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;2370 ricardo&nbsp;&nbsp; 20&nbsp;&nbsp; 0&nbsp; 6836 3352&nbsp; 632 S&nbsp;&nbsp;&nbsp; 1&nbsp; 0.1&nbsp;&nbsp; 0:14.33 dbus-daemon


Primeiramente, é preciso entender a saída do comando (mostrada acima). Ela exibe uma série de informações sobre o sistema em funcionamento. Então, é preciso ficar ciente das seções mostradas:

1 – Tempo de atividade e média de carga do sistema (Uptime and Load Averages)

top - 23:18:09 up&nbsp; 1:45,&nbsp; 1 user,&nbsp; load average: 0.76, 0.78, 0.76


Na parte superior do comando top é apresentada a saída similar ao&nbsp;comando uptime.

* O tempo atual&nbsp;* O tempo que seu sistema está funcionando&nbsp;* Número de usuários autenticados no sistema no momento&nbsp;* Média de carga de 5, 10 e 15 minutos respectivamente.

2 – Tarefas (Tasks)

Tasks: 192 total,&nbsp;&nbsp; 1 running, 190 sleeping,&nbsp;&nbsp; 0 stopped,&nbsp;&nbsp; 1 zombie


A segunda linha mostra resumo das tarefas ou processos. Os processos podem ser em diferentes estados. Ela mostra o número total de processos. Destes, os processos podem estar&nbsp;executando (running),&nbsp;dormindo (sleeping),&nbsp;parado (stopped)&nbsp;ou&nbsp;modo zumbi (zombie)

3 – Estados da CPU (CPU States)

Cpu(s): 15.4%us,&nbsp; 5.7%sy,&nbsp; 0.0%ni, 78.8%id,&nbsp; 0.2%wa,&nbsp; 0.0%hi,&nbsp; 0.0%si,&nbsp; 0.0%st


Em seguida é apresentado o estado da CPU. O significado dos diferentes tempos de CPU são:

* us, usuário (user): tempo de CPU na execução dos processos de usuário&nbsp;* Sy, sistema (sytem): tempo de CPU na execução de processos do kernel&nbsp;* Id, ocioso (idle): tempo de CPU em inatividade&nbsp;* Wa, tempo para I/O: tempo de CPU esperando a conclusão de operação de entrada/saída no disco (I/O)&nbsp;* hi: CPU tempo servindo interrupções de hardware&nbsp;* Si: tempo de CPU servindo interrupções de software

4 – Uso da memória (Memory Usage)

Mem:&nbsp;&nbsp; 3058052k total,&nbsp; 2100524k used,&nbsp;&nbsp; 957528k free,&nbsp;&nbsp; 168696k buffers
Swap:&nbsp; 3481788k total,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0k used,&nbsp; 3481788k free,&nbsp; 1099720k cached


Estes mostram o uso de memória, um pouco do comando “free”. A primeira linha refere-se a memória física e a segunda linha a memória virtual (swap). A memória física é apresentada como: memória total disponível, memória usada, memória livre e memória usada para buffers. Da mesma forma, a swap: total, usada, espaço de troca livre e em cache. Todas em unidade Kilobyte

5 – Colunas

 PID USER&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PR&nbsp; NI&nbsp; VIRT&nbsp; RES&nbsp; SHR S %CPU %MEM&nbsp;&nbsp;&nbsp; TIME+&nbsp; COMMAND&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;3187 ricardo&nbsp;&nbsp; RT&nbsp;&nbsp; 0 1129m 403m&nbsp; 43m S&nbsp;&nbsp; 14 13.5&nbsp; 28:23.04 firefox&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;1238 root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 20&nbsp;&nbsp; 0 98840&nbsp; 27m 8876 S&nbsp;&nbsp;&nbsp; 6&nbsp; 0.9&nbsp;&nbsp; 4:45.38 Xorg&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;2398 ricardo&nbsp;&nbsp; 20&nbsp;&nbsp; 0&nbsp; 429m&nbsp; 76m&nbsp; 29m S&nbsp;&nbsp;&nbsp; 4&nbsp; 2.6&nbsp;&nbsp; 3:01.05&nbsp; compiz


Nesta seção, os processos são apresentados em colunas. As diferentes colunas representam diferentes propriedades exibidas abaixo:

PID (Identificador do processo)&nbsp;A identificação do processo (identificador único)

USUÁRIO (USER)&nbsp;Usuário proprietário do processo.

PR (Prioridade)&nbsp;A prioridade de agendamento do processo. Alguns valores neste campo são ‘ RT ‘ . Isso significa que o processo está sendo executado em tempo real (Real Time).

NI&nbsp;Os valores mais baixos significam maior prioridade.

VIRT&nbsp;A quantidade de memória virtual usada pelo processo.

RES&nbsp;O tamanho da memória usada. Residente na memória física e não na área de troca (swap).

SHR (Share – compartilhada)&nbsp;SHR é a memória compartilhada usada pelo processo.

S (State – estado)Este é o estado do processo . Ele pode ter um dos seguintes valores :

D – ininterrupto&nbsp;R – executando&nbsp;S – dormindo&nbsp;T – rastreado ou parado&nbsp;Z – zumbi

% CPU&nbsp;É a porcentagem de tempo de CPU que a tarefa tem usado desde a última atualização.

% MEM&nbsp;Percentagem de memória física disponível usada pelo processo.

TEMPO +&nbsp;O tempo total de CPU que a tarefa tem usado desde o início (precisão de centésimo de segundo)

COMANDO&nbsp;Descrição do comando que foi utilizado para iniciar o processo.


II – OPÇÕES DO COMANDO


1 – Resultado enxuto

top -b

2 – Tempo de atualização (a cada 2 segundos)

top -d 2

3 – Somente processos executando

top -i

4 – Limite de iteração

top -n 3

5 – Especificando o usuário

top -u “nome_usuario”


III – COMANDOS INTERATIVOS


Esses comandos serão usados durante a execução do comando TOP.

1 – ‘h’: Help

Help for Interactive Commands - procps version 3.2.8
Window 1:Def: Cumulative mode Off.&nbsp; System: Delay 3.0 secs; Secure mode Off.
&nbsp;
&nbsp; Z,B&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Global: 'Z' change color mappings; 'B' disable/enable bold
&nbsp; l,t,m&nbsp;&nbsp;&nbsp;&nbsp; Toggle Summaries: 'l' load avg; 't' task/cpu stats; 'm' mem info
&nbsp; 1,I&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Toggle SMP view: '1' single/separate states; 'I' Irix/Solaris mode
&nbsp;
&nbsp; f,o&nbsp;&nbsp;&nbsp;&nbsp; . Fields/Columns: 'f' add or remove; 'o' change display order
&nbsp; F or O&nbsp; . Select sort field
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; . Move sort field: '' next col right
&nbsp; R,H&nbsp;&nbsp;&nbsp;&nbsp; . Toggle: 'R' normal/reverse sort; 'H' show threads
&nbsp; c,i,S&nbsp;&nbsp; . Toggle: 'c' cmd name/line; 'i' idle tasks; 'S' cumulative time
&nbsp; x,y&nbsp;&nbsp;&nbsp;&nbsp; . Toggle highlights: 'x' sort field; 'y' running tasks
&nbsp; z,b&nbsp;&nbsp;&nbsp;&nbsp; . Toggle: 'z' color/mono; 'b' bold/reverse (only if 'x' or 'y')
&nbsp; u&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; . Show specific user only
&nbsp; n or #&nbsp; . Set maximum tasks displayed


2 – ‘ENTER’: Atualizar a amostragem

3 – ‘d’: Informe o tempo de atualização

top - 00:25:27 up&nbsp; 2:52,&nbsp; 1 user,&nbsp; load average: 0.70, 0.65, 0.62
Tasks: 190 total,&nbsp;&nbsp; 2 running, 187 sleeping,&nbsp;&nbsp; 0 stopped,&nbsp;&nbsp; 1 zombie
Cpu(s): 13.5%us,&nbsp; 3.9%sy,&nbsp; 4.3%ni, 76.8%id,&nbsp; 1.4%wa,&nbsp; 0.0%hi,&nbsp; 0.1%si,&nbsp; 0.0%st
Mem:&nbsp;&nbsp; 3058052k total,&nbsp; 2106460k used,&nbsp;&nbsp; 951592k free,&nbsp;&nbsp; 177340k buffers
Swap:&nbsp; 3481788k total,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0k used,&nbsp; 3481788k free,&nbsp; 1086764k cached
Change delay from 3.0 to: 
&nbsp;&nbsp;PID USER&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PR&nbsp; NI&nbsp; VIRT&nbsp; RES&nbsp; SHR S %CPU %MEM&nbsp;&nbsp;&nbsp; TIME+&nbsp; COMMAND&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;3187 ricardo&nbsp;&nbsp; 22&nbsp;&nbsp; 2 1216m 418m&nbsp; 43m S&nbsp;&nbsp; 20 14.0&nbsp; 50:26.41 firefox 


4 – ‘f’: Controle quais valores devem ser exibidos

Current Fields:&nbsp; AEHIOQTWKNMbcdfgjplrsuvyzX&nbsp; for window 1:Def
Toggle fields via field letter, type any other key to return 
&nbsp;
* A: PID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = Process Id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0x00100000&nbsp; PF_USEDFPU (thru 2.4)
* E: USER&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = User Name
* H: PR&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = Priority
* I: NI&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= Nice value
* O: VIRT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = Virtual Image (kb)
* Q: RES&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = Resident size (kb)
* T: SHR&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = Shared Mem size (kb)
* W: S&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = Process Status
* K: %CPU&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = CPU usage
* N: %MEM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = Memory usage (RES)
* M: TIME+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = CPU Time, hundredths
&nbsp; b: PPID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = Parent Process Pid
&nbsp; c: RUSER&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = Real user name
&nbsp; d: UID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = User Id
&nbsp; f: GROUP&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = Group Name
&nbsp; g: TTY&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = Controlling Tty
&nbsp; j: P&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = Last used cpu (SMP)


5 – ‘i’: Apenas processos em execução

6 – ‘k’: Matar processos pelo identificador (ID)



http://www.linuxdescomplicado.com.br/2013/12/comandos-linux-dominando-o-comando-top.html





Resident and Virtual memory on Linux: A short example



Tools like&nbsp;top&nbsp;show processes using two kinds of memory:

·&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Resident memory, labelled RES: How much physical memory, how much RAM, your process is using.&nbsp;RES is the important number.

·&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Virtual memory, labelled VIRT: How much memory your process&nbsp;thinks&nbsp;it’s using. Usually much bigger than RES, thanks to the Linux kernel’s clever memory management.





Here’s a short C program to illustrate the difference:

#include &lt;stdio.h&gt;

#include &lt;stdlib.h&gt;



void fill(unsigned char* addr, size_t amount) {

&nbsp;&nbsp;&nbsp; unsigned long i;

&nbsp;&nbsp;&nbsp; for (i = 0; i &lt; amount; i++) {

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *(addr + i) = 42;

&nbsp;&nbsp;&nbsp; }

}



int main(int argc, char **argv) {



&nbsp;&nbsp;&nbsp; unsigned char *result;

&nbsp;&nbsp;&nbsp; char input;

&nbsp;&nbsp;&nbsp; size_t s = 1&lt;&lt;30;



&nbsp;&nbsp;&nbsp; result = malloc(s);

&nbsp;&nbsp;&nbsp; printf("Addr: %p\n", result);

&nbsp;&nbsp;&nbsp; //fill(result, s);



&nbsp;&nbsp;&nbsp; scanf("%c", &amp;input);

&nbsp;&nbsp;&nbsp; return 0;

}

Save it as&nbsp;mem.c, compile it&nbsp;cc -Wall -g mem.c -o mem&nbsp;and run it.

It requests 1 Gig of memory (1 &lt;&lt; 30), but doesn’t use it. With&nbsp;top&nbsp;(or&nbsp;htop, which is much nicer), or even&nbsp;ps -Ao rsz,vsz,cmd | grep mem&nbsp;view it’s memory usage. The resident size should be quite small (~280k for me), but the virtual size will be the full 1 Gig we requested.

Uncomment the&nbsp;fill&nbsp;line, compile and run it again. You should see the resident size get much bigger, as we’re actually using the memory we requested (we’re filling it with the number 42). The kernel has to give us real memory to work with.

We can request far more virtual memory than the machine can handle. Here’s a screenshot where I’ve requested 16 Gig of memory, on a machine with only 3 Gig of RAM and 3 Gig of swap. The VIRT’s sum up to way more than that machine can handle. At the top left of the screenshot you can see none of that memory has really been allocated.&nbsp;The kernel won’t allocate it until we use it.



In summary, virtual size can largely be ignored. Resident size is the important number.



Fontes:&nbsp;RICARDO FERREIRA