3

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?

cwd
  • 45,389

3 Answers3

2

Process accounting (package psacct) can also help.

  • Read this question: http://unix.stackexchange.com/questions/25225/is-there-a-log-of-past-threads-that-are-now-closed – 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
1

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

nopcorn
  • 9,559
Alexander
  • 9,850
  • 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
1

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.

Nils
  • 18,492
  • 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