Пример #1
0
        public static AzureResponse PostRequest(AzurePayload payload)
        {
            HttpWebRequest request = CreatePOSTRequest(AZURE_DASHBOARD_URL);

            //HEADER INFO
            request.PreAuthenticate = true;
            request.Headers.Add("csrfToken", Properties.Get("CSRFToken"));
            request.Headers.Add("Authorization", GetBearerAuthToken());
            request.Headers.Add("Origin", "https://jarvis-west.dc.ad.msft.net");
            request.Headers.Add("DNT", "1");
            request.Headers.Add("x-ms-app", "Jarvis.Dashboard");
            request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36";
            request.Referer   = "https://jarvis-west.dc.ad.msft.net/app/canvas/w/mdm/MDMProfilePage?wires={%22account%22:%22%22,%22namespace%22:%22%22,%22profile%22:%22%22,%22selected%22:%22$$$%22,%22globalStartTime%22:-3600000,%22globalEndTime%22:-1,%22pinGlobalTimeRange%22:false,%22syncGlobalTimeRange%22:false,%22presentationMode%22:false,%22refreshTick%22:1542213399097,%22refreshInterval%22:0,%22pendingSave%22:null,%22pendingWidgets%22:[],%22pendingShare%22:false,%22pendingExport%22:null,%22pendingImport%22:false,%22overrides%22:[{%22query%22:%22//kusto%22,%22key%22:%22connection%22,%22replacement%22:%22https://sqlazureuk2.kustomfa.windows.net:443%22},{%22query%22:%22//conditions[id=%27AzureSqlServer%27]%22,%22key%22:%22value%22,%22replacement%22:%22g5ajmo36i2%22}],%22dashboardBrowserTab%22:0,%22dashboardBrowserVisible%22:true,%22selectedAccounts%22:%22SPOProd,SPODogFood,SPOMSIT,sporunners%22,%22dashboardBrowserTreeFilter%22:%22%22,%22selectedPath%22:[%22SPOProd%22,%22OCE%22,%22Azure%20Dashboard%22],%22dashboardId%22:%22%22,%22v%22:1542136435389}";

            byte[] content = ConvertPayloadToContentByteArray(payload);
            request.ContentLength = content.Length;
            using (Stream dataStream = request.GetRequestStream())
            {
                dataStream.Write(content, 0, content.Length);
                dataStream.Close();
            }

            OptionsRequest();

            // Get response
            AzureResponse jsonResponse = GetRequestResponse(request);

            return(jsonResponse);
        }
Пример #2
0
        public static AzureOverview Get(string azureLabel, DateTime startTime, DateTime endTime)
        {
            AzureOverview overview = new AzureOverview(azureLabel, startTime, endTime);

            Console.WriteLine(" ---- NODE DB BREAKDOWN ---- ");
            // Node / DB Breakdown
            AzurePayload requestPayload = new AzurePayload()
            {
                DB  = "sqlazure1",
                CSL = GetNodeDBBreakdownCSL(azureLabel)
            };
            AzureResponse response = AzureRequester.PostRequest(requestPayload);

            // find useful info
            AzureResponseTable azureTable = response.Tables.Find(table => table.Columns.Exists(column => column.ColumnName.Equals("database_name")));

            foreach (List <dynamic> row in azureTable.Rows)
            {
                DBNode breakdown = new DBNode((string)row[0], (string)row[1], (string)row[2], (string)row[3], (string)row[4], (string)row[5]);
                overview.DBNodes.Add(breakdown);
            }

            Console.WriteLine(" ---- Average CPU % Per Pool Node ---- ");
            // Average CPU % per Pool Node
            requestPayload.CSL = GetPerNodeCSL(azureLabel, startTime, endTime, "avg_cpu_percent");
            response           = AzureRequester.PostRequest(requestPayload);

            // find useful info
            azureTable = response.Tables.Find(table => table.Columns.Exists(column => column.ColumnName.Equals("avg_cpu_percent")));
            foreach (List <dynamic> row in azureTable.Rows)
            {
                AvgCPUPct cpuPct = new AvgCPUPct((DateTime)row[0], (string)row[1], (string)row[2], (string)row[3], (double)row[4]);
                overview.AddAvgCpuPct(cpuPct);
            }

            Console.WriteLine(" ---- Peak Worker % per Pool Node ---- ");
            // Peak Worker % per Pool Node
            requestPayload.CSL = GetPerNodeCSL(azureLabel, startTime, endTime, "peak_worker_percent");
            response           = AzureRequester.PostRequest(requestPayload);

            // find useful info
            azureTable = response.Tables.Find(table => table.Columns.Exists(column => column.ColumnName.Equals("peak_worker_percent")));
            foreach (List <dynamic> row in azureTable.Rows)
            {
                PeakWorkPct peakPct = new PeakWorkPct((DateTime)row[0], (string)row[1], (string)row[2], (string)row[3], (double)row[4]);
                overview.AddPeakWorkerPct(peakPct);
            }

            return(overview);
        }