Skip to content

Commit

Permalink
Add asg(Auto Scaling Groups) and sqs support for plumbum namespace.
Browse files Browse the repository at this point in the history
  • Loading branch information
guyingbo committed Jul 29, 2015
1 parent b64d0ed commit ec8255e
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 1 deletion.
20 changes: 19 additions & 1 deletion plumbum.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Options:
template path to the jinja2 template
namespace AWS namespace. Currently supports: elasticache, elb, ec2, rds
namespace AWS namespace. Currently supports: elasticache, elb, ec2, rds, asg, sqs
region AWS region [default: us-east-1]
options key value combinations, they can be tags or any other property
Expand Down Expand Up @@ -37,6 +37,8 @@
import boto.ec2.elb
import boto.rds
import boto.elasticache
import boto.ec2.autoscale
import boto.sqs
import jinja2


Expand Down Expand Up @@ -140,11 +142,27 @@ def list_elasticache(region, filter_by_kwargs):
return clusters


def list_autoscaling_group(region, filter_by_kwargs):
"""List all Auto Scaling Groups."""
conn = boto.ec2.autoscale.connect_to_region(region)
groups = conn.get_all_groups()
return lookup(groups, filter_by=filter_by_kwargs)


def list_sqs(region, filter_by_kwargs):
"""List all SQS Queues."""
conn = boto.sqs.connect_to_region(region)
queues = conn.get_all_queues()
return lookup(queues, filter_by=filter_by_kwargs)


list_resources = {
'ec2': list_ec2,
'elb': list_elb,
'rds': list_rds,
'elasticache': list_elasticache,
'asg': list_autoscaling_group,
'sqs': list_sqs,
}


Expand Down
19 changes: 19 additions & 0 deletions sample_templates/asg.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Sample config.yaml
#
Auth:
region: "{{ region }}"
Metrics:
{% for asg in resources %}
- Namespace: "AWS/EC2"
MetricName: "CPUUtilization"
Statistics:
- "Maximum"
- "Average"
Unit: "Percent"
Dimensions:
AutoScalingGroupName: {{ asg.name }}
{% endfor %}
Options:
Count: 3
Period: 5
Formatter: 'cloudwatch.aws.asg.{{ region }}.%(dimension)s.%(MetricName)s.%(statistic)s.%(Unit)s'
18 changes: 18 additions & 0 deletions sample_templates/sqs.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Sample config.yaml
#
Auth:
region: "{{ region }}"
Metrics:
{%- for sqs in resources %}
- Namespace: "AWS/SQS"
MetricName: "NumberOfMessagesReceived"
Statistics:
- "Sum"
Unit: "Count"
Dimensions:
QueueName: {{ sqs.name }}
{%- endfor %}
Options:
Count: 5
Period: 5
Formatter: 'cloudwatch.%(Namespace)s.{{ region }}.%(dimension)s.%(MetricName)s.%(statistic)s.%(Unit)s'

0 comments on commit ec8255e

Please sign in to comment.