7

Here's a solution which may consume a lot of cpu usage (stolen from this article):

There's a difference in my Ubuntu 12 ec2 server, I have to use top -bn1 instead of top -ln.

Here's my related .tmux.conf file:

set -g status-right '#[fg=yellow]#[(getCpuUsage.sh)]'

It actually calls top every 2 seconds and outputs a whole lot of information. I think there should be a way involving less cpu consumption or use some flag to limit the output of top to only cpu usage.

0

4 Answers 4

11

I use the small tmux-mem-cpu-load C++ program. It's at least one fork/exec per update either way, but probably better than invoking a shell.

1
  • Yes I try this,but it only give me memory usage
    – mko
    Jul 19, 2012 at 10:48
7

If I knew tmux-mem-cpu-load, I would become too lazy to write my own rainbarf:

rainbarf

It has a fancier look, but it is a Perl script so it is not a good idea to run it every 2 seconds (on my experience, 15 seconds suffice).

0
1

You can try vmstat(1). It displays the averaged CPU load over all CPUs: user, system, idle and IO wait in the last four fields:

vmstat|while read s;do [[ "$s" =~ ([[:space:]]+[0-9]+){4}$ ]]&&echo $BASH_REMATCH; done
0
  1. stat top command.
  2. press 1.
  3. Press 0 then
  4. Press "t" twice.

It will display bar graph of the CPU usage. You can change the color by +z. Then color number in the list.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.