Prstat substitute

Hello All,
I have a shell script where with the lines below:

echo "${v_sd_dateTime},${RUN_QUEUE_SIZE},${LOAD_AVERAGE},${v_sd_load_list},${v_sd_thread_count_list}" >> ${v_sd_file}

Format of the output :

   01/05/2005 08:00:00, RUN_QUEUE_SIZE, LOAD_AVG, CPU_PROD1, CPU_PROD2, THREADS_PROD1, THREADS_PR

Sample of the output :

01/07/2012 1:00	0	0.5	0.00%	0.50%	0.00%	74	29	69	

prstat is used for the variables : ${v_sd_load_list} , ${v_sd_thread_count_list}

The scripts is as below:

v_gap_prstat_line=`prstat -p ${v_gpsd_pid} 5 1 | grep -vi TOTAL | grep -v CPU`

CPU_LOAD_INSTANCE=` echo ${v_gap_prstat_line} | awk '{ print $9 }'`
THREAD_COUNT_INSTANCE=`echo ${v_gap_prstat_line} | awk '{ print $10 }' | cut -d/ -f2`
    
CPU_LOAD_INSTANCE_LIST="${CPU_LOAD_INSTANCE_LIST} ${CPU_LOAD_INSTANCE}"
THREAD_COUNT_INSTANCE_LIST="${THREAD_COUNT_INSTANCE_LIST} ${THREAD_COUNT_INSTANCE}"
	
v_sd_load_list=`echo ${CPU_LOAD_INSTANCE_LIST} | sed -e 's/^  *//' -e 's/  */,/g'`
v_sd_thread_count_list=`echo ${THREAD_COUNT_INSTANCE_LIST} | sed -e 's/^  *//' -e 's/  */,/g'`

**********************

I understand that prstat takes the option p where it takes only the process id
5 being the number of times the statistics are repeated
1 being the interval in seconds

I have to migrate this in linux. I tried the command with

top -p 13213 -d 2 -n 1

But i dont get this output.
Could someone help.:frowning:

Apples vs. oranges with regards to NLWP counts... but let's see what is possible.... I have no idea if your logic will be sound... the systems are quite different.

replace:

v_gap_prstat_line=`prstat -p ${v_gpsd_pid} 5 1 | grep -vi TOTAL | grep -v CPU`

with:

v_gap_prstat_line=`top -b -n 1 -p ${v_gpsd_pid}  | tail -n 1`

For the NWLP number... well, perhaps if you get a thread list... so things change a bit.

change:

THREAD_COUNT_INSTANCE=`echo ${v_gap_prstat_line} | awk '{ print $10 }' | cut -d/ -f2`

try instead:

THREAD_COUNT_INSTANCE=`top -b -n 1 -H -p ${v_gpsd_pid}  | grep '^[ ]*[0-9]' | wc -l`

No warranties

---------- Post updated at 04:53 PM ---------- Previous update was at 04:51 PM ----------

Oh... and I just did -n 1... feel free to adjust... might need more work, but certainly on the right path (I think)

1 Like