Skip to content

Instantly share code, notes, and snippets.

@yuvalo
Created November 20, 2012 14:33
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 yuvalo/4118268 to your computer and use it in GitHub Desktop.
Save yuvalo/4118268 to your computer and use it in GitHub Desktop.
Sets off a notification when you forget too many EC2 instances running.
import boto
import commands
# running instances threshold
limit = 4
conn = boto.connect_ec2('KEY','SECRET_KEY')
instances = conn.get_all_instance_status()
if (len(instances) > limit):
commands.getstatusoutput('terminal-notifier -message "Too many running instances: '+str(len(instances))+'" -title "Ec2 Alert"')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment