示例#1
0
		private AdminStatistics CreateAdminStats()
		{
			var allDbs = new List<DocumentDatabase>();
			var allFs = new List<RavenFileSystem>();
			DatabasesLandlord.ForAllDatabases(allDbs.Add);
			FileSystemsLandlord.ForAllFileSystems(allFs.Add);
			var currentConfiguration = DatabasesLandlord.SystemConfiguration;


			var stats = new AdminStatistics
			{
				ServerName = currentConfiguration.ServerName,
				TotalNumberOfRequests = RequestManager.NumberOfRequests,
				Uptime = SystemTime.UtcNow - RequestManager.StartUpTime,
				Memory = new AdminMemoryStatistics
				{
					DatabaseCacheSizeInMB = ConvertBytesToMBs(DatabasesLandlord.SystemDatabase.TransactionalStorage.GetDatabaseCacheSizeInBytes()),
					ManagedMemorySizeInMB = ConvertBytesToMBs(GetCurrentManagedMemorySize()),
					TotalProcessMemorySizeInMB = ConvertBytesToMBs(GetCurrentProcessPrivateMemorySize64()),
				},
				LoadedDatabases = LoadedDatabasesStats(allDbs),
				LoadedFileSystems = from fileSystem in allFs
									select fileSystem.GetFileSystemStats()
			};
			return stats;
		}
示例#2
0
		public HttpResponseMessage Stats()
		{
			if (Database != DatabasesLandlord.SystemDatabase)
				return GetMessageWithString("Admin stats can only be had from the root database", HttpStatusCode.NotFound);

		    var allDbs = new List<DocumentDatabase>();
            var allFs = new List<RavenFileSystem>();
            DatabasesLandlord.ForAllDatabases(allDbs.Add);
            FileSystemsLandlord.ForAllFileSystems(allFs.Add);
		    var currentConfiguration = DatabasesLandlord.SystemConfiguration;

            
            var stats =  new AdminStatistics
            {
                ServerName = currentConfiguration.ServerName,
                TotalNumberOfRequests = RequestManager.NumberOfRequests,
                Uptime = SystemTime.UtcNow - RequestManager.StartUpTime,
                Memory = new AdminMemoryStatistics
                {
                    DatabaseCacheSizeInMB = ConvertBytesToMBs(DatabasesLandlord.SystemDatabase.TransactionalStorage.GetDatabaseCacheSizeInBytes()),
                    ManagedMemorySizeInMB = ConvertBytesToMBs(GetCurrentManagedMemorySize()),
                    TotalProcessMemorySizeInMB = ConvertBytesToMBs(GetCurrentProcessPrivateMemorySize64()),
                },
                LoadedDatabases =
                    from documentDatabase in allDbs
                    let indexStorageSize = documentDatabase.GetIndexStorageSizeOnDisk()
                    let transactionalStorageSize = documentDatabase.GetTransactionalStorageSizeOnDisk()
                    let totalDatabaseSize = indexStorageSize + transactionalStorageSize.AllocatedSizeInBytes
                    let lastUsed = DatabasesLandlord.LastRecentlyUsed.GetOrDefault(documentDatabase.Name ?? Constants.SystemDatabase)
                    select new LoadedDatabaseStatistics
                    {
                        Name = documentDatabase.Name,
                        LastActivity = new[]
							{
								lastUsed,
								documentDatabase.WorkContext.LastWorkTime
							}.Max(),
                        TransactionalStorageAllocatedSize = transactionalStorageSize.AllocatedSizeInBytes,
                        TransactionalStorageAllocatedSizeHumaneSize = SizeHelper.Humane(transactionalStorageSize.AllocatedSizeInBytes),
                        TransactionalStorageUsedSize = transactionalStorageSize.UsedSizeInBytes,
                        TransactionalStorageUsedSizeHumaneSize = SizeHelper.Humane(transactionalStorageSize.UsedSizeInBytes),
                        IndexStorageSize = indexStorageSize,
                        IndexStorageHumaneSize = SizeHelper.Humane(indexStorageSize),
                        TotalDatabaseSize = totalDatabaseSize,
                        TotalDatabaseHumaneSize = SizeHelper.Humane(totalDatabaseSize),
                        CountOfDocuments = documentDatabase.Statistics.CountOfDocuments,
                        CountOfAttachments = documentDatabase.Statistics.CountOfAttachments,

                        DatabaseTransactionVersionSizeInMB = ConvertBytesToMBs(documentDatabase.TransactionalStorage.GetDatabaseTransactionVersionSizeInBytes()),
                        Metrics = documentDatabase.CreateMetrics()
                    },
                LoadedFileSystems = from fileSystem in allFs
                   select fileSystem.GetFileSystemStats()
            };

            return GetMessageWithObject(stats);
		}