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

5 Answers 5

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
    Commented 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
1
  • what exactly does this show?
    – rubo77
    Commented Feb 1 at 22:27
1
  1. stat the command top
  2. press 1.
  3. Press 0 then
  4. Press "t" twice.

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

-2

htop shows some decent display:

enter image description here

press F6 to choose sort-by-memory-usage

Your Answer

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

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