Created
November 20, 2012 14:33
-
-
Save yuvalo/4118268 to your computer and use it in GitHub Desktop.
Sets off a notification when you forget too many EC2 instances running.
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
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