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.

I use nagios to monitor my server. Once in a while I'll get a report that the CPU load is warning / critical, etc. Usually this happens at some odd hour or when I don't have the tools to immediately log in and look around.

Is there some way that I can set up the system to take some top snapshots when the CPU usage is very high - either independently on the system or via nagios?

share|improve this question
add comment

3 Answers 3

Process accounting (package psacct) can also help.

share|improve this answer
    
Read this question: unix.stackexchange.com/questions/25225/… –  andcoz Jan 13 '12 at 16:07
    
@Alien Life Form - +1 but a little more elaboration would be nice –  cwd Jan 13 '12 at 16:27
add comment

You could run ps aux >> logfile every minute with cron. It includes CPU usage.

share|improve this answer
    
That's not bad. But really I only would like to log this when the CPU usage is above a certain threshold. Is there a way to "trigger" it? Or perhaps only store it to a file when it is above a certain point? –  cwd Jan 13 '12 at 15:39
    
Also it would be nice to have a way to order processes by highest CPU usage. –  cwd Jan 13 '12 at 16:11
2  
ps aux |sort -n -k 3 –  Alien Life Form Jan 13 '12 at 16:16
add comment

Take a closer look at snmpd (snmpd.conf). If compiled with the right options you can set trigger actions for a number of things - one of these is CPU-load.

share|improve this answer
    
cool, i like the looks of this. i found the "load average checks" section of the config file - i hope that means it was compiled right on my system. i've been trying to google for instruction on how to "set it up" to give me alerts. what should i be googling for? –  cwd Jan 14 '12 at 17:21
add comment

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.