This commit is contained in:
@@ -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<IActionResult> 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<IActionResult> 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
|
||||
|
||||
/// <summary>
|
||||
/// 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<double, double>(z.t.ToOADate(), z.PrivateBytes)).ToList();
|
||||
dsPrivateBytes = Util.DataUtil.LargestTriangleThreeBuckets(dsPrivateBytes, (int)maxRecords) as List<Tuple<double, double>>;
|
||||
|
||||
|
||||
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<MetricNameLongValue> TopTables = new List<MetricNameLongValue>();
|
||||
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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user