Exemple #1
0
        private void InitNMonMonitorClient()
        {
            try
            {
                if (mNetMonitorClient != null)
                {
                    mNetMonitorClient.Stop();
                    mNetMonitorClient = null;
                }

                //string strAddress = App.Session.AppServerInfo.Address;
                //int intPort = App.Session.AppServerInfo.SupportHttps
                //    ? App.Session.AppServerInfo.Port - 5
                //    : App.Session.AppServerInfo.Port - 4;

                string strAddress = "192.168.5.31";
                int    intPort    = 8081 - 4;

                mNetMonitorClient        = new MonitorClient();
                mNetMonitorClient.Debug += (mode, msg) => AppendMessage(string.Format("MonitorClient\t{0}", msg));
                mNetMonitorClient.ReturnMessageReceived += NMonMonitorClient_ReturnMessageReceived;
                mNetMonitorClient.NotifyMessageReceived += NMonMonitorClient_NotifyMessageReceived;
                mNetMonitorClient.Connect(strAddress, intPort);
            }
            catch (Exception ex)
            {
                AppendMessage(ex.Message);
            }
        }
Exemple #2
0
        private static async Task RunMetricsSample(MonitorClient readOnlyClient, string resourceUri)
        {
            Write("Call without filter parameter (i.e. $filter = null)");
            IEnumerable <Metric> metrics = await readOnlyClient.Metrics.ListAsync(resourceUri : resourceUri, cancellationToken : CancellationToken.None);

            EnumerateMetrics(metrics);

            // The $filter can contain a propositional logic expression, specifically, a disjunction of the format: [(]name.value eq '<mericName>' or name.value eq '<metricName>' ...[)]
            var metricNames = "name.value eq 'CpuPercentage'"; // could be concatenated with " or name.value eq '<another name>'" ... inside parentheses for more than one name.

            // The $filter can include time grain, which is optional when metricNames is present. The is forms a conjunction with the list of metric names described above.
            string timeGrain = " and timeGrain eq duration'PT5M'";

            // The $filter can also include a time range for the query; also a conjunction with the list of metrics and/or the time grain. Defaulting to 3 hours before the time of execution for these datetimes
            string startDate = string.Format(" and startTime eq {0}", DateTime.Now.AddHours(-3).ToString("o"));
            string endDate   = string.Format(" and endTime eq {0}", DateTime.Now.ToString("o"));

            var odataFilterMetrics = new ODataQuery <Metric>(
                string.Format(
                    "{0}{1}{2}{3}",
                    metricNames,
                    timeGrain,
                    startDate,
                    endDate));

            Write("Call with filter parameter (i.e. $filter = {0})", odataFilterMetrics);
            metrics = await readOnlyClient.Metrics.ListAsync(resourceUri : resourceUri, odataQuery : odataFilterMetrics, cancellationToken : CancellationToken.None);

            EnumerateMetrics(metrics);
        }
Exemple #3
0
        public static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                throw new ArgumentException("Usage: AzureMonitorCSharpExamples <resourceId>");
            }

            var tenantId       = Environment.GetEnvironmentVariable("AZURE_TENANT_ID");
            var clientId       = Environment.GetEnvironmentVariable("AZURE_CLIENT_ID");
            var secret         = Environment.GetEnvironmentVariable("AZURE_CLIENT_SECRET");
            var subscriptionId = Environment.GetEnvironmentVariable("AZURE_SUBSCRIPTION_ID");

            if (new List <string> {
                tenantId, clientId, secret, subscriptionId
            }.Any(i => String.IsNullOrEmpty(i)))
            {
                Console.WriteLine("Please provide environment variables for AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET and AZURE_SUBSCRIPTION_ID.");
            }
            else
            {
                readOnlyClient = AuthenticateWithReadOnlyClient(tenantId, clientId, secret, subscriptionId).Result;
                var resourceId = args[1];

                RunMetricDefinitionsSample(readOnlyClient, resourceId).Wait();
                RunMetricsSample(readOnlyClient, resourceId).Wait();
            }
        }
