Your Ad Here

IBM AIX/UNIX system storage administration ksh/perl scripting

Monday, March 09, 2009

Script to list process in current runq in AIX

The script also exclude the process created by the script itself.


#!/bin/ksh
myPID=$$
echo
echo "CMD PID Uptime CPU_time THCNT in_RunQ" | awk ' { printf ("%-10s %-10s %-15s %-10s %-10s %s",$1,$2,$3,$4,$5,$6"\n") }'
echo "--------------------------------------------------------------------"
ps -emo pid,tid,comm,etime,time,thcount,ppid,state | awk '$1 != "-" && $7 != MYPID { if (NB_THREAD != 0 ) { print PID"\t"NB_THREAD } ; PID=$3"\t"$1"\t"$4"\t"$5"\t"$6 ; NB_THREAD=0 } ; $NF=="R" { NB_THREAD=NB_THREAD + 1 }' MYPID="$myPID" | awk ' { printf ("%-10s %-10s %-15s %-10s %-10s %s",$1,$2,$3,$4,$5,$6"\n") }'
echo

1 comment:

Unknown said...

Thanks for sharing this information. You may also refer http://www.s4techno.com/aix-administration-training-online/ for more details.

Labels

Blog Archive

BlogCatalog