I have couple of machines as shown below which are running Ubuntu 12.04 and I need to find out the process name along with its pid whose CPU usage is greater than 70%.

Below are the machines as an example -


I need to have my shell script which can run periodically every 15 minutes and check whether any of the above machines has CPU usage greater than 70%. If there are any machines which are having CPU usage as greater than 70%, then send out an email with the machine name and the process name along with it's id.

I will be running my shell script from machineX and I have passwordless ssh key setup for user david from machineX to all the above machines.

What is the best way to do all these kind of monitoring?

I have below command which can get me PID, %CPU and COMMAND name of the process whose CPU usage is greater than 70%.

ps aux --sort=-%cpu | awk 'NR==1{print $2,$3,$11}NR>1{if($3>=70) print $2,$3,$11}'

Not sure how to fully automate this process?

1 Answer 1


You should probably try to use an already existing monitoring solution for this. This is pretty much exactly what they're designed to do, monitor for conditions and send out alerts (SMS or email). You might want to check out nagios or zabbix for a free monitoring solution.

I haven't used it but it looks like Cacti supports alerting on thresholds

collectd can also alert, but I would mainly only use collectd for a historical collection of performance statistics where I didn't need to alert on anything.

Bottom line is that doing this yourself is going to waste your time, effort, and introduce the possibility of error in your monitoring mechanism. It's a common problem with a variety of pre-made solutions.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .