Last active
January 18, 2017 21:23
-
-
Save skojin/939b7d9f314fbc2df0829256d329e23b to your computer and use it in GitHub Desktop.
aws cloudwatch custom rails metrics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*/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