pidstat – Statistiche sui processi e sui thread del kernel

()

pidstat – Statistiche sui processi e sui thread del kernel

Questo viene utilizzato per il monitoraggio dei processi e i thread correnti, che vengono gestiti dal kernel. pidstat può anche controllare lo stato dei processi e dei thread figli.

Sintassi
# pidstat <OPZIONI> [INTERVALLO] [CONTEGGIO]

1. Utilizzando il comando pidstat senza alcun argomento, verranno visualizzate tutte le attività attive.

tecmint@tecmint  ~ $ pidstat

Linux 3.11.0-23-generic (tecmint.com) giovedì 04 settembre 2014 _i686_ (2 CPU)

12:47:24 IST UID PID %usr %system %guest %CPU Comando CPU
12:47:24 IST 0 1 0,01 0,12 0,00 0,13 1 init
12:47:24 IST 0 3 0,00 0,01 0,00 0,01 0 ksoftirqd/0
12:47:24 IST 0 9 0,00 0,04 0,00 0,04 0 rcu_sched
12:47:24 IST 0 10 0,00 0,00 0,00 0,00 0 watchdog/0
12:47:24 IST 0 11 0.00 0.00 0.00 0.00 1 watchdog/1
12:47:24 IST 0 12 0,00 0,00 0,00 0,00 1 migrazione/1
12:47:24 IST 0 13 0,00 0,01 0,00 0,01 1 ksoftirqd/1
12:47:24 IST 0 23 0,00 0,00 0,00 0,00 0 kworker/u9:0
12:47:24 IST 0 29 0,00 0,61 0,00 0,61 0 klavoratore/0:1
12:47:24 IST 0 30 0,00 0,06 0,00 0,06 1 klavoratore/1:1
12:47:24 IST 0 224 0,00 0,01 0,00 0,01 1 jbd2/sda1-8
12:47:24 IST 0 360 0.00 0.00 0.00 0.00 1 upstart-udev-br
12:47:24 IST 0 365 0,01 0,00 0,00 0,01 0 systemd-udevd
12:47:24 IST 0 476 0,00 0,00 0,00 0,00 0 kworker/u9:1

2. Per stampare tutte le attività attive e non attive utilizzare l’opzione ‘ -p ‘ (processi).

tecmint@tecmint  ~ $ pidstat -p ALL

Linux 3.11.0-23-generic (tecmint.com) giovedì 04 settembre 2014 _i686_ (2 CPU)

12:51:55 IST UID PID %usr %system %guest %CPU CPU Command
12:51:55 IST 0 1 0,01 0,11 0,00 0,12 1 init
12:51:55 IST 0 2 0,00 0,00 0,00 0,00 0 kthreadd
12:51:55 IST 0 3 0,00 0,01 0,00 0,01 0 ksoftirqd/0
12:51:55 IST 0 5 0,00 0,00 0,00 0,00 0 klavoratore/0:0H
12:51:55 IST 0 7 0,00 0,00 0,00 0,00 0 migrazione/0
12:51:55 IST 0 8 0,00 0,00 0,00 0,00 0 rcu_bh
12:51:55 IST 0 9 0,00 0,04 0,00 0,04 1 rcu_sched
12:51:55 IST 0 10 0,00 0,00 0,00 0,00 0 watchdog/0
12:51:55 IST 0 11 0.00 0.00 0.00 0.00 1 watchdog/1
12:51:55 IST 0 12 0,00 0,00 0,00 0,00 1 migrazione/1
12:51:55 IST 0 13 0,00 0,01 0,00 0,01 1 ksoftirqd/1
12:51:55 IST 0 15 0.00 0.00 0.00 0.00 1 kworker/1:0H
12:51:55 IST 0 16 0.00 0.00 0.00 0.00 1 khelper
12:51:55 IST 0 17 0.00 0.00 0.00 0.00 0 kdevtmpfs
12:51:55 IST 0 18 0.00 0.00 0.00 0.00 0 netns
12:51:55 IST 0 19 0,00 0,00 0,00 0,00 0 riscrittura
12:51:55 IST 0 20 0.00 0.00 0.00 0.00 1 kintegrityd

3. Usando il comando pidstat con l’ opzione ‘ -d 2 ‘, possiamo ottenere statistiche I/O e 2 è l’intervallo in secondi per ottenere statistiche aggiornate. Questa opzione può essere utile in situazioni in cui il sistema è sottoposto a un I/O pesante e si desidera ottenere indizi sui processi che consumano risorse elevate.

tecmint@tecmint  ~ $ pidstat -d 2

Linux 3.11.0-23-generic (tecmint.com) giovedì 04 settembre 2014 _i686_ (2 CPU)

03:26:53 EDT PID kB_rd/s kB_wr/s kB_ccwr/s Comando

03:26:55 EDT PID kB_rd/s kB_wr/s kB_ccwr/s Comando
03:26:57 EDT 574 0.00 148,00 2.00 miniserv.pl

03:27:01 EDT PID kB_rd/s kB_wr/s kB_ccwr/s Comando
03:27:03 EDT 1 0.00 8.00 2.00 init
03:27:03 EDT 450 0.00 2.00 0.00 rsyslogd
03:27:03 EDT 534 138.00 10.00 4.00 crond
03:27:03 EDT 25100 0.00 6.00 0.00 sendmail
03:27:03 EDT 30829 0.00 6.00 0.00 java

4. Per conoscere le statistiche della CPU insieme a tutti i thread sul processo id 4164 a intervalli di 2 secondi per 3 volte, utilizzare il seguente comando con l’opzione ‘ -t ‘ (visualizza le statistiche del processo selezionato).

tecmint@tecmint  ~ $ pidstat -t -p 4164 2 3

Linux 3.11.0-23-generic (tecmint.com) giovedì 04 settembre 2014 _i686_ (2 CPU)

01:09:06 IST UID TGID TID %usr %system %guest %CPU Comando CPU
01:09:08 IST 1000 4164 - 22.00 1.00 0.00 23.00 1 firefox
01:09:08 IST 1000 - 4164 20,00 0,50 0,00 20,50 1 |__firefox
01:09:08 IST 1000 - 4171 0,00 0,00 0,00 0,00 0 |__Gecko_IOThread
01:09:08 IST 1000 - 4172 0,00 0,00 0,00 0,00 0 |__Presa
01:09:08 IST 1000 - 4173 0,00 0,00 0,00 0,00 0 |__JS
01:09:08 IST 1000 - 4174 0,00 0,00 0,00 0,00 0 |__JS
01:09:08 IST 1000 - 4175 0.00 0.00 0.00 0.00 0 |__Hang
01:09:08 IST 1000 - 4176 0,00 0,00 0,00 0,00 1 |__gdbus
01:09:08 IST 1000 - 4177 0,00 0,00 0,00 0,00 1 |__gmain

5. Utilizzare l’ opzione ‘ -rh ‘, per conoscere l’utilizzo della memoria dei processi che variano frequentemente il loro utilizzo in intervalli di 2 secondi.

tecmint@tecmint  ~ $ pidstat -rh 2 3

Linux 3.11.0-23-generic (tecmint.com) giovedì 04 settembre 2014 _i686_ (2 CPU)

# Tempo UID PID minflt/s majflt/s VSZ RSS %MEM Command
 1409816695 1000 3958 3378,22 0,00 707420 215972 5,32 cannella
 1409816695 1000 4164 406.93 0.00 1252024 461404 11.36 firefox
 1409816695 1000 6676 168,81 0,00 4436 984 0,02 pidstat

# Tempo UID PID minflt/s majflt/s VSZ RSS %MEM Command
 1409816697 0 1601 644,00 0,00 506728 316788 7,80 Xorg
 1409816697 1000 3958 3412.00 0.00 707420 215972 5.32 cannella
 1409816697 1000 4164 2667,00 0,00 1259576 471724 11,62 firefox
 1409816697 1000 6676 172,50 0,00 4436 1020 0,03 pidstat

# Tempo UID PID minflt/s majflt/s VSZ RSS %MEM Command
 1409816699 0 1601 644,00 0,00 506728 316788 7,80 Xorg
 1409816699 1000 3958 4094,00 0,00 710148 218700 5,39 cannella
 1409816699 1000 4164 599.00 0.00 1261944 476664 11.74 firefox
 1409816699 1000 6676 168,00 0,00 4436 1020 0,03 pidstat

6. Per stampare tutto il processo di contenimento della stringa ” VB “, utilizzare l’opzione ‘ -t ‘ per vedere anche i thread.

tecmint@tecmint  ~ $ pidstat -G VB

Linux 3.11.0-23-generic (tecmint.com) giovedì 04 settembre 2014 _i686_ (2 CPU)

01:09:06 IST UID PID %usr %sistema %guest %CPU Comando CPU
01:09:08 IST 1000 1492 22,00 1,00 0,00 23,00 1 VBoxService
01:09:08 IST 1000 1902 4164 20,00 0,50 0,00 20,50 VBoxClient
01:09:08 IST 1000 1922 4171 0,00 0,00 0,00 0,00 VBoxClient
tecmint@tecmint  ~ $ pidstat -t -G VB
Linux 2.6.32-431.el6.i686 (tecmint) 04/09/2014 _i686_ (2 CPU)

15:19:52 UID TGID TID %usr %system %guest %CPU Comando CPU
15:19:52 0 1479 - 0,01 0,12 0,00 0,13 1 VBoxService
15:19:52 0 - 1482 0,00 0,00 0,00 0,00 0 |__timesync
15:19:52 0 - 1483 0,01 0,06 0,00 0,06 0 |__vminfo
15:19:52 0 - 1485 0.00 0.01 0.00 0.01 1 |__memballoon
15:19:52 0 - 1486 0,00 0,01 0,00 0,01 1 |__vmstats
15:19:52 0 - 1487 0.00 0.05 0.00 0.05 0 |__automount
15:19:52 0 1913 - 0,00 0,00 0,00 0,00 0 VBoxClient
15:19:52 0 - 1913 0,00 0,00 0,00 0,00 0 |__VBoxClient
15:19:52 0 - 1942 0,00 0,00 0,00 0,00 0 |__SHCLIP
15:19:52 0 1933 - 0,04 0,89 0,00 0,93 0 VBoxClient
15:19:52 0 - 1936 0,04 0,89 0,00 0,93 1 |__X11-NOTIFY

7. Per ottenere la priorità in tempo reale e le informazioni sulla pianificazione, utilizzare l’opzione ‘ -R ‘.

tecmint@tecmint  ~ $ pidstat -R

Linux 3.11.0-23-generic (tecmint.com) giovedì 04 settembre 2014 _i686_ (2 CPU)

01:09:06 Comando IST UID PID prio policy
01:09:08 IST 1000 3 99 migrazione FIFO/0
01:09:08 IST 1000 5 99 migrazione FIFO/0
01:09:08 IST 1000 6 99 watchdog FIFO/0

/ 5
Grazie per aver votato!

How useful was this post?

Click on a star to rate it!

Average rating / 5. Vote count:

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?