Skip to content

Instantly share code, notes, and snippets.

@shadowbq
Last active June 8, 2016 21:05
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 shadowbq/20d93fb478014592aaa7b8a01cdc4817 to your computer and use it in GitHub Desktop.
Save shadowbq/20d93fb478014592aaa7b8a01cdc4817 to your computer and use it in GitHub Desktop.
describe ipsec vpns for aws
#!/usr/bin/python
import boto.ec2.cloudwatch
import boto.vpc
AWS_Regions=["us-east-1","us-west-2","us-west-1","eu-west-1","ap-southeast-1","ap-northeast-1","ap-southeast-2","sa-east-1","eu-central-1"]
#AWS_Regions=boto.ec2.regions()
CloudWatch_Region="us-east-1"
cw = boto.ec2.cloudwatch.connect_to_region(CloudWatch_Region)
for region in AWS_Regions:
vpcconn = boto.vpc.connect_to_region(region)
try:
vpns = vpcconn.get_all_vpn_connections()
for vpn in vpns:
if vpn.state == "available":
active_tunnels = 0
if vpn.tunnels[0].status == "UP":
active_tunnels+=1
if vpn.tunnels[1].status == "UP":
active_tunnels+=1
print vpn.id+" has "+str(active_tunnels)+" active tunnels!"
cw.put_metric_data("VPNStatus", vpn.id, unit="Count", value=active_tunnels, dimensions={'VGW':vpn.vpn_gateway_id, 'CGW':vpn.customer_gateway_id})
except:
continue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment