diff --git a/server/AyaNova/Controllers/ServerMetricsController.cs b/server/AyaNova/Controllers/ServerMetricsController.cs index bb4713e5..e6082684 100644 --- a/server/AyaNova/Controllers/ServerMetricsController.cs +++ b/server/AyaNova/Controllers/ServerMetricsController.cs @@ -49,37 +49,37 @@ namespace AyaNova.Api.Controllers serverState = apiServerState; } -// #if (DEBUG) -// [HttpGet("collect")] -// [AllowAnonymous] -// public ActionResult GetCollect() -// { -// GC.Collect(); -// GC.WaitForPendingFinalizers(); -// GC.Collect(); + // #if (DEBUG) + // [HttpGet("collect")] + // [AllowAnonymous] + // public ActionResult GetCollect() + // { + // GC.Collect(); + // GC.WaitForPendingFinalizers(); + // GC.Collect(); -// return Ok(); -// } + // return Ok(); + // } -// [HttpGet("hammer")] -// [AllowAnonymous] -// public async Task GetHammer() -// { -// //test allocation and cleanup -// for (int x = 0; x < 100000; x++) -// { -// using (AyContext ct = ServiceProviderProvider.DBContext) -// var v=await ct.Widget.Where(z=>z.Serial<100).ToListAsync(); -// // int i = await ct.Database.ExecuteSqlRawAsync($"select * from aglobalbizsettings"); -// } + // [HttpGet("hammer")] + // [AllowAnonymous] + // public async Task GetHammer() + // { + // //test allocation and cleanup + // for (int x = 0; x < 100000; x++) + // { + // using (AyContext ct = ServiceProviderProvider.DBContext) + // var v=await ct.Widget.Where(z=>z.Serial<100).ToListAsync(); + // // int i = await ct.Database.ExecuteSqlRawAsync($"select * from aglobalbizsettings"); + // } -// return Ok(); -// } + // return Ok(); + // } -// #endif + // #endif /// /// Get Memory and CPU server metrics for time period specified @@ -118,10 +118,10 @@ namespace AyaNova.Api.Controllers var dsPrivateBytes = MinuteMetrics.Select(z => new Tuple(z.t.ToOADate(), z.PrivateBytes)).ToList(); dsPrivateBytes = Util.DataUtil.LargestTriangleThreeBuckets(dsPrivateBytes, (int)maxRecords) as List>; - + var ret = new { - cpu = dsCPU.Select(z => new MetricDouble(DateTime.FromOADate(z.Item1), z.Item2)).ToArray(), + cpu = dsCPU.Select(z => new MetricDouble(DateTime.FromOADate(z.Item1), z.Item2)).ToArray(), allocated = dsAllocated.Select(z => new MetricLong(DateTime.FromOADate(z.Item1), z.Item2 / MB)).ToArray(), workingSet = dsWorkingSet.Select(z => new MetricLong(DateTime.FromOADate(z.Item1), z.Item2 / MB)).ToArray(), privateBytes = dsPrivateBytes.Select(z => new MetricLong(DateTime.FromOADate(z.Item1), z.Item2 / MB)).ToArray() @@ -227,10 +227,19 @@ namespace AyaNova.Api.Controllers //############# TOP TABLES KB - + int AllTableCount=0; List TopTables = new List(); using (var command = ct.Database.GetDbConnection().CreateCommand()) { + /* + SELECT table_name, pg_total_relation_size(table_name) AS total_size +FROM ( SELECT ( table_schema || '.' || table_name ) +AS table_name FROM information_schema.tables +where table_schema not in('pg_catalog','information_schema')) +AS all_tables +ORDER BY total_size DESC + */ + var cmd = @"SELECT table_name, pg_total_relation_size(table_name) AS total_size @@ -249,6 +258,7 @@ namespace AyaNova.Api.Controllers { while (dr.Read()) { + AllTableCount++; long tableSize = dr.GetInt64(1); string tableName = dr.GetString(0); tableName = tableName.Replace("\"", "").Replace("public.a", ""); @@ -265,6 +275,7 @@ namespace AyaNova.Api.Controllers //trim out tables less than 1kb (the math above sets anything less than 1kb to zero) TopTables = TopTables.Where(z => z.value > 48).ToList();//NOTE: empty tables seem to all be 48kb so that's why this is here + int OtherTableCount=AllTableCount-TopTables.Count(); long DBTotalSize = 0; using (var command = ct.Database.GetDbConnection().CreateCommand()) @@ -286,7 +297,7 @@ namespace AyaNova.Api.Controllers { ttSize += tt.value; } - TopTables.Add(new MetricNameLongValue() { name = "other", value = DBTotalSize - ttSize }); + TopTables.Add(new MetricNameLongValue() { name = $"{OtherTableCount} others", value = DBTotalSize - ttSize }); var ret = new {