コード例 #1
3
ファイル: CloudWatchSamples.cs プロジェクト: aws/aws-sdk-net
    public static void CWGetMetricStatistics()
    {
      #region CWGetMetricStatistics
      var client = new AmazonCloudWatchClient();

      var request = new GetMetricStatisticsRequest
      {
        Dimensions = new List<Dimension>() { dimension },
        EndTime = DateTime.Today,
        MetricName = "CPUUtilization",
        Namespace = "AWS/EC2",
        // Get statistics by day.
        Period = (int)TimeSpan.FromDays(1).TotalSeconds,
        // Get statistics for the past month.
        StartTime = DateTime.Today.Subtract(TimeSpan.FromDays(30)),
        Statistics = new List<string>() { "Minimum" },
        Unit = StandardUnit.Percent
      };

      var response = client.GetMetricStatistics(request);

      if (response.Datapoints.Count > 0)
      {
        foreach (var point in response.Datapoints)
        {
          Console.WriteLine(point.Timestamp.ToShortDateString() +
            " " + point.Minimum + "%");
        }
      }
      #endregion

      Console.ReadLine();
    }
コード例 #2
0
ファイル: MainActivity.cs プロジェクト: Clancey/aws-sdk-net
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			// Set our view from the "main" layout resource
			SetContentView (Resource.Layout.Main);

			// Get our button from the layout resource,
			// and attach an event to it
			Button button = FindViewById<Button> (Resource.Id.getcloudwatchdata);
			EditText cloudwatchdata = FindViewById<EditText> (Resource.Id.cloudwatchdata);

			button.Click += delegate {
				const string ACCESS_KEY = "";
				const string SECRET_KEY = "";
				IAmazonCloudWatch cw = Amazon.AWSClientFactory.CreateAmazonCloudWatchClient (ACCESS_KEY, SECRET_KEY, Amazon.RegionEndpoint.USWest1);

				string measureName = "CPUUtilization";

				GetMetricStatisticsRequest request = new GetMetricStatisticsRequest ();
				request.StartTime = DateTime.Now.AddDays (-1);
				request.Namespace = "AWS/EC2";
				request.Period = 5 * 60;
				var dimensions = new Dimension ();
				dimensions.Name = "InstanceType";
				dimensions.Value = "t1.micro";
				request.Dimensions = new List<Dimension>{ dimensions };
				request.MetricName = measureName;
				request.Statistics = new List<string>{"Average", "Maximum", "Minimum"};
				request.EndTime = DateTime.Now;

				List<Datapoint> datapoints = cw.GetMetricStatistics(request).Datapoints;
				datapoints.ForEach(d => cloudwatchdata.Text = String.Format("Min: {0} Max: {1} Average: {3} Unit: {4}\n", d.Minimum, d.Maximum, d.Average, d.Unit));
			};
		}
コード例 #3
0
		void HandleTouchUpInside (object sender, EventArgs e)
		{
			const string ACCESS_KEY = "";
			const string SECRET_KEY = "";
			IAmazonCloudWatch cw = Amazon.AWSClientFactory.CreateAmazonCloudWatchClient (ACCESS_KEY, SECRET_KEY, Amazon.RegionEndpoint.USWest1);

			string measureName = "CPUUtilization";

			GetMetricStatisticsRequest request = new GetMetricStatisticsRequest ();
			request.StartTime = DateTime.Now.AddDays (-1);
			request.Namespace = "AWS/EC2";
			request.Period = 5 * 60;
			var dimensions = new Dimension ();
			dimensions.Name = "InstanceType";
			dimensions.Value = "t1.micro";
			request.Dimensions = new List<Dimension>{ dimensions };
			request.MetricName = measureName;
			request.Statistics = new List<string>{"Average", "Maximum", "Minimum"};
			request.EndTime = DateTime.Now;

			List<Datapoint> datapoints = cw.GetMetricStatistics(request).Datapoints;
			datapoints.ForEach(d => 
				this.View.Add(new UILabel(){
					Text = String.Format("Min: {0} Max: {1} Average: {3} Unit: {4}\n", d.Minimum, d.Maximum, d.Average, d.Unit), 
					Frame = (new RectangleF(20, 40*datapoints.FindIndex(dp => dp==d), 280, 21))
				}));
		}
コード例 #4
0
        public static List<CloudWatchResultRecord> GetCpuUtilization(string instanceId, int minutesBack)
        {
            var cloudWatchClient = CloudWatchConnectionProvider.GetCloudWatchConnection();

            var dimension = new Dimension
            {
                Name = "InstanceId",
                Value = instanceId,
            };

            var request = new GetMetricStatisticsRequest();
            request.Dimensions.Add(dimension);

            var currentTime = DateTime.UtcNow;
            var startTime = currentTime.AddDays(-1);
            request.StartTime = startTime;
            request.EndTime = currentTime;

            request.Namespace = "AWS/EC2";
            request.Statistics.Add("Maximum");
            request.Statistics.Add("Average");
            request.MetricName = "CPUUtilization";
            request.Period = 60;

            var response = cloudWatchClient.GetMetricStatistics(request);

            if (response.GetMetricStatisticsResult.Datapoints.Count > 0)
            {
                var result = new List<CloudWatchResultRecord>();
                int counter = 0;

                foreach(var dataPoint in response.GetMetricStatisticsResult.Datapoints)
                {
                    result.Add(new CloudWatchResultRecord()
                    {
                        RecordId = counter,
                        CpuAverage = dataPoint.Average
                    });
                }

                return result;
            }
            else
            {
                return null;
            }
        }
