How to Monitor the performance of Linux using pidstat
To Monitor the performance of Linux using pidstat
pidstat command is used to monitor child process of selected tasks which is monitored by the Linux kernel.
To display all active task using pidstat
[root@linuxhelp Desktop]# pidstat
Linux 2.6.32-573.18.1.el6.x86_64 (linuxhelp.com) 04/01/2016 _x86_64_ (1 CPU)
01:28:05 PM PID %usr %system %guest %CPU CPU Command
01:28:05 PM 1 0.00 0.04 0.00 0.04 0 init
01:28:05 PM 4 0.00 0.00 0.00 0.00 0 ksoftirqd/0
01:28:05 PM 7 0.00 0.08 0.00 0.08 0 events/0
01:28:05 PM 16 0.00 0.00 0.00 0.00 0 sync_supers
01:28:05 PM 17 0.00 0.00 0.00 0.00 0 bdi-default
01:28:05 PM 19 0.00 0.03 0.00 0.03 0 kblockd/0
01:28:05 PM 24 0.00 0.02 0.00 0.02 0 ata_sff/0
.
.
.
01:28:05 PM 3098 3.05 0.42 0.00 3.47 0 firefox
01:28:05 PM 3252 0.07 0.02 0.00 0.08 0 gnome-terminal
01:28:05 PM 3255 0.00 0.00 0.00 0.00 0 bash
01:28:05 PM 3930 0.00 0.00 0.00 0.00 0 pidsta
To display all active and inactive process
Option &ndash p with pidstat is used to display all active and inactive process statistics.
[root@linuxhelp Desktop]# pidstat -p ALL
Linux 2.6.32-573.18.1.el6.x86_64 (linuxhelp.com) 04/01/2016 _x86_64_ (1 CPU)
01:29:53 PM PID %usr %system %guest %CPU CPU Command
01:29:53 PM 1 0.00 0.04 0.00 0.04 0 init
01:29:53 PM 2 0.00 0.00 0.00 0.00 0 kthreadd
01:29:53 PM 3 0.00 0.00 0.00 0.00 0 migration/0
01:29:53 PM 4 0.00 0.00 0.00 0.00 0 ksoftirqd/0
01:29:53 PM 5 0.00 0.00 0.00 0.00 0 stopper/0
01:29:53 PM 6 0.00 0.00 0.00 0.00 0 watchdog/0
01:29:53 PM 7 0.00 0.08 0.00 0.08 0 events/0
01:29:53 PM 8 0.00 0.00 0.00 0.00 0 events/0
01:29:53 PM 9 0.00 0.00 0.00 0.00 0 events_long/0
01:29:53 PM 10 0.00 0.00 0.00 0.00 0 events_power_ef
01:29:53 PM 11 0.00 0.00 0.00 0.00 0 cgroup
01:29:53 PM 12 0.00 0.00 0.00 0.00 0 khelper
01:29:53 PM 13 0.00 0.00 0.00 0.00 0 netns
.
.
.
.
01:29:53 PM 2396 0.00 0.00 0.00 0.00 0 atd
01:29:53 PM 2420 0.00 0.00 0.00 0.00 0 certmonger
01:29:53 PM 2426 0.00 0.00 0.00 0.00 0 gdm-binary
01:29:53 PM 2431 0.00 0.00 0.00 0.00 0 mingetty
01:29:53 PM 2434 0.00 0.00 0.00 0.00 0 mingetty
01:29:53 PM 2436 0.00 0.00 0.00 0.00 0 mingetty
To get input and output statistics information
Option &ndash d with pidstat is used to get input and output statistics information with refreshment of specific time interval.
[root@linuxhelp Desktop]# pidstat -d 2
Linux 2.6.32-573.18.1.el6.x86_64 (linuxhelp.com) 04/01/2016 _x86_64_ (1 CPU)
01:38:44 PM PID kB_rd/s kB_wr/s kB_ccwr/s Command
01:38:46 PM 344 0.00 2.03 0.00 flush-8:0
01:38:46 PM PID kB_rd/s kB_wr/s kB_ccwr/s Command
01:38:48 PM PID kB_rd/s kB_wr/s kB_ccwr/s Command
01:38:50 PM 296 0.00 4.04 0.00 jbd2/sda2-8
01:38:50 PM 3098 0.00 20.20 0.00 firefox
01:38:50 PM PID kB_rd/s kB_wr/s kB_ccwr/s Command
01:38:52 PM 2145 0.00 2.06 2.06 tpvmlp
To display specific process id status
Option -p with pidstat is used to display the specific process id status.
[root@linuxhelp Desktop]# pidstat -p 3255
Linux 2.6.32-573.18.1.el6.x86_64 (linuxhelp.com) 04/01/2016 _x86_64_ (1 CPU)
01:40:05 PM PID %usr %system %guest %CPU CPU Command
01:40:05 PM 3255 0.00 0.00 0.00 0.00 0 bash
To display memory utilization process
Option &ndash rh with pidstat is used to display your memory utilization process
[root@linuxhelp Desktop]# pidstat &ndash rh
Linux 2.6.32-573.18.1.el6.x86_64 (linuxhelp.com) 04/01/2016 _x86_64_ (1 CPU)
# Time PID minflt/s majflt/s VSZ RSS %MEM Command
1459498322 1 0.60 0.00 19356 1244 0.12 init
1459498322 390 0.20 0.00 11100 272 0.03 udevd
1459498322 1357 0.05 0.00 186536 568 0.06 vmware-vmblock-
1459498322 1392 0.77 0.00 189528 2200 0.22 vmtoolsd
1459498322 1699 0.06 0.00 27596 680 0.07 auditd
1459498322 1733 0.15 0.01 249092 1056 0.10 rsyslogd
1459498322 1784 0.05 0.00 18976 576 0.06 rpcbind
1459498322 1806 0.08 0.00 23348 708 0.07 rpc.statd
1459498322 1846 0.02 0.00 25168 272 0.03 rpc.idmapd
This command will display memory utilization with some time interval and counts.
[root@linuxhelp Desktop]# pidstat -rh 2 3
Linux 2.6.32-573.18.1.el6.x86_64 (linuxhelp.com) 04/01/2016 _x86_64_ (1 CPU)
# Time PID minflt/s majflt/s VSZ RSS %MEM Command
1459498378 3098 18.18 0.00 1357800 411908 40.68 firefox
1459498378 4106 153.03 0.00 101128 920 0.09 pidstat
# Time PID minflt/s majflt/s VSZ RSS %MEM Command
1459498380 3098 21.21 0.00 1357800 412076 40.70 firefox
1459498380 4106 155.56 0.00 101128 948 0.09 pidstat
# Time PID minflt/s majflt/s VSZ RSS %MEM Command
1459498382 2353 2.06 0.00 116860 688 0.07 crond
1459498382 3098 19.07 0.00 1357800 412224 40.72 firefox
1459498382 4106 155.15 0.00 101128 948 0.09 pidstat
To know your CPU statics
Option &ndash t -p with pidstat is used to display your CPU statics and threads for specific process id in some time interval with counts.
[root@linuxhelp Desktop]# pidstat -t -p 3255 2 3
Linux 2.6.32-573.18.1.el6.x86_64 (linuxhelp.com) 04/01/2016 _x86_64_ (1 CPU)
01:49:06 PM TGID TID %usr %system %guest %CPU CPU Command
01:49:08 PM 3255 - 0.00 0.00 0.00 0.00 0 bash
01:49:08 PM - 3255 0.00 0.00 0.00 0.00 0 |__bash
01:49:08 PM TGID TID %usr %system %guest %CPU CPU Command
01:49:10 PM 3255 - 0.00 0.00 0.00 0.00 0 bash
01:49:10 PM - 3255 0.00 0.00 0.00 0.00 0 |__bash
01:49:10 PM TGID TID %usr %system %guest %CPU CPU Command
01:49:12 PM 3255 - 0.00 0.00 0.00 0.00 0 bash
01:49:12 PM - 3255 0.00 0.00 0.00 0.00 0 |__bash
Average: TGID TID %usr %system %guest %CPU CPU Command
Average: 3255 - 0.00 0.00 0.00 0.00 - bash
Average: - 3255 0.00 0.00 0.00 0.00 - |__bash
To display performance statics based on process name
Option &ndash C with pidstat is used to display the performance statics based on process name and option &ndash l is used to list process information details.
[root@linuxhelp Desktop]# pidstat -C python &ndash l
Linux 2.6.32-573.22.1.el6.x86_64 (linuxhelp) 03/31/2016 _x86_64_ (1 CPU)
08:32:51 PM PID %usr %system %guest %CPU CPU Command
08:32:51 PM 3388 0.00 0.01 0.00 0.01 0 python /usr/share/system-config-printer/applet.py
To display performance statistics by tree format
Option -t with pidstat is used to display performance statistics by tree format.
[root@linuxhelp Desktop]# pidstat -t -C python
Linux 2.6.32-573.18.1.el6.x86_64 (linuxhelp.com) 04/01/2016 _x86_64_ (1 CPU)
02:01:10 PM TGID TID %usr %system %guest %CPU CPU Command
02:01:10 PM 2794 - 0.00 0.02 0.00 0.02 0 python
02:01:10 PM - 2794 0.00 0.02 0.00 0.02 0 |__python
To display selected process along with child process
Using option -T with pidstat will display the selected process along with child process. Instead of CHILD option you can also use TASKS and ALL option all these option display the same result.
[root@linuxhelp Desktop]# pidstat -T CHILD | who -l
LOGIN tty2 2016-04-01 12:27 2431 id=2
LOGIN tty3 2016-04-01 12:27 2434 id=3
LOGIN tty4 2016-04-01 12:27 2436 id=4
LOGIN tty5 2016-04-01 12:27 2440 id=5
LOGIN tty6 2016-04-01 12:27 2442 id=6
To monitor multiple performances
Option -h is used to monitor multiple performances.
[root@linuxhelp Desktop]# pidstat -rud -h | head
Linux 2.6.32-573.22.1.el6.x86_64 (linuxhelp) 03/31/2016 _x86_64_ (1 CPU)
# Time PID %usr %system %guest %CPU CPU minflt/s majflt/s VSZ RSS %MEM kB_rd/s kB_wr/s kB_ccwr/s Command
1459436947 1 0.00 0.07 0.00 0.07 0 1.45 0.01 19356 1132 0.11 497.35 104.27 3.69 init
1459436947 4 0.00 0.00 0.00 0.00 0 0.00 0.00 0 0 0.00 0.00 0.00 0.00 ksoftirqd/0
1459436947 7 0.00 0.12 0.00 0.12 0 0.00 0.00 0 0 0.00 0.00 0.00 0.00 events/0
1459436947 16 0.00 0.00 0.00 0.00 0 0.00 0.00 0 0 0.00 0.00 0.00 0.00 sync_supers
1459436947 17 0.00 0.00 0.00 0.00 0 0.00 0.00 0 0 0.00 0.00 0.00 0.00 bdi-default
1459436947 19 0.00 0.08 0.00 0.08 0 0.00 0.00 0 0 0.00 0.00 0.00 0.00 kblockd/0
1459436947 26 0.00 0.00 0.00 0.00 0 0.00
Comments ( 0 )
No comments available