Friday, January 17, 2014

Bash script to check for AWS CloudWatch alerts that are alarming

Today's simple Bash script is for getting a list of your AWS CloudWatch alerts that are currently in an alarm state.

Here's an overview of the script and what it does (And as always, the most up-to-date version of the script will be in my Github repo):



#!/bin/bash
alarm="$(aws cloudwatch describe-alarms --state-value "ALARM" | grep "AlarmName")"
echo -e "Current alarms: \n" $alarm



When it's run, it will look like this:



[ec2-user@test ~]$ ./cloudwatch-alarm-check.sh
Current alarms:
"AlarmName": "AWS_cpu-usage-over-75-percent_for_instance-named_test",
[ec2-user@test ~]$