private string InvokeExternalExe(PlatformType platformType, SystemLoadType systemLoadType, string podName, string startTime, string endTime)
        {
            var exePath     = _mDMOptions.ExternalExePath;//"C:/home/Work/DevDiv/MDMetricsClientSampleCode/bin/Debug/MDMetricsClientSampleCode.exe";
            var argsBuilder = new StringBuilder();

            argsBuilder.Append(podName).Append(" ")
            .Append(platformType.ToString()).Append(" ")
            .Append(systemLoadType.ToString()).Append(" ")
            .Append(startTime).Append(" ")
            .Append(endTime).Append(" ")
            .Append(_mDMOptions.ResultPath);
            var task = RunProcessAsync(exePath, argsBuilder.ToString());

            if (task && File.Exists(_mDMOptions.ResultPath))
            {
                string content;
                using (StreamReader file = new StreamReader(_mDMOptions.ResultPath, true))
                {
                    content = file.ReadToEnd();
                }
                File.Delete(_mDMOptions.ResultPath);
                return(content);
            }
            else
            {
                Console.WriteLine("Exe has not completed successfully!");
            }
            return(null);
        }
Exemple #2
0
        public static string QueryMetrics(string podName, PlatformType platformType, SystemLoadType systemLoadType, DateTime startTime, DateTime endTime, string filePath)
        {
            if (platformType == PlatformType.Dogfood)
            {
                var testCertificateThumbprint = "C35CBFF9FA6C51E51E1DE97B6D1E246F27661301";
                var httpsUrl       = "https://shoebox2.metrics.nsatc.net/public/monitoringAccount/SignalRShoeboxTest/homeStamp";
                var connectionInfo = new ConnectionInfo(new Uri(httpsUrl), testCertificateThumbprint, StoreLocation.LocalMachine);
                var id             = new MetricIdentifier("SignalRShoeboxTest", "systemLoad", systemLoadType == SystemLoadType.CPU ? "PodCpuUsage" : "PodMemory");
                var reader         = new MetricReader(connectionInfo);

                // The short link for this series is http://jarvis-int.dc.ad.msft.net/D10A9E2E.
                var definition = new TimeSeriesDefinition <MetricIdentifier>(
                    id,
                    new Dictionary <string, string> {
                    { "podName", podName }
                });

                TimeSeries <MetricIdentifier, double?> result =
                    reader.GetTimeSeriesAsync(startTime, endTime, SamplingType.Max, definition).Result;
                var strOutput = JsonConvert.SerializeObject(result);
                using (System.IO.StreamWriter file = new System.IO.StreamWriter(filePath, false))
                {
                    file.Write(strOutput);
                }
                return(strOutput);
            }
            return(null);
        }
 public string QueryMetrics(PlatformType platformType, SystemLoadType systemLoadType, string podName, string startTime, string endTime)
 {
     if (platformType == PlatformType.Dogfood)
     {
         var result = InvokeExternalExe(platformType, systemLoadType, podName, startTime, endTime);
         return(result);
     }
     return(null);
 }