From Wiki-UX.info

How to create running process reports
Jump to: navigation, search

How to create running process reports

The following scripts allows to use "ps" command to create process reports that can help to pinpoint performance issues.

Get list of processes by allocated sizes

export UNIX95=
 
ps -eo pid,sz,comm | grep -v PID | sort -rnk 2,2 \
| awk 'BEGIN {PAGE=4; TSZ=0; TVSZ=0; print "PID        SZ (KB) COMMAND";}
{
   printf "%-5d\t%10u %-25s\n", $1, $2 * PAGE, $3
   TSZ=TSZ + $2 * PAGE
}
END {printf "TOTAL\t%10u MB\n", TSZ / 1024}'

Example:

PID        SZ (KB) COMMAND
1750         56208 scopeux
27666        11928 cimservermain
1921         11188 coda
1768          8776 midaemon
580           6896 evmlogger
27667         5908 cimprovagt
27942         4788 WbemWrapperMonitor
1789          4668 perfalarm
1823          4288 ovbbccb
27673         4188 postgres:
1805          3744 ovcd
1434          2972 postgres:
1435          2908 postgres:
1431          2844 postmaster
435           2388 snmpdm
1400          2156 sendmail:
561           1968 evmd
29343         1960 swagentd
1529          1532 rpcd
1680          1516 diagmond
1916          1512 rpc.mountd
10504         1492 sshd:
28039         1424 lpmc_em
10982         1364 sshd:
10448         1364 sshd:
2020          1332 kcmond
1068          1308 rpc.statd
2006          1300 utild
1099          1092 nfsmapid
1             1048 init
472           1028 mib2agt
396           1024 sshd
1113          1020 automountd
522            916 utmpd
187            896 fsdaemon
460            792 ipv6agt
996            780 rpcbind
11162          688 -sh
10986          688 -sh
10509          688 -sh
10451          688 -sh
1997           688 -sh
1775           688 -sh
10100          624 -sh
10015          624 -sh
653            624 -sh
1975           604 sh
1923           572 nfsd
1628           556 cmwbemd
448            528 hp_unixagt
1963           524 ovtrcd
490            520 trapdestagt
2084           516 memlogd
1122           476 inetd
10887          464 sh
1809           464 sh
1093           440 nfs4cbd
1074           440 rpc.lockd
27514          428 psmctd
27530          408 disk_em
11645          396 ps
27740          364 dm_core_hw
27518          364 registrar
2083           344 diaglogd
11648          332 awk
1495           332 cmsnmpd
1740           328 ttd
28111          324 sysstat_em
27815          308 dm_memory
27846          292 dm_ql_adapter
10098          280 telnetd
10014          280 telnetd
1774           280 telnetd
652            280 telnetd
15102          276 bootpd
1842           252 emsagent
1653           244 pwgrd
27665          228 cimserver
10889          228 more
1811           228 more
1810           228 zcat
581            228 evmchmgr
11161          216 telnetd
853            212 netfmt
10888          208 zcat
8800           204 lpsched
2005           196 p_client
809            196 syslogd
1443           168 cmproxyd
12234          164 cimserverd
11647          156 sort
1994           156 dtlogin
2000           152 esmd
1998           152 krsd
1999           128 sfd
518            128 syncer
1664           124 cron
11646          108 grep
10886           96 man
1808            96 man
1683            88 envd
828             84 hotplugd
814             72 ptydaemon
10647           60 smhstartd
842             56 nktl_daemon
852             40 ntl_reader
133              0 lvmattachd
132              0 lvmdevd
116              0 rng
77               0 pagezerod
76               0 nfs4srvkd
75               0 nfslogkd
74               0 kend
73               0 str_mblk_flush_daemon
72               0 smpsched
71               0 sblksched
70               0 sblksched
69               0 pm_schedcpu
68               0 eventdaemon
67               0 vxfsd
60               0 ipmid
59               0 evacd
58               0 fb_daemon
57               0 fcachedaemon
56               0 dcda_daemon
55               0 progressdaemon
54               0 awd
53               0 shutdowndaemon
52               0 pagetableinit_daemon
51               0 swapdaemon
50               0 lvmattachd
49               0 lvmdevd
48               0 OlstarMdep
47               0 strfreebd
46               0 strweld
45               0 strmem
44               0 smpsched
43               0 inet_areset_daemon
42               0 afinet_strout
41               0 lvmp_wk_th_d
40               0 lvmp_schedd
39               0 lvmp_kd
38               0 lvmp_kd
37               0 lvmp_kd
36               0 lvmp_kd
35               0 lvmp_kd
34               0 lvmp_kd
33               0 cachefskd
32               0 autofskd
31               0 nfs4_async_io
30               0 nfs4clntkd
29               0 nfs_failover
28               0 nfs_async_io
27               0 krpckd
26               0 nfs_reclaim
25               0 sendfile_vn_rele_daemon
24               0 side_daemon
23               0 memfsd
22               0 usbmsd
21               0 lvmschedd
20               0 lvmkd
19               0 lvmkd
18               0 lvmkd
17               0 lvmkd
16               0 lvmkd
15               0 lvmkd
14               0 kevm
13               0 net_str_cached
12               0 net_str_cached
11               0 usbhubd
10               0 escsid
9                0 ttisr
8                0 ksyncer_daemon
7                0 ioconfigd
6                0 kmemdaemon
5                0 signald
4                0 unhashdaemon
3                0 statdaemon
2                0 vhand
0                0 swapper
TOTAL          180 MB

