This file contains hidden or 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"') |