24 Temmuz 2020 Cuma

top komutu

Giriş
İşlemcileri izlemek için gnome-system-monitor uygulamasının Resources sekmesi benim tercihim.

top uygulaması q tuşuna basında sonlanınca ekranı temizlemiyor. Temizlemesi için şöyle yaparız.
top && clear
Çıktı
1. En üstte sistemle ilgili özet bilgiler var
2. Altında ise sütunlar var

Tuşlar
i tuşu
Açıklaması şöyle
top is an interactive program, for instance you can type i to toggle showing idle processes.

1. Özet Bilgiler
1.1 Tasks Satırı
1.2 Cpu(s) Satırı
%us %sy %ni %id %wa %hi %si %st ile biten değerler var

%us
Toplam işlemci kullanımını gösterir. Eğer %100 ise sistem çok dolu demektir. "Chaos Engineering" için bu yük testi yapılabilir.

%ni ile biten değer "Nice CPU Time" anlamına gelir
Açıklaması şöyle
‘nice CPU time’ is the amount of time a CPU spends in running low priority processes (whose nice values are greater than 0). 

%wa ile biten değer "Waiting CPU Time" anlamına gelir.
Açıklaması şöyle
Waiting CPU time indicates the amount of time the CPU spends waiting for disk I/O or network I/O operations to complete. A high waiting time indicates that the CPU is *stranded* because of the I/O operations on that device. For optimal performance, one should aim to keep the I/O waiting CPU time as low as possible. If waiting time is > 10%, then it is worth investigating it.
%si ile biten değer "Software Interrupt Time" anlamına gelir
Açıklaması şöyle
Software interrupts can be triggered because of the following events:

- When software run into exceptional conditions such as a divide by zero or accessing unavailable memory.
- When a special instruction in the application code causes an interrupt when the processor executes it.
- Some hardware interrupts might take a long time to complete. In such scenarios, hardware interrupts can be deferred to execute at a later point of time through software interrupts. Software interrupts can be scheduled to run independently or on any CPU in the device or even run concurrently. On the other hand, these flexibilities don’t exist in hardware interrupts.

The amount of time the CPU spends in processing these software interrupt signals is called ‘Software interrupt time’. 
1.3 Mem Satırı
1.4 Swap Satırı

2. Sütunlar
USER Sütunu
Uygulamayı çalıştıran kullanıcı 8 karakter uzunluğunda. Açıklaması şöyle.
The default width for the USER column is 8 characters, and the column doesn’t scale with its contents. The width can be adjusted with X while top is running.
PR ve NI Sütunu
Priority ve Nice değerlerini gösterir. NI sütunu nice komutu ile atanabilir.
Örnek
Şöyle yaparız. Burada 3239 numaralı process'in thread'lerini görüyoruz. Java thread'i 20 PR (priority) değerine sahip. HighPriority ve LowPriority ismine sahip thread'ler ise 17 ve 23 PR (priority) deperlerine sahipler. Dolayısıyla NI (nice) değerleri de ona göre
$ top -p 3239
|  PID | PR | NI | VIRT    |   RES | %MEM | COMMAND         |
|------+----+----+---------+-------+------+-----------------|
| 3239 | 20 |  0 | 10.686g | 33996 |  0.1 | java            |
| 3256 | 17 | -3 | 10.686g | 33996 |  0.1 | HighPriority    |
| 3257 | 23 |  3 | 10.686g | 33996 |  0.1 | LowPriority     |
RES Sütunu
Açıklaması şöyle. Kullanılan RAM miktarını gösterir.
The RES column is physical memory. The VIRT column shows all the virtual memory used by the process. According to man top, that includes all code, data, and shared libraries plus pages that have been swapped out and pages that have been mapped but not used.
S Sütunu
S sütununda - Status sütunu anlamına gelir - bazı harfler görünür. Bir harf Z ise Zombie anlamına gelir. Harfle şöyle
Process status is reported with a single character:

R — RUNNING/RUNNABLE
S — INTERRUPTABLE_SLEEP
D — UNINTERRUPTABLE_SLEEP
T — STOPPED
Z — ZOMBIE
3. Seçenekler

- b seçeneği
batch mode seçeneği. Çıktıyı başka programa gönderir. Açıklaması şöyle.
The -b argument makes top run in batch mode – the information is gathered, displayed, and then dumped to stdout as opposed to running in an interactive mode and refreshing the data displayed.

With the -b option, the user must tell top how many times to run, this is done with the -n argument and a final argument with how many times to run.
Örnek
Şöyle yaparız.
top -b | awk '/dockerd/ {print strftime("%Y-%m-%d-%H:%M:%S"), $0}'
Çıktı olarak şunu alırız.
2017-05-11-18:54:18  2569 root 20 0  624m  41m  28m S  0.0  4.2   0:07.32 dockerd
2017-05-11-18:54:21  2569 root 20 0  624m  41m  28m S  0.0  4.2   0:07.32 dockerd
2017-05-11-18:54:24  2569 root 20 0  624m  41m  28m S  0.0  4.2   0:07.32 dockerd
Örnek
Şöyle yaparız.
watch top -b
-H seçeneği
thread'leri göster seçeneği. Açıklaması şöyle.
The -H argument instructs top to display each individual thread. Normally top summarizes all threads under their parent process.
Örnek
Şöyle yaparız.
top -H -b -n 1
Örnek
Bir process'in thread'lerini izlemek istersek kullanabiliriz. Şöyle yaparız.
top -H -p <pid>
Eğer -H seçeneği desteklenmiyorsa -p ile process'i görüntüledikten sonra klavyede H tuşuna basarak aynı sonucu elde edebiliriz.

-p seçeneği - pid verilir
Örnek
Şöyle yaparız
top -p "$(pgrep gvfs | paste -s -d ',')"


Hiç yorum yok:

Yorum Gönder