You might want to use cron and the CloudWatch API to manually enter numbers in CloudWatch as part of an autoscaling policy. By numbers, I mean the number of processes from each instance of ps aux | grep your_process | wc -l ps aux | grep your_process | wc -l
CloudWatch allows you to set an alarm for this manual metric, aggregated by SUM from nr processes through all running instances or using auto-scaling group.
Something to get you started:
Manually pushing RAM memory metrics: http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/mon-scripts-perl.html
Another one: http://aws.typepad.com/aws/2011/05/amazon-cloudwatch-user-defined-metrics.html
For memory, this looks simple, as amazon already provides scripts for this. For processes, you may need to dig into these scripts or read official API docs
EDIT:
If you are now worried about a single point of failure in the surveillance system, and you have a list of servers, it might be preferable to examine them in parallel from a remote server:
rm ~/count.log # SSH in parallel for ROW in `cat ~/ListofIP.txt` do IP=`echo ${ROW} | sed 's/\./ /g' | awk '{print $1}'` ssh -i /path/to/keyfile root@ ${IP} "ps -ef | grep process_name.rb | grep -v grep | wc -l" >> ~/count.log & done # Wait for totals while [ ! `wc -l ~/ListofIP.txt` -eq `wc -l ~/count.log` ] do wait 1 done # Sum up numbers from ~/count.log # Push TO CloudWatch
source share