当前位置: 首页>>代码示例>>Python>>正文


Python cloudwatch.CloudWatchConnection类代码示例

本文整理汇总了Python中boto.ec2.cloudwatch.CloudWatchConnection的典型用法代码示例。如果您正苦于以下问题:Python CloudWatchConnection类的具体用法?Python CloudWatchConnection怎么用?Python CloudWatchConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CloudWatchConnection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_get_metric_statistics

 def test_get_metric_statistics(self):
     c = CloudWatchConnection()
     m = c.list_metrics()[0]
     end = datetime.datetime.now()
     start = end - datetime.timedelta(hours=24*14)
     c.get_metric_statistics(
         3600*24, start, end, m.name, m.namespace, ['Average', 'Sum'])
开发者ID:der4im,项目名称:boto,代码行数:7,代码来源:test_connection.py

示例2: test_build_put_params_invalid

 def test_build_put_params_invalid(self):
     c = CloudWatchConnection()
     params = {}
     try:
         c.build_put_params(params, name=["N", "M"], value=[1, 2, 3])
     except:
         pass
     else:
         self.fail("Should not accept lists of different lengths.")
开发者ID:der4im,项目名称:boto,代码行数:9,代码来源:test_connection.py

示例3: get_stats

def get_stats(key, secret, db_id, metric):
    end = datetime.now()
    start = end - timedelta(minutes=5)
    conn = CloudWatchConnection(key, secret)
    try:
        res = conn.get_metric_statistics(60, start, end, metric,
            "AWS/RDS", "Average", {"DBInstanceIdentifier": db_id})
    except Exception, e:
        print(e)
        sys.exit(1)
开发者ID:arcus-io,项目名称:puppet,代码行数:10,代码来源:check_rds.py

示例4: test_build_list_params

 def test_build_list_params(self):
     c = CloudWatchConnection()
     params = {}
     c.build_list_params(
         params, ['thing1', 'thing2', 'thing3'], 'ThingName%d')
     expected_params = {
         'ThingName1': 'thing1',
         'ThingName2': 'thing2',
         'ThingName3': 'thing3'
         }
     self.assertEqual(params, expected_params)
开发者ID:der4im,项目名称:boto,代码行数:11,代码来源:test_connection.py

示例5: test_build_put_params_one

 def test_build_put_params_one(self):
     c = CloudWatchConnection()
     params = {}
     c.build_put_params(params, name="N", value=1, dimensions={"D": "V"})
     expected_params = {
         'MetricData.member.1.MetricName': 'N',
         'MetricData.member.1.Value': 1,
         'MetricData.member.1.Dimensions.member.1.Name': 'D',
         'MetricData.member.1.Dimensions.member.1.Value': 'V',
         }
     self.assertEqual(params, expected_params)
开发者ID:der4im,项目名称:boto,代码行数:11,代码来源:test_connection.py

示例6: test_build_get_params_multiple_parameter_dimension1

 def test_build_get_params_multiple_parameter_dimension1(self):
     self.maxDiff = None
     c = CloudWatchConnection()
     params = {}
     dimensions = OrderedDict((("D1", "V"), ("D2", "W")))
     c.build_dimension_param(dimensions, params)
     expected_params = {
         'Dimensions.member.1.Name': 'D1',
         'Dimensions.member.1.Value': 'V',
         'Dimensions.member.2.Name': 'D2',
         'Dimensions.member.2.Value': 'W',
     }
     self.assertEqual(params, expected_params)
开发者ID:10sr,项目名称:hue,代码行数:13,代码来源:test_connection.py

示例7: AWSSendStatusSDK

def AWSSendStatusSDK(service):
  """Send status to AWS using SDK
  pip install boto"""
  status = service[1]
  service_name = service[0]

  cwc = CloudWatchConnection(aws_access_key_id, \
      aws_secret_access_key)
  if status:
    value = 1
  else:
    value = 0

  cwc.put_metric_data(namespace, name = service_name, value = str(value))
开发者ID:cbiphuk,项目名称:python,代码行数:14,代码来源:service_monitoring.py