コード例 #5
0
        /// <summary>
        /// Initiates the asynchronous execution of the GetMetricStatistics operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the GetMetricStatistics operation on AmazonCloudWatchClient.</param>
        /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
        /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
        ///          procedure using the AsyncState property.</param>
        /// 
        /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndGetMetricStatistics
        ///         operation.</returns>
        public IAsyncResult BeginGetMetricStatistics(GetMetricStatisticsRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new GetMetricStatisticsRequestMarshaller();
            var unmarshaller = GetMetricStatisticsResponseUnmarshaller.Instance;

            return BeginInvoke<GetMetricStatisticsRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
コード例 #6
0
        /// <summary>
        /// Gets statistics for the specified metric. 
        /// 
        ///  
        /// <para>
        ///  The maximum number of data points returned from a single <code>GetMetricStatistics</code>
        /// request is 1,440, wereas the maximum number of data points that can be queried is
        /// 50,850. If you make a request that generates more than 1,440 data points, Amazon CloudWatch
        /// returns an error. In such a case, you can alter the request by narrowing the specified
        /// time range or increasing the specified period. Alternatively, you can make multiple
        /// requests across adjacent time ranges. 
        /// </para>
        ///  
        /// <para>
        ///  Amazon CloudWatch aggregates data points based on the length of the <code>period</code>
        /// that you specify. For example, if you request statistics with a one-minute granularity,
        /// Amazon CloudWatch aggregates data points with time stamps that fall within the same
        /// one-minute period. In such a case, the data points queried can greatly outnumber the
        /// data points returned. 
        /// </para>
        ///  
        /// <para>
        ///  The following examples show various statistics allowed by the data point query maximum
        /// of 50,850 when you call <code>GetMetricStatistics</code> on Amazon EC2 instances with
        /// detailed (one-minute) monitoring enabled: 
        /// </para>
        ///  <ul> <li>Statistics for up to 400 instances for a span of one hour</li> <li>Statistics
        /// for up to 35 instances over a span of 24 hours</li> <li>Statistics for up to 2 instances
        /// over a span of 2 weeks</li> </ul> 
        /// <para>
        ///  For information about the namespace, metric names, and dimensions that other Amazon
        /// Web Services products use to send metrics to Cloudwatch, go to <a href="http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/CW_Support_For_AWS.html">Amazon
        /// CloudWatch Metrics, Namespaces, and Dimensions Reference</a> in the <i>Amazon CloudWatch
        /// Developer Guide</i>. 
        /// </para>
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the GetMetricStatistics service method.</param>
        /// 
        /// <returns>The response from the GetMetricStatistics service method, as returned by CloudWatch.</returns>
        /// <exception cref="Amazon.CloudWatch.Model.InternalServiceException">
        /// Indicates that the request processing has failed due to some unknown error, exception,
        /// or failure.
        /// </exception>
        /// <exception cref="Amazon.CloudWatch.Model.InvalidParameterCombinationException">
        /// Parameters that must not be used together were used together.
        /// </exception>
        /// <exception cref="Amazon.CloudWatch.Model.InvalidParameterValueException">
        /// Bad or out-of-range value was supplied for the input parameter.
        /// </exception>
        /// <exception cref="Amazon.CloudWatch.Model.MissingRequiredParameterException">
        /// An input parameter that is mandatory for processing the request is not supplied.
        /// </exception>
        public GetMetricStatisticsResponse GetMetricStatistics(GetMetricStatisticsRequest request)
        {
            var marshaller = new GetMetricStatisticsRequestMarshaller();
            var unmarshaller = GetMetricStatisticsResponseUnmarshaller.Instance;

            return Invoke<GetMetricStatisticsRequest,GetMetricStatisticsResponse>(request, marshaller, unmarshaller);
        }
コード例 #7
0
        /// <summary>
        /// <para> Gets statistics for the specified metric. </para> <para> The maximum number of data points returned from a single
        /// <c>GetMetricStatistics</c> request is 1,440, wereas the maximum number of data points that can be queried is 50,850. If you make a request
        /// that generates more than 1,440 data points, Amazon CloudWatch returns an error. In such a case, you can alter the request by narrowing the
        /// specified time range or increasing the specified period. Alternatively, you can make multiple requests across adjacent time ranges. </para>
        /// <para> Amazon CloudWatch aggregates data points based on the length of the <c>period</c> that you specify. For example, if you request
        /// statistics with a one-minute granularity, Amazon CloudWatch aggregates data points with time stamps that fall within the same one-minute
        /// period. In such a case, the data points queried can greatly outnumber the data points returned. </para> <para> The following examples show
        /// various statistics allowed by the data point query maximum of 50,850 when you call <c>GetMetricStatistics</c> on Amazon EC2 instances with
        /// detailed (one-minute) monitoring enabled: </para>
        /// <ul>
        /// <li>Statistics for up to 400 instances for a span of one hour</li>
        /// <li>Statistics for up to 35 instances over a span of 24 hours</li>
        /// <li>Statistics for up to 2 instances over a span of 2 weeks</li>
        /// 
        /// </ul>
        /// <para> For information about the namespace, metric names, and dimensions that other Amazon Web Services products use to send metrics to
        /// Cloudwatch, go to <a href="http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/CW_Support_For_AWS.html">Amazon CloudWatch
        /// Metrics, Namespaces, and Dimensions Reference</a> in the <i>Amazon CloudWatch Developer Guide</i> .
        /// </para>
        /// </summary>
        /// 
        /// <param name="getMetricStatisticsRequest">Container for the necessary parameters to execute the GetMetricStatistics service method on
        /// AmazonCloudWatch.</param>
        /// 
        /// <returns>The response from the GetMetricStatistics service method, as returned by AmazonCloudWatch.</returns>
        /// 
        /// <exception cref="T:Amazon.CloudWatch.Model.InvalidParameterValueException" />
        /// <exception cref="T:Amazon.CloudWatch.Model.InternalServiceException" />
        /// <exception cref="T:Amazon.CloudWatch.Model.InvalidParameterCombinationException" />
        /// <exception cref="T:Amazon.CloudWatch.Model.MissingRequiredParameterException" />
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
		public Task<GetMetricStatisticsResponse> GetMetricStatisticsAsync(GetMetricStatisticsRequest getMetricStatisticsRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new GetMetricStatisticsRequestMarshaller();
            var unmarshaller = GetMetricStatisticsResponseUnmarshaller.GetInstance();
            return Invoke<IRequest, GetMetricStatisticsRequest, GetMetricStatisticsResponse>(getMetricStatisticsRequest, marshaller, unmarshaller, signer, cancellationToken);
        }
コード例 #8
0
		internal GetMetricStatisticsResponse GetMetricStatistics(GetMetricStatisticsRequest request)
        {
            var task = GetMetricStatisticsAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                throw e.InnerException;
            }
        }
