Skip to content

Instantly share code, notes, and snippets.

@torian
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save torian/8940007 to your computer and use it in GitHub Desktop.
Save torian/8940007 to your computer and use it in GitHub Desktop.
AWS ELB monitoring
#!/usr/bin/env python
"""Usage: elb [-r REGION] [-l LBNAME]
-r REGION, --region REGION Region name [default: eu-west-1]
-l LBNAME, --lb LBNAME Load Balancer name
"""
from docopt import docopt
import boto
import boto.ec2.elb
import boto.ec2.elb.loadbalancer
import boto.regioninfo
# Options from __doc__
opts = docopt(__doc__)
cfg = {
'endpoint': 'elasticloadbalancing.amazonaws.com',
'APIVersion': '2012-06-01',
}
region = boto.regioninfo.RegionInfo(
name = opts['--region'],
endpoint = '%s.%s' % (opts['--region'], cfg['endpoint'])
)
print "Boto version: %s" % boto.Version
print region
conn = boto.connect_elb(region = region)
if opts['--lb'] is None:
lbs = conn.get_all_load_balancers()
for lb in lbs:
print lb
else:
lb_health = conn.describe_instance_health(opts['--lb'])
#lb_attrs = conn.get_all_lb_attributes(opts['--lb'])
#for attr in lb_attrs:
# print attr
for node in lb_health:
print node
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment