LILUG BASH Programming Contest 4/2002

System with one hundred unruly users...

Some users have been bringing a common server to it's knees. There are many possible evildoers. You need to get to bottom of it. Find out what and who has been pegging CPU time. This way you'll never be in the dark about system resources again. (until the next thing.)

Required for all winners, baseline required for speed win.

Create a script that will run as a background process monitoring CPU activity, and log key activity whenever the CPU is busy. An argument should be passed to the script for the percentage of overall CPU time that that will be considered "busy" . The argument should be above an an integer from 0 to 99. This background process should write data to a log file every five minutes for the duration of busy periods. The name of the log file should also be passed as an argument to the script. The log file should write the top ten biggest CPU hogs by program-name, process ID, and username. Don't forget to date and time stamp each snapshot for maximum readability.

It will need to do this in a automated manner. Please, the spirit is more important than the exact wording for the elegance award. If you are in third place but only your script actually works, you are in first. A flexible CPU process logging script is what we are after.

Suggested enhancments for elegance/maximum usefulness award. Bored? Want to keep going?