Exemple #4
0
        private static async Task <double> ListMetrics(MonitorClient readOnlyClient, string resourceUri, string metricName)
        {
            // The timespan is the concatenation of the start and end date/times separated by "/"
            string startDate = DateTime.Now.AddHours(-1).ToString("o");
            string endDate   = DateTime.Now.ToString("o");
            string timeSpan  = startDate + "/" + endDate;

            Response metrics = await readOnlyClient.Metrics.ListAsync(resourceUri : resourceUri,
                                                                      metric : metricName,
                                                                      aggregation : "Total",
                                                                      timespan : timeSpan,
                                                                      interval : TimeSpan.FromMinutes(1),
                                                                      resultType : ResultType.Data,
                                                                      cancellationToken : CancellationToken.None);

            double result = 0;

            foreach (var metric in metrics.Value)
            {
                foreach (TimeSeriesElement element in metric.Timeseries)
                {
                    foreach (MetricValue data in element.Data)
                    {
                        result += (double)data.Total;
                    }
                }
            }

            return(result);
        }
Exemple #5
0
        private static Dictionary <string, LinkModel> getLinkModel(string ip, out PCData pcdata, out double memCount)
        {
            NetTcpBinding binging = new NetTcpBinding();

            binging.MaxBufferPoolSize      = 524288;
            binging.MaxBufferSize          = 2147483647;
            binging.MaxReceivedMessageSize = 2147483647;
            binging.MaxConnections         = 1000;
            binging.ListenBacklog          = 200;
            binging.OpenTimeout            = TimeSpan.Parse("00:10:00");
            binging.ReceiveTimeout         = TimeSpan.Parse("00:10:00");
            binging.TransferMode           = TransferMode.Buffered;
            binging.Security.Mode          = SecurityMode.None;

            binging.SendTimeout           = TimeSpan.Parse("00:10:00");
            binging.ReaderQuotas.MaxDepth = 64;
            binging.ReaderQuotas.MaxStringContentLength = 2147483647;
            binging.ReaderQuotas.MaxArrayLength         = 16384;
            binging.ReaderQuotas.MaxBytesPerRead        = 4096;
            binging.ReaderQuotas.MaxNameTableCharCount  = 16384;
            binging.ReliableSession.Ordered             = true;
            binging.ReliableSession.Enabled             = false;
            binging.ReliableSession.InactivityTimeout   = TimeSpan.Parse("00:10:00");

            Dictionary <string, LinkModel> modellist = new Dictionary <string, LinkModel>();

            using (MonitorClient client = MonitorClient.Instance)
            {
                IMonitorControl proxy = client.getProxy(ip, binging);
                modellist = proxy.GetMonitorInfo(out pcdata, out memCount);
            }

            return(modellist);
        }
Exemple #6
0
        private static void CalculateFunctionAppCost(MonitorClient readOnlyClient, string resourceId, string outputFilename)
        {
            double execUnitsLastHour = ListMetrics(readOnlyClient, resourceId, "FunctionExecutionUnits").Result;
            double execCountLastHour = ListMetrics(readOnlyClient, resourceId, "FunctionExecutionCount").Result;

            // calc pricing - currnetly hard coded (until usage of RateCard API will be possible)
            // using retail pricing https://azure.microsoft.com/en-us/pricing/details/functions/
            // exec count = Total Executions
            // exec units = Execution Time

            double execCountMonth = execCountLastHour * 24 * 30;
            double totalExecs     = (execCountMonth > mil) ? ((execCountMonth - mil) / mil) * executionsPrice : 0;

            execUnitsLastHour = execUnitsLastHour / gig; // convert to GB
            double execUnitMonth = execUnitsLastHour * 24 * 30;
            double execTime      = (execUnitMonth > freeGB) ? (execUnitMonth - freeGB) * unitsPrice : 0;

            double totalCost = totalExecs + execTime;

            Console.WriteLine("Toal Price: " + totalCost + "\n");
            Console.WriteLine("Metric\tHour\tMonth\tCost");
            Console.WriteLine(string.Format("{0}\t{1}\t{2}\t{3}", "FunctionExecutionUnits", execUnitsLastHour, execUnitMonth, execTime));
            Console.WriteLine(string.Format("{0}\t{1}\t{2}\t{3}", "FunctionExecutionCount", execCountLastHour, execCountMonth, totalExecs));

            string[] lines =
            {
                "===============================================================================================",
                DateTime.Now.ToString(),
                "Toal Price: " + totalCost,
                "Metric\tHour\tMonth\tCost",
                string.Format("{0}\t{1}\t{2}\t{3}",                                                               "FunctionExecutionUnits",  execUnitsLastHour, execUnitMonth,  execTime),
                string.Format("{0}\t{1}\t{2}\t{3}",                                                               "FunctionExecutionCount",  execCountLastHour, execCountMonth, totalExecs)
            };
            WriteToFile(outputFilename, lines);
        }
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/user/account
        string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        string AuthToken  = "your_auth_token";
        var    client     = new MonitorClient(AccountSid, AuthToken);

        client.DeleteAlert("NO5a7a84730f529f0a76b3e30c01315d1a");
    }
Exemple #8
0
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/user/account
        string AccountSid = "{{ account_sid }}";
        string AuthToken  = "{{ auth_token }}";
        var    client     = new MonitorClient(AccountSid, AuthToken);

        var alert = client.GetAlert("NO5a7a84730f529f0a76b3e30c01315d1a");

        Console.WriteLine(alert.AlertText);
    }
Exemple #9
0
        public void TestDescribeMetrics()
        {
            MonitorClient          monitorClient = GetMonitorClient();
            DescribeMetricsRequest request       = new DescribeMetricsRequest();

            request.RegionId    = "cn-north-1";
            request.ServiceCode = "vm";
            var result = monitorClient.DescribeMetrics(request).Result;

            _output.WriteLine(JsonConvert.SerializeObject(result));
        }
Exemple #10
0
        private async Task <MonitorClient> authenticate(string tenantId, string clientId, string secret, string subscriptionId)
        {
            var serviceCreds = await ApplicationTokenProvider.LoginSilentAsync(tenantId, clientId, secret);

            var monitorClient = new MonitorClient(serviceCreds)
            {
                SubscriptionId = subscriptionId
            };

            return(monitorClient);
        }
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/user/account
        string AccountSid = "{{ account_sid }}";
        string AuthToken  = "{{ auth_token }}";
        var    monitor    = new MonitorClient(AccountSid, AuthToken);

        var e = monitor.GetEvent("AE21f24380625e4aa4abec76e39b14458d");

        Console.WriteLine(e.Description);
    }
Exemple #12
0
        private static async Task <MonitorClient> AuthenticateWithReadOnlyClient(string tenantId, string clientId, string secret, string subscriptionId)
        {
            // Build the service credentials and Monitor client
            var serviceCreds = await ApplicationTokenProvider.LoginSilentAsync(tenantId, clientId, secret);

            var monitorClient = new MonitorClient(serviceCreds);

            monitorClient.SubscriptionId = subscriptionId;

            return(monitorClient);
        }
Exemple #13
0
        public async Task <MonitorClient> GetMonitorClient()
        {
            var serviceCreds = await ApplicationTokenProvider.LoginSilentAsync(Default.TenantId, Default.ClientId, Default.Secret);

            var monitorClient = new MonitorClient(serviceCreds)
            {
                SubscriptionId = Default.SubscriptionId
            };

            return(monitorClient);
        }
Exemple #14
0
        public Form1()
        {
            InitializeComponent();

            InstanceContext ic = new InstanceContext(this);

            m_Client = new MonitorClient(ic);

            using (Testpublic t = new Testpublic())
            {
            }
        }
Exemple #15
0
 public static void Start()
 {
     Running = true;
     if (null == manager)
     {
         manager = new ServiceManager();
     }
     if (null == monitorClient)
     {
         monitorClient = new MonitorClient();
     }
     manager.Working();
 }
Exemple #16
0
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/user/account
        string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        string AuthToken  = "your_auth_token";
        var    client     = new MonitorClient(AccountSid, AuthToken);

        var alerts = twilio.ListAlerts();

        foreach (var alert in alerts.Alerts)
        {
            Console.WriteLine(alert.AlertText);
        }
    }
Exemple #17
0
        private static async Task RunMetricDefinitionsSample(MonitorClient readOnlyClient, string resourceUri)
        {
            // Get metrics definitions
            IEnumerable <MetricDefinition> metricDefinitions = await readOnlyClient.MetricDefinitions.ListAsync(resourceUri : resourceUri, cancellationToken : new CancellationToken());

            EnumerateMetricDefinitions(metricDefinitions);

            // The $filter can contain a propositional logic expression, specifically, a disjunction of the format: name.value eq '<metricName>' or name.value eq '<metricName>' ...
            var odataFilterMetricDef = new ODataQuery <MetricDefinition>("name.value eq 'CpuPercentage'");

            metricDefinitions = await readOnlyClient.MetricDefinitions.ListAsync(resourceUri : resourceUri, odataQuery : odataFilterMetricDef, cancellationToken : new CancellationToken());

            EnumerateMetricDefinitions(metricDefinitions);
        }
Exemple #18
0
        protected void PushCommandToRest(string transferObject)
        {
            var commandLineClient = new MonitorClient(AuspiciousCache.AuspiciousIp, AuspiciousCache.AuspiciousPort);
            commandLineClient.SendDataToRest(Guid.NewGuid(), (int)CommandType, RestaurantId,
             transferObject);

            commandLineClient.ResultResponse += CommandLineClient_ResultResponse;
            int index = 0;
            while (index < 15 && Code == 1)
            {
                index++;
                Thread.Sleep(200);
            }
        }
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at client.com/user/account
        string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        string AuthToken  = "your_auth_token";
        var    client     = new MonitorClient(AccountSid, AuthToken);

        var alerts = client.ListAlerts("warning", new DateTime(2015, 4, 1),
                                       new DateTime(2015, 4, 30));

        foreach (var alert in alerts.Alerts)
        {
            Console.WriteLine(alert.AlertText);
        }
    }
Exemple #20
0
        public void TestMetricsData()
        {
            MonitorClient             monitorClient = GetMonitorClient();
            DescribeMetricDataRequest request       = new DescribeMetricDataRequest();

            request.RegionId     = "cn-north-1";
            request.Metric       = "cpu_util";
            request.ServiceCode  = "vm";
            request.ResourceId   = "i-21n50s7wb4";
            request.TimeInterval = "1h";

            var result = monitorClient.DescribeMetricData(request);

            _output.WriteLine(JsonConvert.SerializeObject(result));
        }
Exemple #21
0
 public Monitor()
 {
     InitializeComponent();
     CreateWelcomePanel();
     this.Height           = 400;
     this.Width            = 400;
     returnButton          = new Button();
     returnButton.Text     = "return";
     returnButton.Size     = new Size(50, 30);
     returnButton.Location = new Point(0, 0);
     returnButton.Click   += new EventHandler(ReturnButtonClick);
     client = new MonitorClient();
     result = "test";
     Controls.Add(InitReturnPanel());
 }
Exemple #22
0
        private void GetData()
        {
            try
            {
                Credential cred = new Credential
                {
                    SecretId  = APIKey.SecretID,
                    SecretKey = APIKey.SecretKey
                };

                ClientProfile clientProfile = new ClientProfile();
                HttpProfile   httpProfile   = new HttpProfile();
                httpProfile.Endpoint      = ("monitor.tencentcloudapi.com");
                clientProfile.HttpProfile = httpProfile;

                MonitorClient         client = new MonitorClient(cred, IRegion, clientProfile);
                GetMonitorDataRequest req    = new GetMonitorDataRequest();
                req.Namespace  = "QCE/CVM";
                req.MetricName = Metric;
                Instance  instance1  = new Instance();
                Dimension dimension1 = new Dimension();
                dimension1.Name      = "InstanceId";
                dimension1.Value     = InstanceID;
                instance1.Dimensions = new Dimension[] { dimension1 };

                req.Instances = new Instance[] { instance1 };

                GetMonitorDataResponse resp = client.GetMonitorDataSync(req);

                dataPoints.Clear();
                for (int i1 = 0; i1 < resp.DataPoints[0].Timestamps.Length; i1++)
                {
                    MetricDataPoint i = new MetricDataPoint()
                    {
                        time = resp.DataPoints[0].Timestamps[i1], value = resp.DataPoints[0].Values[i1]
                    };
                    dataPoints.Enqueue(i);
                    if (dataPoints.Count > 10)
                    {
                        dataPoints.Dequeue();
                    }
                }
            }
            catch (Exception e)
            {
                SOLMain.WriteLogline("获取数据失败:" + e.Message, SOLMain.LogLevel.Error);
            }
        }
Exemple #23
0
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/user/account
        string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        string AuthToken  = "your_auth_token";
        var    monitor    = new MonitorClient(AccountSid, AuthToken);

        var options = new EventListRequest();

        options.ResourceSid = "PN4aa51b930717ea83c91971b86d99018f";
        var events = monitor.ListEvents(options);

        foreach (var e in events.Events)
        {
            Console.WriteLine(e.Description);
        }
    }
        public static void Main(string[] args)
        {
            string resourceGroupName  = "";
            string subscriptionID     = "";
            string storageAccountName = "";
            string resourceID         = "/subscriptions/" + subscriptionID + "/resourceGroups/" + resourceGroupName + "/providers/Microsoft.Storage/storageAccounts/" + storageAccountName;

            Console.WriteLine("Resource ID: " + resourceID);

            string tenantID      = "";
            string applicationID = "";
            string accessKey     = "";

            readOnlyClient = AuthenticateWithReadOnlyClient(tenantID, applicationID, accessKey, subscriptionID).Result;

            GetMetricDefinitions(resourceID).Wait();
        }
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/user/account
        string AccountSid = "{{ account_sid }}";
        string AuthToken  = "{{ auth_token }}";
        var    monitor    = new MonitorClient(AccountSid, AuthToken);

        var options = new EventListRequest();

        options.ActorSid    = "USd0afd67cddff4ec7cb0022771a203cb1";
        options.ResourceSid = "PN4aa51b930717ea83c91971b86d99018f";
        var events = monitor.ListEvents(options);

        foreach (var e in events.Events)
        {
            Console.WriteLine(e.Description);
        }
    }
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/user/account
        string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        string AuthToken  = "your_auth_token";
        var    monitor    = new MonitorClient(AccountSid, AuthToken);

        var options = new EventListRequest();

        options.StartDate = new DateTime(2015, 3, 1);
        options.EndDate   = new DateTime(2015, 4, 1);
        var events = monitor.ListEvents(options);

        foreach (var e in events.Events)
        {
            Console.WriteLine(e.Description);
        }
    }
Exemple #27
0
        public void Execute(IJobExecutionContext context)
        {
            Logger.Info("开始运行监控脚本文件");
            try
            {
                using (var client = new MonitorClient())
                {
                    var result = client.KeepJobAlive("WinService_CJob");
                    result.ThrowIfException(true);
                }
            }
            catch (Exception ex)
            {
                Logger.Warn($"WinService_JobSchedulerService{ex.Message}");
            }

            Logger.Info("脚本运行完成");
        }
Exemple #28
0
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/user/account
        string AccountSid = "{{ account_sid }}";
        string AuthToken  = "{{ auth_token }}";
        var    monitor    = new MonitorClient(AccountSid, AuthToken);

        var options = new EventListRequest();

        options.SourceIpAddress = "104.14.155.29";
        options.StartDate       = new DateTime(2015, 4, 25);
        options.EndDate         = new DateTime(2015, 4, 25, 23, 59, 59);
        var events = monitor.ListEvents(options);

        foreach (var e in events.Events)
        {
            Console.WriteLine(e.Description);
        }
    }
        public void Execution()
        {
            if (string.IsNullOrEmpty(SystemConst.AuspiciousIp) || SystemConst.AuspiciousPort == 0)
            {
                LogUtility.SendError("未初始监控吉利端口!!!");
                return;
            }

            var commandLineClient = new MonitorClient(SystemConst.AuspiciousIp, SystemConst.AuspiciousPort);

            commandLineClient.SendDataToProxy(Guid.NewGuid(), 20);
            if (commandLineClient.State == MonitorClientState.Error)
            {
                if (CanNotConnectTime % 5 == 1)
                {
                    SmsUtility.SendAuspiciousError($"中间端连接有异常{DateTime.Now}");
                }
                CanNotConnectTime++;
            }
        }
Exemple #30
0
        public static void Main(string[] args)
        {
            var client        = new MonitorClient();
            var servicesCount = client.GetServicesCount();

            Console.WriteLine("Services available: {0}", servicesCount);
            Console.WriteLine();

            ServiceInfo[] services;

            services = client.QueryServices(new EmptyQuery());
            Console.WriteLine("EmptyQuery returns empty result set = {0}", services.Length == 0);

            services = client.QueryServices(new SelectServicesWithSpecifiedNameQuery
            {
                Name = "master-us"
            });
            Console.WriteLine("(master-us node exists && count == 1) == {0}", services.Any() && services.Length == 1);

            services = client.QueryServices(new SelectServicesWithNameContainsQuery
            {
                NameText = "slave"
            });
            Console.WriteLine("(*slave* nodes exist && count == 2) == {0}", services.Any() && services.Length == 2);

            services = client.QueryServices(new SelectServicesWithSpecifiedTypeQuery
            {
                Type = "UserStorageSlave"
            });
            Console.WriteLine("(UserStorageSlave type nodes exist && count == 2) == {0}", services.Any() && services.Length == 2);

            services = client.QueryServices(new SelectAllServicesQuery());
            Console.WriteLine("\nServices:");
            foreach (var service in services)
            {
                Console.WriteLine("\tName: {0}, Type: {1}, Url: {2} ({3})", service.ServiceName, service.ServiceType, service.ServiceUrl, service.ServiceDebugInfo);
            }

            Console.WriteLine("\nPress Enter to continue.");
            Console.ReadLine();
        }
Exemple #31
0
        /// <summary>
        /// Processes all pending tasks that can be found in the queue.
        /// </summary>
        protected internal virtual void ProcessPendingTasks()
        {
            var examinedTasks = new HashSet <Guid>();
            var anyNewTasks   = true;

            // if a task had been preserved from the previous iteration,
            // process it before moving forward.
            if (MonitorClient.CurrentTask != null)
            {
                examinedTasks.Add(MonitorClient.CurrentTask.Identifier);
                ProcessTask(MonitorClient.CurrentTask);
            }

            while (anyNewTasks)
            {
                anyNewTasks = false;
                var taskCount = MonitorClient.PendingTasks(Settings.Default.Queue).Count;
                for (var index = 0; index < taskCount; index++)
                {
                    TaskMessage task;

                    try { task = MonitorClient.Reserve(Settings.Default.Queue); }
                    catch (QueueIsEmptyException)
                    {
                        Log.DebugFormat("No tasks in queue [{0}]", new QueueName(Settings.Default.Queue).NameWhenPending);
                        return;
                    }

                    if (examinedTasks.Contains(task.Identifier))
                    {
                        continue;
                    }

                    anyNewTasks = true;
                    ProcessTask(task);
                    examinedTasks.Add(task.Identifier);
                }
            }
        }
Exemple #32
0
        static void Main(string[] args)
        {
            var tenantId       = Environment.GetEnvironmentVariable("AZURE_TENANT_ID");
            var clientId       = Environment.GetEnvironmentVariable("AZURE_CLIENT_ID");
            var secret         = Environment.GetEnvironmentVariable("AZURE_CLIENT_SECRET");
            var subscriptionId = Environment.GetEnvironmentVariable("AZURE_SUBSCRIPTION_ID");

            if (new List <string> {
                tenantId, clientId, secret, subscriptionId
            }.Any(i => String.IsNullOrEmpty(i)))
            {
                Console.WriteLine("Please provide environment variables for AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET and AZURE_SUBSCRIPTION_ID.");
            }
            else
            {
                readOnlyClient = AuthenticateWithReadOnlyClient(tenantId, clientId, secret, subscriptionId).Result;
                var resourceId = args[0];

                CalculateFunctionAppCost(readOnlyClient, resourceId, @"C:\temp\FunctionCost.txt");

                Console.Read();
            }
        }
Exemple #33
0
        public void Connect(string server)
        {
            try
            {
                if (!isConnected)
                {
                    monitorClient = new MonitorClient(new BasicHttpBinding()
                    {
                        OpenTimeout = TimeSpan.FromSeconds(5),
                        SendTimeout = TimeSpan.FromSeconds(10),
                        ReceiveTimeout = TimeSpan.FromSeconds(10),
                        CloseTimeout = TimeSpan.FromSeconds(5)
                    }, new EndpointAddress(string.Format(ConfigurationManager.AppSettings["connectionFormat"], server)));

                    //monitorClient.Open();
                    monitorClient.IsStarted();
                    //monitorClient.ChannelFactory.Open();

                    isConnected = true;
                    Update();
                    timer.Start();
                }
            }
            catch (TimeoutException te)
            {
            #if DEBUG
                view.ShowError(te.ToString());
            #else
                view.ShowError(te.Message);
            #endif
            }
            catch (EndpointNotFoundException enfe)
            {
            #if DEBUG
                view.ShowError(enfe.ToString());
            #else
                view.ShowError(enfe.Message);
            #endif
            }
        }
Exemple #34
0
 protected void PushCommandToProxy(string transferObject)
 {
     var commandLineClient = new MonitorClient(AuspiciousCache.AuspiciousIp, AuspiciousCache.AuspiciousPort);
     commandLineClient.SendDataToProxy(Guid.NewGuid(), (int)CommandType,
         string.Format("{0}:{1}", RestaurantId, transferObject));
 }