1

So everytime I leave my ubuntu desktop alone, it seems that after a while it starts "working on stuff" -- CPU lights lighting, that busy CPU processing sound being pretty loud, etc. But when I move my mouse, it just goes away.

I don't think it's spyware just yet, but, (puts on tinfoil hat) is there any way to figure out what kind of processes were running that were taking the most CPU time, and log them historically?

I'm thinking of writing a daemon for monitoring this, actually, but if there's already an existing tool for this, that would be better I guess?

kamziro
  • 179
  • Running top in a terminal (or htop, sudo apt-get install htop` to install) would be a simple solution for realtime monitoring, there are also a number of indicator applets that will do this on the top panel (see here and here). As for your question about logging the info historically, I don't have any immediate ideas--but this is the interesting part of your question and I might suggest making this part of your question more prominent (so your post doesn't get marked as a duplicate). – adempewolff Jun 03 '12 at 02:59
  • What is the "CPU light" and the "busy CPU sound"? If the former is the blue/green/red light on your case/laptop that flickers, it's NOT the CPU but indicates hard disk activity. – ish Jun 03 '12 at 04:55

1 Answers1

3

is there any way to figure out what kind of processes were running that were taking the most CPU time, and log them historically?

Set up a cronjob, running every minute and appending date and ps auxk time | tail -N to your chosen log file. Set N to how many CPU hogs you want logged. Default (without -N) is 10. The total time (in minutes) as of a particular timestamp is the second-last column, in descending order, just before the process name:

izx       2096  0.0  0.6 396920  7000 ?        Ssl  16:41   0:11 gnome-session --session=ubuntu
izx       2147  0.0  1.1 681920 11404 ?        Sl   16:41   0:16 /usr/lib/gnome-settings-daemon/gnome-settings-daemon
izx       2275  0.0  0.8 421544  8684 ?        Sl   16:41   0:16 /usr/lib/bamf/bamfdaemon
izx       2311  0.0  2.8 614148 29388 ?        Sl   16:41   0:16 /usr/lib/unity/unity-panel-service
root      1736  0.1  0.2  87632  2576 ?        S    16:41   0:24 /usr/sbin/vmtoolsd
izx       2205  0.1  0.9 446056  9208 ?        Sl   16:41   0:30 /usr/lib/vmware-tools/sbin64/vmtoolsd -n vmusr --blockFd 3
izx       2451  0.3  2.3 551928 24348 ?        Sl   16:41   1:10 gnome-terminal
izx       2163  0.9  6.5 1157128 66616 ?       Sl   16:41   3:39 compiz
root      1058  1.5 15.3 320408 156080 tty7    Ss+  16:41   5:53 /usr/bin/X :0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch -background none
izx       2541  2.0 16.1 944464 164536 ?       Sl   16:41   8:03 /usr/lib/firefox/firefox

You may want to look at man ps to clean up the fields you don't need.

ish
  • 139,926