Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Once in a while some program (ok, usually it's firefox) will start eating up nearly 100% of a processor's cpu time, heating up the processor and driving down by laptop's battery life. Since it's not bad enough to impact performance, I usually don't notice for a while, so I'd like to change this:

Is there a utility that monitors process cpu usage and popus up an alert if some process is using a lot of cpu time for an extended period of time (e.g., more than 30 seconds)? I can probably rig something up with ps or top, sed and a bunch of pipes, but I'm hoping there's a more direct way to do it.

Edit: On second thought, what I'm really after is power usage. So any instrumentation specifically targeted at estimating power consumption is of particular interest.

I'm on OS X 10.8, but welcome Linux-specific solutions as well.

share|improve this question
    
There is cpulimit on Debian based OSes. Check out CPU Usage Limiter for Linux & cpulimit on github –  SparKot ॐ Mar 21 at 14:27
1  
Interesting, thanks. It would be useful in cases where a single process must be slowed down, but less so for monitoring the system. –  alexis Mar 21 at 14:34
    
oh, I thought you wanted to pin the cause; I remember using Monit utility on production servers. Monit Utility –  SparKot ॐ Mar 21 at 14:37

1 Answer 1

Rolling your own with Zenity

I'm not aware of any out of the box tool that will do this for you. I'd write a script to watch for the situation and then use something like zenity to pop a dialog up when the situation arises.

$ zenity --info --text="This is an information box."

                                              ss of zenity dialog

It's pretty easy to get started with it and it's extremely easy to embed these dialogs into crons and scripts if need be.

Conky

I personally use conky to keep an eye on things that are going on, on my system. It's highly configurable and can be coupled to your background so that it's always easily accessible.

                                     conky

Putting them together?

As a novel solution to your problem you could setup conky to watch for a particular situation, such as a process consuming all of your CPU resources, and then popping a dialog alerting you to the problem. I found this solution which shows a warning dialog being displayed when the battery got below a certain threshold. This solution was in a post titled: Low Battery Warning Using conky.

   BATTERY: ${color}${battery BAT0}
    ${if_match ${battery_percent BAT0} <= 10}
    ${if_match "${acpiacadapter}" == "off-line"}
    ${exec zenity --warning --text "Low Battery"}
    ${endif}
    ${endif}
share|improve this answer
    
Thanks for both tips. Does Conky warn you when something starts hogging the cpu? –  alexis Mar 21 at 15:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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