Created
September 30, 2014 17:09
-
-
Save bfulton/b92e90f88fa48389485f to your computer and use it in GitHub Desktop.
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
require 'aws-sdk' | |
require 'sumo' | |
require 'time' | |
# get all instances that have sent logs in last hour | |
sumo_insts = Sumo.search( | |
query: 'instance_id | parse "\"instance_id\":\"*\"" as instance_id | count by instance_id', | |
from: (Time.now - (60 * 60)).iso8601, | |
to: Time.now.iso8601, | |
time_zone: 'UTC' | |
).records.map { |record| record['instance_id'] } | |
# get all EC2 instances | |
ec2_insts = AWS::EC2.new.instances.map { |inst| inst.id } | |
# find the non-reporting instances | |
non_reporting_insts = ec2_insts - sumo_insts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment