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)); }
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); }
private static async Task StoreActiveDatabaseNames(ServerRecord server, AsyncServerClient client, IAsyncDocumentSession session) { AdminStatistics adminStatistics = await client.GlobalAdmin.GetStatisticsAsync(); server.IsUnauthorized = false; server.ClusterName = adminStatistics.ClusterName; server.ServerName = adminStatistics.ServerName; server.MemoryStatistics = adminStatistics.Memory; foreach (var loadedDatabase in adminStatistics.LoadedDatabases) { var databaseRecord = await session.LoadAsync <DatabaseRecord>(server.Id + "/" + loadedDatabase.Name); if (databaseRecord == null) { databaseRecord = new DatabaseRecord { Name = loadedDatabase.Name, ServerId = server.Id, ServerUrl = server.Url }; await session.StoreAsync(databaseRecord); } databaseRecord.LoadedDatabaseStatistics = loadedDatabase; } server.LoadedDatabases = adminStatistics.LoadedDatabases.Select(database => database.Name).ToArray(); }
public async Task <AdminStatistics> getAdminStatistics() { Stopwatch stopwatch = new Stopwatch(); AdminStatistics astats = new AdminStatistics(); stopwatch.Start(); var res1 = await _unitOfWork.UserRepository.FindAllWhereAsync(x => x.id_position == 1); var res2 = await _unitOfWork.UserRepository.FindAllWhereAsync(x => x.id_position == 2); var res3 = await _unitOfWork.UserRepository.FindAllWhereAsync(x => x.id_position == 3); var res4 = await _unitOfWork.UserRepository.FindAllWhereAsync(x => x.emailconfirm == false); var res5 = await _unitOfWork.TransRepository.FindAllWhereAsync(x => x.translate_status == 1); var res6 = await _unitOfWork.TransRepository.FindAllWhereAsync(x => x.translate_status == 4); var res7 = await _unitOfWork.TransRepository.FindAllWhereAsync(x => x.translate_status == 3); var res8 = await _unitOfWork.TransRepository.FindAllWhereAsync(x => x.end_date > DateTime.Now); astats.totalusers = res1.Count(); astats.totaltranslators = res2.Count(); astats.totaladmins = res3.Count(); astats.notredeemedusers = res4.Count(); astats.posted = res5.Count(); astats.translated = res6.Count(); astats.inprogress = res7.Count(); astats.expired = res8.Count(); //astats.totalusers = _unitOfWork.UserRepository.FindAllWhere(x => x.id_position == 1).Count(); //astats.totaltranslators = _unitOfWork.UserRepository.FindAllWhere(x => x.id_position == 2).Count(); //astats.totaladmins = _unitOfWork.UserRepository.FindAllWhere(x => x.id_position == 3).Count(); //astats.notredeemedusers = _unitOfWork.UserRepository.FindAllWhere(x => x.emailconfirm == false).Count(); stopwatch.Stop(); TimeSpan ts = stopwatch.Elapsed; return(astats); }
public GetDatabaseAndServerStatistics() { using (var store = new DocumentStore()) { #region database_statistics_2 DatabaseStatistics statistics = store.DatabaseCommands.GetStatistics(); #endregion } using (var store = new DocumentStore()) { #region server_statistics_2 AdminStatistics serverStatistics = store .DatabaseCommands .GlobalAdmin .GetStatistics(); #endregion } }
public async Task <AdminStatistics> IndexStatisticsData() { var accountDepositsList = (await _accountDepositService.Get()).ToList(); var requestedDeposits = accountDepositsList.Count(x => x.Status == Status.Pending.ToString()); var acceptedDeposits = accountDepositsList.Count(x => x.Status == Status.IsActive.ToString()); var rejectedDeposits = accountDepositsList.Count(x => x.Status == Status.Rejected.ToString()); var accountLoansList = (await _accountLoanService.Get()).ToList(); var requestedLoans = accountLoansList.Count(x => x.Status == Status.Pending.ToString()); var acceptedLoans = accountLoansList.Count(x => x.Status == Status.IsActive.ToString()); var rejectedLoans = accountLoansList.Count(x => x.Status == Status.Rejected.ToString()); var accountCardsList = (await _cardService.Get()).ToList(); var requestedCards = accountCardsList.Count(x => x.Status == CardStatus.Pending.ToString()); var acceptedCards = accountCardsList.Count(x => x.Status == CardStatus.Active.ToString()); var rejectedCards = accountCardsList.Count(x => x.Status == CardStatus.Rejected.ToString()); var users = (await _userService.Get()).ToList(); var activeUsersCount = users.Count(x => x.IsBanned == false); var blockedUsersCount = users.Count(x => x.IsBanned == true); var adminStatistics = new AdminStatistics { RequestedDeposits = requestedDeposits, AcceptedDeposits = acceptedDeposits, RejectedDeposits = rejectedDeposits, RequestedLoans = requestedLoans, AcceptedLoans = acceptedLoans, RejectedLoans = rejectedLoans, RequestedCards = requestedCards, AcceptedCards = acceptedCards, RejectedCards = rejectedCards, ActiveUsersCount = activeUsersCount, BlockedUsersCount = blockedUsersCount }; return(adminStatistics); }