コード例 #9
0
        /// <summary>
        /// <para> Gets statistics for the specified metric. </para> <para> The maximum number of data points returned from a single
        /// <c>GetMetricStatistics</c> request is 1,440, wereas the maximum number of data points that can be queried is 50,850. If you make a request
        /// that generates more than 1,440 data points, Amazon CloudWatch returns an error. In such a case, you can alter the request by narrowing the
        /// specified time range or increasing the specified period. Alternatively, you can make multiple requests across adjacent time ranges. </para>
        /// <para> Amazon CloudWatch aggregates data points based on the length of the <c>period</c> that you specify. For example, if you request
        /// statistics with a one-minute granularity, Amazon CloudWatch aggregates data points with time stamps that fall within the same one-minute
        /// period. In such a case, the data points queried can greatly outnumber the data points returned. </para> <para> The following examples show
        /// various statistics allowed by the data point query maximum of 50,850 when you call <c>GetMetricStatistics</c> on Amazon EC2 instances with
        /// detailed (one-minute) monitoring enabled: </para>
        /// <ul>
        /// <li>Statistics for up to 400 instances for a span of one hour</li>
        /// <li>Statistics for up to 35 instances over a span of 24 hours</li>
        /// <li>Statistics for up to 2 instances over a span of 2 weeks</li>
        /// 
        /// </ul>
        /// <para> For information about the namespace, metric names, and dimensions that other Amazon Web Services products use to send metrics to
        /// Cloudwatch, go to <a href="http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/CW_Support_For_AWS.html">Amazon CloudWatch
        /// Metrics, Namespaces, and Dimensions Reference</a> in the <i>Amazon CloudWatch Developer Guide</i> .
        /// </para>
        /// </summary>
        /// 
        /// <param name="getMetricStatisticsRequest">Container for the necessary parameters to execute the GetMetricStatistics service method on
        /// AmazonCloudWatch.</param>
        /// 
        /// <returns>The response from the GetMetricStatistics service method, as returned by AmazonCloudWatch.</returns>
        /// 
        /// <exception cref="T:Amazon.CloudWatch.Model.InvalidParameterValueException" />
        /// <exception cref="T:Amazon.CloudWatch.Model.InternalServiceException" />
        /// <exception cref="T:Amazon.CloudWatch.Model.InvalidParameterCombinationException" />
        /// <exception cref="T:Amazon.CloudWatch.Model.MissingRequiredParameterException" />
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
		public async Task<GetMetricStatisticsResponse> GetMetricStatisticsAsync(GetMetricStatisticsRequest getMetricStatisticsRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new GetMetricStatisticsRequestMarshaller();
            var unmarshaller = GetMetricStatisticsResponseUnmarshaller.GetInstance();
            var response = await Invoke<IRequest, GetMetricStatisticsRequest, GetMetricStatisticsResponse>(getMetricStatisticsRequest, marshaller, unmarshaller, signer, cancellationToken)
                .ConfigureAwait(continueOnCapturedContext: false);
            return response;
        }
コード例 #10
0
        private async Task<GetMetricStatisticsResponse> GetMetricResponse(string tableName, string indexName, string metricName, CancellationToken cancellationToken)
        {
            var dimensions = GetDimensions(tableName, indexName);
            var completeMetricName = CalculateMetricName(tableName, indexName, metricName);

            var request = new GetMetricStatisticsRequest
            {
                Namespace = DynamoDbMetricNamespace,
                Dimensions = dimensions,
                MetricName = completeMetricName,
                Period = 60,
                StartTime = DateTime.UtcNow.Subtract(MetricTimeSpan),
                EndTime = DateTime.UtcNow,
                Statistics = new[] { "Average", "Sum" }.ToList()
            };

            return await client.GetMetricStatisticsAsync(request, cancellationToken);
        }
