From Wiki-UX.info

How to analize process usage syscalls
Jump to: navigation, search

How to analize process usage syscalls

This script is useful to analize a tusc syscall output on a live process.

1. Default tusc output (# tusc)

cat /tmp/lp.out | awk -F "(" '{print $1}' | sort | \
awk \
'BEGIN { action = "foo"; count = 0 }
   { if( action == $1 ) count++;
     else {
        printf "%-15s = %4d\n", action, count
        action = $1
        count = 1
     }
    }' | sort -rn -k 3,3 | grep -v foo

2. Detail tusc output (# tusc -fpkaev -b 256 -rall)

cat <tusc_output> | awk -F "(" '/[[]<pid>/ {split($1, syscall, " "); print syscall[2]}' | sort | \
awk \
'BEGIN { action = "foo"; count = 0 }
   { if( action == $1 ) count++;
     else {
        printf "%-15s = %4d\n", action, count
        action = $1
        count = 1
     }
    }' | sort -rn -k 3,3 | grep -v foo

Replace the <tusc_output> and <pid> fields with the tusc output file and process ID respectively.

Example:

cat dsmserv.tusc | awk -F "(" '/[[]3530/ {split($1, syscall, " "); print syscall[2]}' | sort | \
awk \
'BEGIN { action = "foo"; count = 0 }
   { if( action == $1 ) count++;
     else {
        printf "%-15s = %4d\n", action, count
        action = $1
        count = 1
     }
    }' | sort -rn -k 3,3 | grep -v foo
 
sched_yield     =  587
ksleep          =  425
kwakeup         =  391
lseek           =  139
gettimeofday    =  138
write           =   88
readv           =   52
time            =   18
select          =   15
ioctl           =    4
accept          =    3
read            =    1
lwp_wait        =    1
  • Here is a portion of the original tusc output:
# tusc -fpkaev -b 256 -rall -o /tmp/dsmserv.tusc 3530
 
# head -n 24 /tmp/dsmserv.tusc
( Attached to process 3530 ("./dsmserv") [64-bit] )
[3530] ksleep(PTH_CONDVAR_OBJECT, 0x6000000017b17750, 0x600000000066bae8, NULL) ........ [sleeping]
[3530] ksleep(PTH_CONDVAR_OBJECT, 0x6000000001642a00, 0x600000000066de58, NULL) ........ [sleeping]
[3530] ksleep(PTH_CONDVAR_OBJECT, 0x6000000001642dc0, 0x600000001832d868, NULL) ........ [sleeping]
[3530] ksleep(PTH_CONDVAR_OBJECT, 0x6000000001643180, 0x600000000066e328, NULL) ........ [sleeping]
[3530] readv(7, 0x9fffffff7f45cc70, 1) ................................................. [running]
[3530] ksleep(PTH_CONDVAR_OBJECT, 0x6000000001643900, 0x600000000066dec8, NULL) ........ [sleeping]
[3530] ksleep(PTH_CONDVAR_OBJECT, 0x6000000001644d00, 0x6000000017b46f48, NULL) ........ [sleeping]
[3530] select(0, NULL, NULL, NULL, 0x9fffffff7f0fcf10) ................................. [sleeping]
                              nfds: 0
                    timeout.tv_sec: 300
                   timeout.tv_usec: 0
[3530] ksleep(PTH_CONDVAR_OBJECT, 0x60000000017551e0, 0x600000001832d638, NULL) ........ [sleeping]
[3530] ksleep(PTH_CONDVAR_OBJECT, 0x60000000017556e0, 0x6000000017adc048, NULL) ........ [sleeping]
[3530] ksleep(PTH_CONDVAR_OBJECT, 0x600000001799a3a0, 0x6000000017ae1018, NULL) ........ [sleeping]
[3530] ksleep(PTH_CONDVAR_OBJECT, 0x6000000001647c80, 0x600000001832d6a8, NULL) ........ [sleeping]
[3530] ksleep(PTH_CONDVAR_OBJECT, 0x60000000017f6200, 0x600000000066e398, NULL) ........ [sleeping]
[3530] ksleep(PTH_CONDVAR_OBJECT, 0x6000000017a35d60, 0x600000001832d8d8, NULL) ........ [sleeping]
[3530] ksleep(PTH_CONDVAR_OBJECT, 0x6000000017a35ea0, 0x6000000017ae01a8, NULL) ........ [sleeping]
[3530] select(0, NULL, NULL, NULL, 0x9fffffffef330f90) ................................. [sleeping]
                              nfds: 0
                    timeout.tv_sec: 300
                   timeout.tv_usec: 0
[3530] select(0, NULL, NULL, NULL, 0x9fffffffef22cfc0) ................................. [sleeping]

Reference

Author

This page was last modified on 2 November 2009, at 18:22. This page has been accessed 1,621 times.