Skip to content

Instantly share code, notes, and snippets.

@skojin
Last active January 18, 2017 21:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skojin/939b7d9f314fbc2df0829256d329e23b to your computer and use it in GitHub Desktop.
Save skojin/939b7d9f314fbc2df0829256d329e23b to your computer and use it in GitHub Desktop.
aws cloudwatch custom rails metrics
*/5 * * * * aws cloudwatch put-metric-data --metric-name MyPassengerCount --namespace "System/Linux" --dimensions "InstanceId=$(ec2metadata --instance-id)" --unit Count --value $(ps ax | grep "[P]assenger RackApp" | wc -l)
*/5 * * * * aws cloudwatch put-metric-data --metric-name MyDJWorkersCount --namespace "System/Linux" --dimensions "InstanceId=$(ec2metadata --instance-id)" --unit Count --value $(ps ax | grep "[d]elayed_job" | wc -l)
*/5 * * * * aws cloudwatch put-metric-data --metric-name MyCometServerCount --namespace "System/Linux" --dimensions "InstanceId=$(ec2metadata --instance-id)" --unit Count --value $(ps ax | grep "[b]randrep_comet_server" | wc -l)
# N of Passenger processed that older then 1 hour
*/30 * * * * aws cloudwatch put-metric-data --metric-name MyOldPassengerCount --namespace "System/Linux" --dimensions "InstanceId=$(ec2metadata --instance-id)" --unit Count --value $(ps axo etimes,args | grep "RackApp" | awk '{if ($1 >= (1 * 3600)) print $0}' | wc -l)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment