-
-
Save noahehall/381a613b0fbdc607a17d08cb3cda1856 to your computer and use it in GitHub Desktop.
AWS
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
#!/bin/bash | |
SERVICENAME="NAME-OF-NODE" | |
INSTANCEID=$(wget -q -O - http://169.254.169.254/latest/meta-data/instance-id) | |
AWS=/usr/bin/aws | |
REGION=$(wget -q -O - http://169.254.169.254/latest/dynamic/instance-identity/document | grep region | awk -F '"' '{print $4}') | |
DOMAIN=$(/usr/bin/aws ec2 describe-instances --region $REGION --instance-id $INSTANCEID --query 'Reservations[*].Instances[*].Tags[*]' --output=t | |
ext | grep Name | awk -F ":" '{print $1}' | awk '{print $2}') | |
SNSARN=arn:aws:sns:${REGION}:948962939411:BPPM_Connector | |
METRICNAME=$1 | |
PERIOD=$2 | |
UNIT=$3 | |
METRICTHRESHOLD=$4 | |
COMPARISONOPERATOR=$5 | |
$AWS cloudwatch put-metric-alarm --region=$REGION --alarm-name "$SERVICENAME|$INSTANCEID|$METRICNAME" --alarm-description "$DOMAIN CLI $METRICNAM | |
E" --actions-enabled --ok-actions $SNSARN --alarm-actions $SNSARN --insufficient-data-actions $SNSARN --metric-name $METRICNAME --namespace "AWS/ | |
EC2" --statistic Average --dimensions "Name=InstanceId,Value=$INSTANCEID" --period $PERIOD --unit $UNIT --evaluation-periods 1 --threshold $METRI | |
CTHRESHOLD --comparison-operator $COMPARISONOPERATOR | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment