#!/bin/sh # # g_top15 # # Usage: g_top15 # # By: Angel Corbera, TSID1, Refinery Isla, Curacao, N.A # Comments to: corbera@rocketmail.com # # Purpose: Get the 15 processes that have taken more CPU time. # REL=`uname -r` case $REL in 4.1.1 ) ps -aux > tmp1;; 5.2 ) /usr/ucb/ps -aux > tmp1;; 5.4 ) /usr/ucb/ps -aux > tmp1;; SVr2.2.1 ) ps -ef > tmp1;; esac # # if [ $REL != "SVr2.2.1" ] then # 50/51 station: awk ' $9~/[0-9][0-9]:[0-9][0-9]:[0-9][0-9]/ {printf "%0s\t%0s\t%0s\t%0s\t%0s\n",$2,$3,$4,$10,$11} $9 ~ /[A-Z][a-z][a-z]/ {printf "%0s\t%0s\t%0s\t%0s\t%0s\n",$2,$3,$4,$11,$12} ' tmp1 > tmp2 sort -r -n +3 -4 tmp2 > tmp1 echo "PID\t%CPU\t%MEM\tTTIME\tPROCESS" > tmp2 head -15 tmp1 >> tmp2 else # 20 station: awk ' $5~/[0-9][0-9]:[0-9][0-9]:[0-9][0-9]/ {printf "%0s\t%0s\t%0s\n",$2,$7,$8} $5 ~ /[A-Z][a-z][a-z]/ {printf "%0s\t%0s\t%0s\n",$2,$8,$9} ' tmp1 > tmp2 sort -r -n +1 -2 tmp2 > tmp1 echo "PID\tTTIME\tPROCESS" > tmp2 head -15 tmp1 >> tmp2 fi more tmp2 rm tmp1 tmp2 > /dev/null 2>&1