Get list of processes to compare SZ against VSZ

export UNIX95=
 
ps -eo pid,sz,vsz,comm | grep -v PID | sort -rnk 2,2 \
| awk 'BEGIN {PAGE=4; TSZ=0; TVSZ=0; print "PID        SZ (KB)         VSZ (KB) COMMAND";}
{
   printf "%-5d\t%10u\t%10u %-25s\n", $1, $2 * PAGE, $3 * PAGE, $4
   TSZ=TSZ + $2 * PAGE
   TVSZ=TVSZ + $3 * PAGE
}
END {printf "TOTALS\t%10u MB\t%10u MB\n", TSZ / 1024, TVSZ / 1024}'

Example:

PID        SZ (KB)         VSZ (KB) COMMAND
1750         56208          226544 scopeux
27666        11928           53664 cimservermain
1921         11188           61616 coda
1768          8776           35104 midaemon
580           6896           27600 evmlogger
27667         5908           23648 cimprovagt
27942         4788           19536 WbemWrapperMonitor
1789          4668           19824 perfalarm
1823          4288           21600 ovbbccb
27673         4188           19072 postgres:
1805          3744           21168 ovcd
1434          2972           16000 postgres:
1435          2908           12416 postgres:
1431          2844           12160 postmaster
435           2388            9648 snmpdm
1400          2156           17328 sendmail:
561           1968            8128 evmd
29343         1960            7920 swagentd
1529          1532            6912 rpcd
1680          1516            6112 diagmond
1916          1512            6128 rpc.mountd
10504         1492            5968 sshd:
28039         1424           37360 lpmc_em
10982         1364            5456 sshd:
10448         1364            5456 sshd:
2020          1332            5376 kcmond
1068          1308            5504 rpc.statd
2006          1300            5744 utild
1099          1092            4544 nfsmapid
1             1048            4192 init
472           1028            4208 mib2agt
396           1024            4112 sshd
1113          1020            4384 automountd
522            916            3872 utmpd
187            896            3728 fsdaemon
460            792            3328 ipv6agt
996            780            4800 rpcbind
11162          688            2896 -sh
10986          688            2896 -sh
10509          688            2896 -sh
10451          688            2896 -sh
1997           688            2896 -sh
1775           688            2896 -sh
10100          624            2640 -sh
10015          624            2640 -sh
653            624            2640 -sh
1975           604            2576 sh
1923           572            2304 nfsd
1628           556            2880 cmwbemd
448            528            2176 hp_unixagt
1963           524            3584 ovtrcd
490            520            2096 trapdestagt
2084           516            2080 memlogd
1122           476            1904 inetd
10887          464            2032 sh
1809           464            2032 sh
1093           440            1776 nfs4cbd
1074           440            1776 rpc.lockd
27514          428            1888 psmctd
27530          408            1872 disk_em
11621          396            2432 ps
27740          364            1712 dm_core_hw
27518          364            1520 registrar
2083           344            4032 diaglogd
11624          332            1616 awk
1495           332            1344 cmsnmpd
1740           328            3136 ttd
28111          324            1536 sysstat_em
27815          308            1520 dm_memory
27846          292            1504 dm_ql_adapter
10098          280            1152 telnetd
10014          280            1152 telnetd
1774           280            1152 telnetd
652            280            1152 telnetd
15102          276            1344 bootpd
1842           252            1072 emsagent
1653           244            1040 pwgrd
27665          228             912 cimserver
10889          228             992 more
1811           228             992 more
1810           228            2144 zcat
581            228             960 evmchmgr
11161          216             896 telnetd
853            212             928 netfmt
10888          208            2144 zcat
8800           204            1008 lpsched
2005           196             832 p_client
809            196             864 syslogd
11623          172            1168 sort
1443           168            1760 cmproxyd
12234          164             672 cimserverd
1994           156            1168 dtlogin
2000           152             704 esmd
1998           152            1344 krsd
1999           128            1888 sfd
518            128             672 syncer
1664           124             512 cron
11622          108             576 grep
10886           96             480 man
1808            96             480 man
1683            88             560 envd
828             84            1296 hotplugd
814             72             464 ptydaemon
10647           60             320 smhstartd
842             56             368 nktl_daemon
852             40             368 ntl_reader
133              0               0 lvmattachd
132              0               0 lvmdevd
116              0               0 rng
77               0               0 pagezerod
76               0               0 nfs4srvkd
75               0               0 nfslogkd
74               0               0 kend
73               0               0 str_mblk_flush_daemon
72               0               0 smpsched
71               0               0 sblksched
70               0               0 sblksched
69               0               0 pm_schedcpu
68               0               0 eventdaemon
67               0               0 vxfsd
60               0               0 ipmid
59               0               0 evacd
58               0               0 fb_daemon
57               0               0 fcachedaemon
56               0               0 dcda_daemon
55               0               0 progressdaemon
54               0               0 awd
53               0               0 shutdowndaemon
52               0               0 pagetableinit_daemon
51               0               0 swapdaemon
50               0               0 lvmattachd
49               0               0 lvmdevd
48               0               0 OlstarMdep
47               0               0 strfreebd
46               0               0 strweld
45               0               0 strmem
44               0               0 smpsched
43               0               0 inet_areset_daemon
42               0               0 afinet_strout
41               0               0 lvmp_wk_th_d
40               0               0 lvmp_schedd
39               0               0 lvmp_kd
38               0               0 lvmp_kd
37               0               0 lvmp_kd
36               0               0 lvmp_kd
35               0               0 lvmp_kd
34               0               0 lvmp_kd
33               0               0 cachefskd
32               0               0 autofskd
31               0               0 nfs4_async_io
30               0               0 nfs4clntkd
29               0               0 nfs_failover
28               0               0 nfs_async_io
27               0               0 krpckd
26               0               0 nfs_reclaim
25               0               0 sendfile_vn_rele_daemon
24               0               0 side_daemon
23               0               0 memfsd
22               0               0 usbmsd
21               0               0 lvmschedd
20               0               0 lvmkd
19               0               0 lvmkd
18               0               0 lvmkd
17               0               0 lvmkd
16               0               0 lvmkd
15               0               0 lvmkd
14               0               0 kevm
13               0               0 net_str_cached
12               0               0 net_str_cached
11               0               0 usbhubd
10               0               0 escsid
9                0               0 ttisr
8                0               0 ksyncer_daemon
7                0               0 ioconfigd
6                0               0 kmemdaemon
5                0               0 signald
4                0               0 unhashdaemon
3                0               0 statdaemon
2                0               0 vhand
0                0               0 swapper
TOTALS         180 MB          832 MB