コード例 #11
0
 private Amazon.CloudWatch.Model.GetMetricStatisticsResponse CallAWSServiceOperation(IAmazonCloudWatch client, Amazon.CloudWatch.Model.GetMetricStatisticsRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon CloudWatch", "GetMetricStatistics");
     try
     {
         #if DESKTOP
         return(client.GetMetricStatistics(request));
         #elif CORECLR
         return(client.GetMetricStatisticsAsync(request).GetAwaiter().GetResult());
         #else
                 #error "Unknown build edition"
         #endif
     }
     catch (AmazonServiceException exc)
     {
         var webException = exc.InnerException as System.Net.WebException;
         if (webException != null)
         {
             throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException);
         }
         throw;
     }
 }
コード例 #12
0
        /// <param name="asyncResult">The IAsyncResult returned by the call to BeginPutMetricData.</param>
        public PutMetricDataResponse EndPutMetricData(IAsyncResult asyncResult)
        {
            return endOperation<PutMetricDataResponse>(asyncResult);
        }
        
        IAsyncResult invokePutMetricData(PutMetricDataRequest putMetricDataRequest, AsyncCallback callback, object state, bool synchronized)
        {
            IRequest irequest = new PutMetricDataRequestMarshaller().Marshall(putMetricDataRequest);
            var unmarshaller = PutMetricDataResponseUnmarshaller.GetInstance();
            AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller);
            Invoke(result);
            return result;
        }
        
        
コード例 #13
0
		internal GetMetricStatisticsResponse GetMetricStatistics(GetMetricStatisticsRequest request)
        {
            var task = GetMetricStatisticsAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                ExceptionDispatchInfo.Capture(e.InnerException).Throw();
                return null;
            }
        }
コード例 #14
0
        /// <summary>
        /// Initiates the asynchronous execution of the GetMetricStatistics operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the GetMetricStatistics operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        public Task<GetMetricStatisticsResponse> GetMetricStatisticsAsync(GetMetricStatisticsRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new GetMetricStatisticsRequestMarshaller();
            var unmarshaller = GetMetricStatisticsResponseUnmarshaller.Instance;

            return InvokeAsync<GetMetricStatisticsRequest,GetMetricStatisticsResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }
コード例 #15
0
 protected override void ProcessRecord()
 {
     AmazonCloudWatch client = base.GetClient();
     Amazon.CloudWatch.Model.GetMetricStatisticsRequest request = new Amazon.CloudWatch.Model.GetMetricStatisticsRequest();
     if (string.IsNullOrEmpty(this._Statistics))
     {
         request.Statistics.Add(this._Statistics);
     }
     request.Period = this._Period;
     request.MeasureName = this._MeasureName;
     request.StartTime = this._StartTime;
     request.EndTime = this._EndTime;
     request.Unit = this._Unit;
     request.CustomUnit = this._CustomUnit;
     request.Namespace = this._Namespace;
     Amazon.CloudWatch.Model.GetMetricStatisticsResponse response = client.GetMetricStatistics(request);
     base.WriteObject(response.GetMetricStatisticsResult, true);
 }