示例8: test_build_put_params_multiple_metrics

 def test_build_put_params_multiple_metrics(self):
     c = CloudWatchConnection()
     params = {}
     c.build_put_params(params, name=["N", "M"], value=[1, 2], dimensions={"D": "V"})
     expected_params = {
         "MetricData.member.1.MetricName": "N",
         "MetricData.member.1.Value": 1,
         "MetricData.member.1.Dimensions.member.1.Name": "D",
         "MetricData.member.1.Dimensions.member.1.Value": "V",
         "MetricData.member.2.MetricName": "M",
         "MetricData.member.2.Value": 2,
         "MetricData.member.2.Dimensions.member.1.Name": "D",
         "MetricData.member.2.Dimensions.member.1.Value": "V",
     }
     self.assertEqual(params, expected_params)
开发者ID:jeffreywugz,项目名称:boto,代码行数:15,代码来源:test_connection.py

示例9: test_build_put_params_multiple_dimensions

 def test_build_put_params_multiple_dimensions(self):
     c = CloudWatchConnection()
     params = {}
     c.build_put_params(params, name="N", value=[1, 2], dimensions=[{"D": "V"}, {"D": "W"}])
     expected_params = {
         'MetricData.member.1.MetricName': 'N',
         'MetricData.member.1.Value': 1,
         'MetricData.member.1.Dimensions.member.1.Name': 'D',
         'MetricData.member.1.Dimensions.member.1.Value': 'V',
         'MetricData.member.2.MetricName': 'N',
         'MetricData.member.2.Value': 2,
         'MetricData.member.2.Dimensions.member.1.Name': 'D',
         'MetricData.member.2.Dimensions.member.1.Value': 'W',
         }
     self.assertEqual(params, expected_params)
开发者ID:der4im,项目名称:boto,代码行数:15,代码来源:test_connection.py

示例10: __init__

	def __init__(self, key, access, cluster):
		try:
			url = "http://169.254.169.254/latest/meta-data/"

			public_hostname = urlopen(url + "public-hostname").read()
			zone = urlopen(url + "placement/availability-zone").read()
			region = zone[:-1]
		except:
			sys.exit("We should be getting user-data here...")

		# the name (and identity) of the cluster (the master)
		self.cluster = cluster

		self.redis = redis.StrictRedis(host='localhost', port=6379)

		endpoint = "monitoring.{0}.amazonaws.com".format(region)
		region_info = RegionInfo(name=region, endpoint=endpoint)

		self.cloudwatch = CloudWatchConnection(key, access, region=region_info)
		self.namespace = '9apps/redis'

		self.events = Events(key, access, cluster)

		# get the host, but without the logging
		self.host = Host(cluster)
		self.node = self.host.get_node()
开发者ID:numan,项目名称:ReDiS,代码行数:26,代码来源:monitor.py

示例11: __init__

    def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
                 is_secure=False, port=None, proxy=None, proxy_port=None,
                 proxy_user=None, proxy_pass=None, debug=0,
                 https_connection_factory=None, region=None, path='/',
                 security_token=None, validate_certs=True):
        """
        Init method to create a new connection to EC2 Load Balancing Service.

        note:: The region argument is overridden by the region specified in
            the boto configuration file.
        """
        if not region:
            region = RegionInfo(self, self.DefaultRegionName,
                                self.DefaultRegionEndpoint)
        self.region = region
        self.cw_con = CloudWatchConnection(aws_access_key_id,
                                    aws_secret_access_key,
                                    is_secure, port, proxy, proxy_port,
                                    proxy_user, proxy_pass, debug,
                                    https_connection_factory, region, path,
                                    security_token,
                                    validate_certs=validate_certs)
        ELBConnection.__init__(self, aws_access_key_id,
                                    aws_secret_access_key,
                                    is_secure, port, proxy, proxy_port,
                                    proxy_user, proxy_pass, debug,
                                    https_connection_factory, region, path,
                                    security_token,
                                    validate_certs=validate_certs)
开发者ID:hnousiainen,项目名称:load-balancer-servo,代码行数:29,代码来源:__init__.py

