I need a linux script to control a runaway process...

Do you know if this is possible, and how hard it would be to write?

I need a script that does the following for linux:

1. Checks for the existence of a specified process.
2. If the process is found, has it been running for longer than 5 minutes at greater than 25% CPU usage?
3. If so, then kill the process, write the event to a log file, and optionally send an email to admin.

The script should accept input switches. For example:

scriptname -p process_name -s 300 -u 25 -e admin@domain.com

-p is the process name to monitor
-s is the number of seconds the process must have been running before action is taken
-u is the % of CPU that the process must be using before action is taken
-e is the email address to receive event notification. Only send email if this switch is specified.

The script should be executable via cron.

Thanks!

 

 

 

 

Top