Output the top results to a log file

I’m having some issues with a server that goes down in a couple of weeks. All I see from the error logs is the Apache OOM errors. The logs don’t really show what process is causing the system to run out of memory – but here’s what I thought. I have a nagios server monitoring the system. Nagios does send out alerts when the system has high CPU utilization. As next steps – I am planning to have an Event Handler to Nagios that will execute the top command in the event of High CPU Utilization and store the results in a log file.

top -n 1 -b > top.log
#-n represents the number of consecutive results to be printed
#-b denotes that the output is a batch operation

And if you’re looking for information on the Nagios Event Handling functionality, refer to this URL: http://nagios.sourceforge.net/docs/3_0/eventhandlers.html

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s