리눅스 관련 일을 하다보면 간혹 PID 에 관련하여 cpu, memory, disk IO 에 대한 사용률을 확인해야 할 경우가 있다.
pidstat 은(는) sysstat 에 포함되어져 있으나 RHEL의 sysstat 같은경우 pidstat 를 포함하고 있지 않다.
그러므로 Source 나 SRPM 을 가져다 빌드 해서 써야하는 어려움이 있다.
관련 내용 :
NAME
pidstat - Report statistics for Linux tasks.
SYNOPSIS
pidstat [ -C comm ] [ -d ] [ -h ] [ -I ] [ -l ] [ -p { pid [,...] | SELF | ALL } ] [ -r ] [ -t ] [ -T { TASK | CHILD | ALL } ] [ -u ]
[ -V ] [ -w ] [ interval [ count ] ]
DESCRIPTION
The pidstat command is used for monitoring individual tasks currently being managed by the Linux kernel. It writes to standard output
activities for every task selected with option -p or for every task managed by the Linux kernel if option -p ALL has been used. Not
selecting any tasks is equivalent to specifying -p ALL but only active tasks (tasks with non-zero statistics values) will appear in
the report.
The pidstat command can also be used for monitoring the child processes of selected tasks. Read about option -T below.
The interval parameter specifies the amount of time in seconds between each report. A value of 0 (or no parameters at all) indicates
that tasks statistics are to be reported for the time since system startup (boot). The count parameter can be specified in conjunc-
tion with the interval parameter if this one is not set to zero. The value of count determines the number of reports generated at
interval seconds apart. If the interval parameter is specified without the count parameter, the pidstat command generates reports con-
tinuously.
You can select information about specific task activities using flags. Not specifying any flags selects only CPU activity.
ex)
추가적으로 옵션은 man 페이지를 참고 하길 바라며, 여기서는 cpu, memory, disk IO 를 확인해 보겠다.
- cpu
# ./pidstat -l -p 7330 2
Linux 2.6.18-194.el5 (backup) 06/15/2010 _x86_64_ (2 CPU)
03:43:34 PM PID %usr %system %guest %CPU CPU Command
03:43:36 PM 7330 0.00 0.00 0.00 0.00 0 sshd: root@pts/0
03:43:38 PM 7330 0.00 0.00 0.00 0.00 0 sshd: root@pts/0
03:43:40 PM 7330 0.00 0.00 0.00 0.00 0 sshd: root@pts/0
- memory
# ../bin/pidstat -r -p 7330 2
Linux 2.6.18-194.el5 (backup) 06/15/2010 _x86_64_ (2 CPU)
03:45:56 PM PID minflt/s majflt/s VSZ RSS %MEM Command
03:45:58 PM 7330 0.00 0.00 90108 3368 0.16 sshd
03:46:00 PM 7330 0.00 0.00 90108 3368 0.16 sshd
03:46:02 PM 7330 0.00 0.00 90108 3368 0.16 sshd
- disk IO
# ./pidstat -d -p 7330 2
Linux 2.6.18-194.el5 (backup) 06/15/2010 _x86_64_ (2 CPU)
03:44:26 PM PID kB_rd/s kB_wr/s kB_ccwr/s Command
03:44:28 PM 7330 0.00 0.00 0.00 sshd
03:44:30 PM 7330 0.00 0.00 0.00 sshd
03:44:32 PM 7330 0.00 0.00 0.00 sshd