コード例 #16
0
        

        #endregion
    
        #region DescribeAlarmsForMetric

        /// <summary>
        /// <para> Retrieves all alarms for a single metric. Specify a statistic, period, or unit to filter the set of alarms further. </para>
        /// </summary>
        /// 
        /// <param name="describeAlarmsForMetricRequest">Container for the necessary parameters to execute the DescribeAlarmsForMetric service method on
        ///          AmazonCloudWatch.</param>
        /// 
        /// <returns>The response from the DescribeAlarmsForMetric service method, as returned by AmazonCloudWatch.</returns>
        /// 
        public DescribeAlarmsForMetricResponse DescribeAlarmsForMetric(DescribeAlarmsForMetricRequest describeAlarmsForMetricRequest)
        {
            IAsyncResult asyncResult = invokeDescribeAlarmsForMetric(describeAlarmsForMetricRequest, null, null, true);
            return EndDescribeAlarmsForMetric(asyncResult);
        }

        

        /// <summary>
        /// Initiates the asynchronous execution of the DescribeAlarmsForMetric operation.
        /// <seealso cref="Amazon.CloudWatch.AmazonCloudWatch.DescribeAlarmsForMetric"/>
        /// </summary>
        /// 
        /// <param name="describeAlarmsForMetricRequest">Container for the necessary parameters to execute the DescribeAlarmsForMetric operation on
        ///          AmazonCloudWatch.</param>
        /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
        /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
        ///          procedure using the AsyncState property.</param>
        /// 
        /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking
コード例 #17
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.CloudWatch.Model.GetMetricStatisticsRequest();

            if (cmdletContext.Dimension != null)
            {
                request.Dimensions = cmdletContext.Dimension;
            }
            if (cmdletContext.UtcEndTime != null)
            {
                request.EndTimeUtc = cmdletContext.UtcEndTime.Value;
            }
            if (cmdletContext.ExtendedStatistic != null)
            {
                request.ExtendedStatistics = cmdletContext.ExtendedStatistic;
            }
            if (cmdletContext.MetricName != null)
            {
                request.MetricName = cmdletContext.MetricName;
            }
            if (cmdletContext.Namespace != null)
            {
                request.Namespace = cmdletContext.Namespace;
            }
            if (cmdletContext.Period != null)
            {
                request.Period = cmdletContext.Period.Value;
            }
            if (cmdletContext.UtcStartTime != null)
            {
                request.StartTimeUtc = cmdletContext.UtcStartTime.Value;
            }
            if (cmdletContext.Statistic != null)
            {
                request.Statistics = cmdletContext.Statistic;
            }
            if (cmdletContext.Unit != null)
            {
                request.Unit = cmdletContext.Unit;
            }
            #pragma warning disable CS0618, CS0612 //A class member was marked with the Obsolete attribute
            if (cmdletContext.EndTime != null)
            {
                if (cmdletContext.UtcEndTime != null)
                {
                    throw new System.ArgumentException("Parameters EndTime and UtcEndTime are mutually exclusive.", nameof(this.EndTime));
                }
                request.EndTime = cmdletContext.EndTime.Value;
            }
            #pragma warning restore CS0618, CS0612 //A class member was marked with the Obsolete attribute
            #pragma warning disable CS0618, CS0612 //A class member was marked with the Obsolete attribute
            if (cmdletContext.StartTime != null)
            {
                if (cmdletContext.UtcStartTime != null)
                {
                    throw new System.ArgumentException("Parameters StartTime and UtcStartTime are mutually exclusive.", nameof(this.StartTime));
                }
                request.StartTime = cmdletContext.StartTime.Value;
            }
            #pragma warning restore CS0618, CS0612 //A class member was marked with the Obsolete attribute

            CmdletOutput output;

            // issue call
            var client = Client ?? CreateClient(_CurrentCredentials, _RegionEndpoint);
            try
            {
                var    response       = CallAWSServiceOperation(client, request);
                object pipelineOutput = null;
                pipelineOutput = cmdletContext.Select(response, this);
                output         = new CmdletOutput
                {
                    PipelineOutput  = pipelineOutput,
                    ServiceResponse = response
                };
            }
            catch (Exception e)
            {
                output = new CmdletOutput {
                    ErrorResponse = e
                };
            }

            return(output);
        }