Per File System CPU and Memory Usage

This example shows how to find the CPU Usage and process size of every process that have opened files under /var/tmp file system. Change the export FS= statement to the file system you need to analize.

export FS=/tmp
 
> /tmp/procs.out; top -n $(ps -e | wc -l) -f /tmp/procs.out
 
awk '{if ($1 == "TTY") print $0}' /tmp/procs.out; for fspid in $(fuser $FS 2> /dev/null)
do
awk -v PID=$fspid '{if ($2 == PID) print $0}' /tmp/procs.out
done | sort -n -k 2,2

Example:

# /procs.out; for fspid in $(fuser $FS 2> /dev/null)                         <
> do
> awk -v PID=$fspid '{if ($2 == PID) print $0}' /tmp/procs.out
> done | sort -n -k 2,2
 TTY     PID USERNAME PRI NI   SIZE    RES STATE    TIME %WCPU  %CPU COMMAND
  ?     1673 root     154 20  5572K   496K sleep    0:00  0.00  0.00 hp_unixagt
  ?     1689 root     154 20  6412K   704K sleep    0:00  0.02  0.02 mib2agt
  ?     1705 root     154 20  5464K   484K sleep    0:00  0.00  0.00 trapdestagt
This page was last modified on 17 March 2010, at 14:42. This page has been accessed 2,621 times.