What's the fairest way to monitor total CPU time - per user?

Solution 1:

Sounds like you need process accounting.

http://www.faqs.org/docs/Linux-mini/Process-Accounting.html

On Ubuntu, the process accounting tools are in the acct package Install acct

To get a per-user report, run

sa -m

Solution 2:

This will give a line for each user showing the username and their total cpu time:

ps -w -e --no-header -o uid,user \
        | sort -u \
        | while read uid user; do
                echo -e "$user\t"$(
                        ps --no-headers -u $uid --cumulative -o time \
                                | sed -e s/:/*3600+/ -e s/:/*60+/ \
                                | paste -sd+ \
                                | bc
                );
        done

Solution 3:

One of the more obvious answers is to just extend what you're currently doing now.

I came across this monitor process for using bash scripting and mysql to track the cpu time of users but it was spanned across a much larger time frame than you were talking about.

Hopefully this can give you some more ideas about the direction you're looking to head in.

http://www.dba-oracle.com/t_oracle_unix_linux_vmstat_capture.htm