Skip to content

Commit

Permalink
Fixes #3: Monitor multiple ASGs
Browse files Browse the repository at this point in the history
EP2 can now monitor multiple ASGs
  • Loading branch information
djmgit committed Nov 24, 2019
1 parent 6c84c15 commit 0083a5e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 5 additions & 1 deletion src/core/nodefetchers/awsfetcher/awsfetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,14 @@ def fetch(self):
if self.asg_boto_client == None or self.ec2_boto_client == None:
return None

# split the asg_name param using comma and store it in a list
asgs = self.asg_name.split(",")
asgs = [asg.strip() for asg in asgs]

# get backends from AWS
asg_instance_ips = BotoHandler.get_instance_ips_for_asg(asg_client=self.asg_boto_client,
ec2_client=self.ec2_boto_client,
asg_name=self.asg_name,
asg_name=asgs,
ip_type=self.ip_type
)

Expand Down
12 changes: 7 additions & 5 deletions src/core/nodefetchers/awsfetcher/botohandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def get_instance_ips_for_asg(**kwargs):
return asg_instance_ips

@staticmethod
def __get_instance_ids_for_asg(boto_client, asg_name, logger=None):
def __get_instance_ids_for_asg(boto_client, asg_names, logger=None):

""" Method for getting aws live instance ids belonging to the asg of interest
Expand All @@ -127,15 +127,17 @@ def __get_instance_ids_for_asg(boto_client, asg_name, logger=None):

# Describe the esired asg
response = boto_client.describe_auto_scaling_groups(
AutoScalingGroupNames=[
asg_name,
]
AutoScalingGroupNames=asg_names
)
except Exception as ex:
logger.critical("Failed to get instance ids for ASG with error : {}".format(str(ex)))
return None

instances = response.get("AutoScalingGroups")[0]["Instances"]
instances = []

# loop over all the autoscaling groups and get instance from them
for asg in response.get("AutoScalingGroups"):
instances += asg.get("Instances")

instance_ids = []

Expand Down

0 comments on commit 0083a5e

Please sign in to comment.