Example #1
0
        public int GetCountOfMessages(string queueURL)
        {
            int countOfMessages            = 0;
            var getNumberOfMessagesRequest = sqsClient.GetQueueAttributesAsync(
                new GetQueueAttributesRequest
            {
                QueueUrl       = queueURL,
                AttributeNames = new List <string>()
                {
                    "All"
                }
            }
                );

            countOfMessages = getNumberOfMessagesRequest.Result.ApproximateNumberOfMessages;
            ConfigSection.Add(new Service
            {
                ServiceType = ServiceType,
                ServiceName = queueURL.Substring(queueURL.LastIndexOf('/') + 1),
                Metric      = "CountOfMessages",
                Value       = countOfMessages.ToString()
            });

            return(countOfMessages);
        }
        private double GetCountOfInvocations(string functionName)
        {
            double countOfInvocation  = 0;
            var    InvocationResponse = cloudWatchClient.GetMetricStatisticsAsync(
                new Amazon.CloudWatch.Model.GetMetricStatisticsRequest
            {
                Dimensions = new List <Amazon.CloudWatch.Model.Dimension>()
                {
                    new Amazon.CloudWatch.Model.Dimension
                    {
                        Name  = "FunctionName",
                        Value = functionName
                    }
                },
                EndTime    = DateTime.Today,
                MetricName = "Invocations",
                Namespace  = "AWS/Lambda",
                // Get statistics by day.
                Period = (int)TimeSpan.FromDays(1).TotalSeconds,
                // Get statistics for the past month.
                StartTime  = DateTime.Today.Subtract(TimeSpan.FromDays(30)),
                Statistics = statisticList,
                Unit       = StandardUnit.Count
            });

            foreach (var point in InvocationResponse.Result.Datapoints)
            {
                countOfInvocation += point.Sum;
            }
            ConfigSection.Add(new Service
            {
                ServiceType = ServiceType,
                ServiceName = functionName,
                Metric      = Metrics.Invocations.ToString(),
                Value       = countOfInvocation.ToString()
            });
            return(countOfInvocation);
        }
Example #3
0
        public ApiGatewayUrl CheckURL(string url)
        {
            var Url = new ApiGatewayUrl();

            Url.CheckUrl(url);
            urls.Add(Url);
            UrlRepository.addNewUrl(url);

            var config = ConfigurationManager.OpenMappedMachineConfiguration(new ConfigurationFileMap(@"..\..\..\ServiceConfiguration.config"));

            ConfigSection = config.GetSection("serviceSection") as ServiceSection;

            ConfigSection.Add(new Service
            {
                ServiceType = "ApiGateWay",
                ServiceName = url,
                Metric      = "url",
                Value       = Url.Code.Description
            });
            config.Save(ConfigurationSaveMode.Modified);
            return(Url);
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            UrlList.Visibility = Visibility.Visible;
            var url = new ApiGatewayUrl();

            url.CheckUrl(UrlTxt.Text);
            UrlVM.UrlRepository.addNewUrl(UrlTxt.Text);
            UrlVM.urls.Add(url);

            var config = ConfigurationManager.OpenMappedMachineConfiguration(new ConfigurationFileMap(@"..\..\ServiceConfiguration.config"));

            ConfigSection = config.GetSection("serviceSection") as ServiceSection;

            ConfigSection.Add(new Service
            {
                ServiceType = "ApiGateWay",
                ServiceName = url.Url,
                Metric      = "url",
                Value       = url.Code.Description
            });
            config.Save(ConfigurationSaveMode.Modified);
            UrlList.Items.Refresh();
        }