예제 #1
0
        public List <MonitoringFile> GetCollectedLogsForSession(string sessionId, string blobSasUri)
        {
            var filesCollected = new List <MonitoringFile>();

            if (string.IsNullOrWhiteSpace(blobSasUri))
            {
                string folderName = CpuMonitoring.GetLogsFolderForSession(sessionId);
                if (FileSystemHelpers.DirectoryExists(folderName))
                {
                    var logFiles = FileSystemHelpers.GetFilesInDirectory(folderName, "*.dmp", false, SearchOption.TopDirectoryOnly);
                    foreach (var fileName in logFiles)
                    {
                        string relativePath = MonitoringFile.GetRelativePath(sessionId, Path.GetFileName(fileName));
                        filesCollected.Add(new MonitoringFile(fileName, relativePath));
                    }
                }
            }
            else
            {
                string        directoryPath = Path.Combine("Monitoring", "Logs", sessionId);
                List <string> files         = new List <string>();
                var           dir           = BlobController.GetBlobDirectory(directoryPath, blobSasUri);
                foreach (
                    IListBlobItem item in
                    dir.ListBlobs(useFlatBlobListing: true))
                {
                    var    relativePath = item.Uri.ToString().Replace(item.Container.Uri.ToString() + "/", "");
                    string fileName     = item.Uri.Segments.Last();
                    filesCollected.Add(new MonitoringFile(fileName, relativePath));
                }
            }
            return(filesCollected);
        }
예제 #2
0
        private void MoveMonitoringLogsToSession(string sessionId)
        {
            string logsFolderPath         = CpuMonitoring.GetLogsFolderForSession(sessionId);
            string monitoringFolderActive = GetCpuMonitoringPath(MonitoringSessionDirectories.Active);
            var    filesCollected         = FileSystemHelpers.GetFilesInDirectory(monitoringFolderActive, "*.log", false, SearchOption.TopDirectoryOnly);

            foreach (string monitoringLog in filesCollected)
            {
                string fileName = Path.GetFileName(monitoringLog);
                fileName = Path.Combine(logsFolderPath, fileName);
                Logger.LogCpuMonitoringVerboseEvent($"Moving {monitoringLog} to {fileName}", sessionId);
                RetryHelper.RetryOnException("Moving monitoring log to logs folder...", () =>
                {
                    FileSystemHelpers.MoveFile(monitoringLog, fileName);
                }, TimeSpan.FromSeconds(5), 5);
            }
        }