示例12: put_cloudwatch_metric_data

def put_cloudwatch_metric_data(name, value, unit, namespace,
                               use_autoscaling_group=True):
    # TODO: Make this more efficient? There are some uses of this function that
    # call it multiple times in succession -- should there be a batch mode?

    dimensions = None
    if use_autoscaling_group:
        autoscaling_group = _get_autoscaling_group()
        dimensions = { 'AutoScalingGroupName': autoscaling_group } if autoscaling_group else None

    cloudwatch = CloudWatchConnection()
    cloudwatch.put_metric_data(namespace,
                               name,
                               value,
                               unit=unit,
                               dimensions=dimensions)
开发者ID:PowerOlive,项目名称:mail-responder,代码行数:16,代码来源:aws_helpers.py

示例13: get_cloudwatch_top_metrics

def get_cloudwatch_top_metrics():
    conn = CloudWatchConnection()

    metrics_names = []
    next_token = None
    while True:
        res = conn.list_metrics(next_token=next_token,
                                dimensions=settings.CLOUDWATCH_DIMENSIONS,
                                namespace=settings.CLOUDWATCH_NAMESPACE)
        metrics_names.extend([m.name for m in res])
        next_token = res.next_token
        if next_token is None:
            break

    # List of tuples like [(metric_name, count), ...]
    metrics = []

    for metric_name in metrics_names:
        res = conn.get_metric_statistics(int(START_DELTA_AGO.total_seconds()),
                                         datetime.datetime.now() - START_DELTA_AGO,
                                         datetime.datetime.now(),
                                         metric_name,
                                         settings.CLOUDWATCH_NAMESPACE,
                                         'Sum',
                                         settings.CLOUDWATCH_DIMENSIONS,
                                         'Count')

        if not res:
            # Some metrics will not have (or no longer have) results
            continue

        count = int(res[0]['Sum'])

        if count >= TOP_THRESHOLD_COUNT:
            metrics.append((metric_name, count))

    metrics.sort(key=lambda x: x[1], reverse=True)

    text = 'Responses sent\n----------------------\n'
    for metric in metrics:
        metric_name = 'TOTAL' if metric[0] == settings.CLOUDWATCH_TOTAL_SENT_METRIC_NAME else metric[0]
        if metric_name == settings.CLOUDWATCH_PROCESSING_TIME_METRIC_NAME:
            continue
        text += '%s %s\n' % (str(metric[1]).rjust(5), metric_name)

    return text
开发者ID:projectarkc,项目名称:psiphon,代码行数:46,代码来源:mail_stats.py

示例14: connect

	def connect(self, groupname):
		self.ec2 = boto.connect_ec2()
		self.cw = CloudWatchConnection()
		self.autoscale = AutoScaleConnection()
		self.group = self.autoscale.get_all_groups(names=[groupname])[0]
		self.instances = len(self.group.instances)
		self.desired = self.group.desired_capacity
		self.name = groupname
开发者ID:agrogeek,项目名称:Meneame,代码行数:8,代码来源:ec2_watchdata.py

示例15: test_build_get_params_multiple_parameter_dimension2

 def test_build_get_params_multiple_parameter_dimension2(self):
     from collections import OrderedDict
     self.maxDiff = None
     c = CloudWatchConnection()
     params = {}
     dimensions = OrderedDict((("D1", ["V1", "V2"]), ("D2", "W"), ("D3", None)))
     c.build_dimension_param(dimensions, params)
     expected_params = {
         'Dimensions.member.1.Name': 'D1',
         'Dimensions.member.1.Value': 'V1',
         'Dimensions.member.2.Name': 'D1',
         'Dimensions.member.2.Value': 'V2',
         'Dimensions.member.3.Name': 'D2',
         'Dimensions.member.3.Value': 'W',
         'Dimensions.member.4.Name': 'D3',
         }
     self.assertEqual(params, expected_params)
开发者ID:0t3dWCE,项目名称:boto,代码行数:17,代码来源:test_connection.py


注:本文中的boto.ec2.cloudwatch.CloudWatchConnection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。