Customizing ps command

Hi,
I want to monitor our batch jobs at a specific interval for later analysis to see the performance and CPU utilization

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
 ps aux|grep dsadm|head
xxxxx   386  0.0  0.0 103524 15448 pts/0    S    Mar27   0:00 /etrade/home/dsadm/sqllib/bin/db2bp 28075A14861 5 A
dsadm     1339  0.0  0.0  24780  1696 ?        Ss   Mar13   0:00 dscs 4 0 0
dsadm     1351  0.0  0.0 158212 37128 ?        Ss   Mar13   0:00 dsapi_slave 7 6 0
xxxxxx  1911  0.0  0.0 103780 15800 pts/5    S    13:04   0:00 /etrade/home/dsadm/sqllib/bin/db2bp 24828A14861 5 A
dsadm     2721  0.0  0.0  24804  1752 ?        Ss   Mar19   0:00 dscs 4 0 0
dsadm     2722  0.0  0.0 158548 38036 ?        Ss   Mar19   0:02 dsapi_slave 7 6 0
dsadm     7298  0.0  0.0  11848  3520 ?        S    Mar23   0:08 /bin/ksh /etrade/prd/dsadm/batch/uscrm/prod/run//DCM/dcm_canary.ksh -project_code DCM -exec_mode PROD -run_date 20140316 -process_name DW_DCM_LOAD -hbinterval 5 -jobname DWDCM01LD
dsadm     7332  0.0  0.0  10924  2556 ?        S    Mar23   0:02 /bin/ksh /etrade/prd/dsadm/batch/uscrm/prod/run/DCM/dcm_load.ksh -project_code DCM -exec_mode PROD -run_date 20140316 -process_name DW_DCM_LOAD -hbinterval 5 -jobname DWDCM01LD
dsadm    10724  0.0  0.0  24780  1688 ?        Ss   Mar13   0:00 dscs 4 0 0
dsadm    10725  0.0  0.0 158924 38284 ?        Ss   Mar13   0:25 dsapi_slave 7 6 0

From which i can later identify the CPU and memory utilization etc.
But couldnt figure out a way to print the parent id in this output

ps -eo command,user,pid,ppid

i have this command to get the parent id also. but here i cant display the any of the performance parameter's. Is there a way to print both PID hierarchy and various performance factors for each process

What is your OS and version?

 uname -a
Linux XXXXXXXXX 2.6.18-308.4.1.el5 #1 SMP Wed Mar 28 01:54:56 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux
ps -eo cmd,user,pid,ppid,pcpu,pmem,vsz,rss,start,stat
1 Like

Try:

ps axo user,pid,ppid,pcpu,%mem,vsz,rss,tt,stat,start,time,command
1 Like

Thanks a ton
Thats what i was looking for..
Just needed a small modification to display the entire command

ps -eo cmd:200,user,pid,ppid,pcpu,pmem,vsz,rss,start,stat
2 Likes

Can i Give a separator between the fields in ps command itself

 ps -eo user,pid,ppid,pcpu,pmem,vsz,rss,start,stat,cmd|grep DW_DCM|head
rjanardh  3866  7777  0.0  0.0   6068   604 16:47:17 S+   grep DW_DCM
dsadm    28644 27590  0.0  0.0  10700  2356 21:00:06 S    /bin/ksh /etrade/prd/dsadm/batch/uscrm/prod/run//DCM/dcm_canary.ksh -project_code DCM -exec_mode PROD -run_date 20140330 -process_name DW_DCM_LOAD -hbinterval 5 -jobname DWDCM01LD
dsadm    28667 28644  0.0  0.0  10668  2172 21:00:06 S    /bin/ksh /etrade/prd/dsadm/batch/uscrm/prod/run/DCM/dcm_load.ksh -project_code DCM -exec_mode PROD -run_date 20140330 -process_name DW_DCM_LOAD -hbinterval 5 -jobname DWDCM01LD

I tried using awk command but if the 'command field' has space then output is weird.