Exemple #1
0
        public override void ExecuteCommand()
        {
            //Get the logs for the previous Hour as the current one is being used by Azure.
            string        DeploymentID  = new JavaScriptSerializer().Deserialize <string>(ReportHelpers.Load(StorageAccount, "DeploymentId_" + ServiceName + ".json", ContainerName));
            string        latestLogName = "u_ex" + string.Format("{0:yyMMddHH}", DateTime.UtcNow.AddHours(-1)) + ".log";
            DirectoryInfo info          = new System.IO.DirectoryInfo(Path.Combine(Environment.CurrentDirectory, latestLogName));

            //Downlog the logs for the last hour.
            while (RetryCount-- > 0)
            {
                try
                {
                    if (!Directory.Exists(info.FullName))
                    {
                        Directory.CreateDirectory(info.FullName);
                    }

                    int instanceCount = GetCurrentInstanceCountInGallery(); //get current instance count.
                    for (int i = 0; i < instanceCount; i++)
                    {
                        ReportHelpers.DownloadBlobToLocalFile(IISStorageAccount, DeploymentID + "/NuGetGallery/NuGetGallery_IN_" + i.ToString() + "/Web/W3SVC1273337584/" + latestLogName, Path.Combine(info.FullName, "IN" + i.ToString() + ".log"), "wad-iis-requestlogs");
                    }
                    break; // break if the operation succeeds without doing any retry.
                }
                catch (Exception e)
                {
                    Console.WriteLine(string.Format("Exception thrown while trying to create report : {0}", e.Message));
                }
            }
            //Create reports.
            CreateOverviewReport(info);
            CreateUriStemDetailedReport(info);
        }
        public override void ExecuteCommand()
        {
            //Get the logs for the previous day.
            string DeploymentID = new JavaScriptSerializer().Deserialize <string>(ReportHelpers.Load(StorageAccount, "DeploymentId_" + ServiceName + ".json", ContainerName));
            string blobName     = DeploymentID + "/NuGetGallery/NuGetGallery_IN_{IID}/Web/W3SVC1273337584/u_ex{Date}{Hour}.log";

            blobName = blobName.Replace("{Date}", ReportDate);

            DirectoryInfo info = new System.IO.DirectoryInfo(Environment.CurrentDirectory);

            //Downlog the logs for the last day.

            while (RetryCount-- > 0)
            {
                try
                {
                    if (!Directory.Exists(info.FullName))
                    {
                        Directory.CreateDirectory(info.FullName);
                    }

                    int instanceCount = GetCurrentInstanceCountInGallery(); //get current instance count.
                    for (int i = 0; i < instanceCount; i++)
                    {
                        for (int j = 0; j < 24; j++) //Download the log for each hour
                        {
                            string temp = blobName;
                            temp = temp.Replace("{IID}", i.ToString());
                            temp = temp.Replace("{Hour}", j.ToString("00"));

                            string logName = temp.Substring(temp.LastIndexOf("/") + 1);
                            logName = logName.Substring(0, logName.Length - 4);
                            string localFile = Path.Combine(info.FullName, logName + i.ToString() + "_" + j.ToString() + ".log");
                            ReportHelpers.DownloadBlobToLocalFile(IISStorageAccount, temp, localFile, "wad-iis-requestlogs");
                        }
                    }
                    break; // break if the operation succeeds without doing any retry.
                }
                catch (Exception e)
                {
                    Console.WriteLine(string.Format("Exception thrown while trying to create report : {0}", e.Message));
                }
            }

            //Create a json file
            CreateIPDetailsReport(info);
            CreateResponseTimeReport(info);
            CreateUserAgentReport(info);
        }