コード例 #18
0
 /// <summary>
 /// Finishes the asynchronous execution of the EnableAlarmActions operation.
 /// <seealso cref="Amazon.CloudWatch.AmazonCloudWatch.EnableAlarmActions"/>
 /// </summary>
 /// 
 /// <param name="asyncResult">The IAsyncResult returned by the call to BeginEnableAlarmActions.</param>
 public EnableAlarmActionsResponse EndEnableAlarmActions(IAsyncResult asyncResult)
 {
コード例 #19
0
 /// <summary>
 /// <para> Gets statistics for the specified metric. </para>
 /// <para><b>NOTE:</b> The maximum number of data points returned from a
 /// single GetMetricStatistics request is 1,440. If a request is made that
 /// generates more than 1,440 data points, Amazon CloudWatch returns an
 /// error. In such a case, alter the request by narrowing the specified
 /// time range or increasing the specified period. Alternatively, make
 /// multiple requests across adjacent time ranges. </para> <para> Amazon
 /// CloudWatch aggregates data points based on the length of the
 /// <c>period</c> that you specify. For example, if you request statistics
 /// with a one-minute granularity, Amazon CloudWatch aggregates data
 /// points with time stamps that fall within the same one-minute period.
 /// In such a case, the data points queried can greatly outnumber the data
 /// points returned. </para> <para><b>NOTE:</b> The maximum number of data
 /// points that can be queried is 50,850; whereas the maximum number of
 /// data points returned is 1,440. </para> <para> The following examples
 /// show various statistics allowed by the data point query maximum of
 /// 50,850 when you call <c>GetMetricStatistics</c> on Amazon EC2
 /// instances with detailed (one-minute) monitoring enabled: </para>
 /// <ul>
 /// <li>Statistics for up to 400 instances for a span of one hour</li>
 /// <li>Statistics for up to 35 instances over a span of 24 hours</li>
 /// <li>Statistics for up to 2 instances over a span of 2 weeks</li>
 /// 
 /// </ul>
 /// </summary>
 /// 
 /// <param name="getMetricStatisticsRequest">Container for the necessary
 ///           parameters to execute the GetMetricStatistics service method on
 ///           AmazonCloudWatch.</param>
 /// 
 /// <returns>The response from the GetMetricStatistics service method, as
 ///         returned by AmazonCloudWatch.</returns>
 /// 
 /// <exception cref="InvalidParameterValueException"/>
 /// <exception cref="InternalServiceException"/>
 /// <exception cref="InvalidParameterCombinationException"/>
 /// <exception cref="MissingRequiredParameterException"/>
 public GetMetricStatisticsResponse GetMetricStatistics(GetMetricStatisticsRequest getMetricStatisticsRequest)
 {
     IRequest<GetMetricStatisticsRequest> request = new GetMetricStatisticsRequestMarshaller().Marshall(getMetricStatisticsRequest);
     GetMetricStatisticsResponse response = Invoke<GetMetricStatisticsRequest, GetMetricStatisticsResponse> (request, this.signer, GetMetricStatisticsResponseUnmarshaller.GetInstance());
     return response;
 }
コード例 #20
0
ファイル: Form1.cs プロジェクト: nguyenq66850/AWSDataAnalysis
        private List<Datapoint> getData(int metricID, DateTime startdate, int days, int period)
        {
            List<Datapoint> datapoints = new List<Datapoint>();
            Metric metric = metricList[metricID];
            GetMetricStatisticsRequest request = new GetMetricStatisticsRequest();
            request.MetricName = metric.MetricName;
            request.Namespace = metric.Namespace;
            request.Dimensions = metric.Dimensions;
            request.Statistics.AddRange(statList);
            request.Period = period;

            try
            {
                for (int day = 0; day < days; day++)
                {
                    request.StartTime = startdate.AddDays(day);
                    request.EndTime = startdate.AddDays(day + 1);
                    GetMetricStatisticsResult result = cw.GetMetricStatistics(request).GetMetricStatisticsResult;
                    datapoints.AddRange(result.Datapoints);
                }
                datapoints.Sort((p1, p2) => DateTime.Compare(p1.Timestamp, p2.Timestamp));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            return datapoints;
        }