1

Basically I need to make a bash script that acts as a handy tool for diagnosing performance issues. The script needs to first determine each unique process owner on the system, and then for each user that has current processes on the system it needs to:

  • Determine the number of processes owned by that user
  • Determine the sum of memory for all processes owned by that user (SZ)
  • Determine the sum of the current CPU usage for all processes owned by that user (C)
  • Determine the cumulative time (TIME) and process name (CMD) of the process with the highest cumulative time owned by that user (Hog: process)

I guess the first step would be to determine all of the unique process owners on the system, and then loop through each?

0

1 Answer 1

0

If you want to have a quick look at processes, use top and read the man page to learn how to sort by various columns

To find (most of) the information you want:

ps ax -o user,sz,pcpu | 
awk '
    NR>1 {n[$1]++; sz[$1]+=$2; cpu[$1]+=$3}
    END {
        for (user in n) 
            printf "%-8s  %4d  %12d  %.1f\n", user, n[user], sz[user], cpu[user]
    }
'
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .